Skip to content

Commit

Permalink
update v4
Browse files Browse the repository at this point in the history
  • Loading branch information
sstaub committed Jan 29, 2024
1 parent 46c2b18 commit ea734e0
Show file tree
Hide file tree
Showing 13 changed files with 1,553 additions and 1,216 deletions.
694 changes: 426 additions & 268 deletions README.md

Large diffs are not rendered by default.

108 changes: 60 additions & 48 deletions examples/gma3_Arduino/gma3_Arduino.ino
Original file line number Diff line number Diff line change
@@ -1,71 +1,83 @@
#include <Ethernet3.h>
#include <EthernetUdp3.h>
// Example for Arduino with Ethernetshield 2

#include <Ethernet.h> // for Arduino Ethernet library https://github.com/arduino-libraries/Ethernet
// #include <Ethernet3.h> // for Ethernet3 library https://github.com/sstaub/Ethernet3
// #include <EthernetUdp3.h>
#include "gma3.h"

#define BTN_KEY 2
#define ENC_1_A 3
#define ENC_1_B 4
#define BTN_CMD 5
#define FADER A0
// I/O config
#define BTN_KEY_1 2
#define BTN_KEY_2 3
#define BTN_KEY_3 4
#define BTN_KEY_4 5
#define ENC_1_A 6
#define ENC_1_B 7
#define ENC_2_A 8
#define ENC_2_B 9
#define BTN_CMD 10
#define FADER A0

// network data
uint8_t mac[] = {0x90, 0xA2, 0xDA, 0x10, 0x14, 0x48};
#define GMA3_UDP_PORT 8000 // UDP Port configured in gma3
#define GMA3_TCP_PORT 9000 // UDP Port configured in gma3
// Network config
#define GMA3_UDP_PORT 8000 // UDP Port configured in gma3
#define GMA3_TCP_PORT 9000 // UDP Port configured in gma3

IPAddress localIP(10, 101, 1, 201); // IP address of the microcontroller board
IPAddress subnet(255, 255, 0, 0); // subnet range
uint8_t mac[] = {0x90, 0xA2, 0xDA, 0x10, 0x14, 0x48};
IPAddress localIp(10, 101, 1, 201); // IP address of the microcontroller board
IPAddress subnet(255, 255, 0, 0); // optional subnet range
IPAddress dns(10, 101, 1, 100); // optional DNS address of your device
IPAddress gateway(10, 101, 1, 100); // optional Gateway address of your device
uint16_t localUdpPort = GMA3_UDP_PORT;
IPAddress gma3IP(10, 101, 1, 100); // IP address of the gma3 console
uint16_t gma3UdpPort = GMA3_UDP_PORT;
uint16_t gma3TcpPort = GMA3_TCP_PORT;

EthernetUDP udp;
EthernetUDP udpQLab;
EthernetClient tcp;
EthernetClient tcpQLab;
// EthernetUDP udp; // for UDP
EthernetClient tcp; // for TCP

// functions prototypes
void parse();

// hardware definitions
Key key101(BTN_KEY_1, 101);
Fader fader201(FADER, 201);
Key key201(BTN_KEY, 201, TCP);
Key key201(BTN_KEY_2, 201);
Key key301(BTN_KEY_3, 301);
ExecutorKnob enc301(ENC_1_A, ENC_1_B, 301);
CmdButton macro1(BTN_CMD, "GO+ Macro 1", TCP);

// use of generic OSC button
#define QLAB_GO_PIN 6
IPAddress qlabIP(10, 101, 1, 100); // IP of QLab
uint16_t qlabPort = 53000; // QLab receive port
OscButton qlabGo(QLAB_GO_PIN , "/go", TCPSLIP);
Key key401(BTN_KEY_4, 401);
ExecutorKnob enc401(ENC_2_A, ENC_2_B, 301);
CmdButton macro1(BTN_CMD, "GO+ Macro 1");
Parser parser(parse);

void setup() {
Serial.begin(9600);
/* for USR-ES1 module
Ethernet.setRstPin(9);
Ethernet.hardreset();
*/
Ethernet.begin(mac, localIP, subnet);
interfaceGMA3(gma3IP);
interfaceUDP(udp, gma3UdpPort);
interfaceTCP(tcp, gma3TcpPort);
interfaceExternUDP(udpQLab, qlabIP, qlabPort);
interfaceExternTCP(tcpQLab, qlabIP, qlabPort);
Ethernet.begin(mac, localIp);
//interface(udp, gma3IP, gma3UdpPort); // for UDP
interface(tcp, TCP, gma3IP, gma3TcpPort); // for TCP
}

void loop() {
key101.update();
key201.update();
key301.update();
key401.update();
fader201.update();
enc301.update();
enc401.update();
macro1.update();
qlabGo.update();
if (receiveUDP()) {
Serial.print("OSC Pattern: ");
Serial.print(patternOSC());
Serial.print(" String: ");
Serial.print(stringOSC());
Serial.print(" Integer 1: ");
Serial.print(int1OSC());
Serial.print(" Integer 2: ");
Serial.print(int2OSC());
Serial.print(" Float: ");
Serial.println(floatOSC());
}
parser.update();
}

void parse() {
Serial.print("OSC Message at ");
Serial.print(millis());
Serial.print("ms Pattern: ");
Serial.print(parser.patternOSC());
Serial.print(" String: ");
Serial.print(parser.stringOSC());
Serial.print(" Integer 1: ");
Serial.print(parser.int1OSC());
Serial.print(" Integer 2: ");
Serial.print(parser.int2OSC());
Serial.print(" Float: ");
Serial.println(parser.floatOSC());
}
16 changes: 0 additions & 16 deletions examples/gma3_Arduino_PIO/platformio.ini

This file was deleted.

118 changes: 0 additions & 118 deletions examples/gma3_Arduino_PIO/src/main.cpp

This file was deleted.

70 changes: 21 additions & 49 deletions examples/gma3_Fetch/gma3_Fetch.ino
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// simple example for paging and fetching

#include "Arduino.h"
#include "Ethernet3.h"
#include "Ethernet.h"
#include "gma3.h"

// constants and macros
// I/O config
#define BTN_1 2
#define BTN_2 3
#define FADER_1 A0
Expand All @@ -16,71 +15,44 @@
uint8_t mac[] = {0x90, 0xA2, 0xDA, 0x10, 0x14, 0x48};
IPAddress localIP(10, 101, 1, 201); // IP address of the microcontroller board
IPAddress subnet(255, 255, 0, 0); // subnet range
IPAddress dns(10, 101, 1, 100); // DNS address of your device
IPAddress gateway(10, 101, 1, 100); // Gateway address of your device
uint16_t localUdpPort = GMA3_UDP_PORT;
IPAddress gma3IP(10, 101, 1, 100); // IP address of the gma3 console
uint16_t gma3UdpPort = GMA3_UDP_PORT;
uint16_t gma3TcpPort = GMA3_TCP_PORT;

EthernetUDP udp;
EthernetUDP udpQLab;
EthernetClient tcp;
EthernetClient tcpQLab;

#define PAGES 4
int pageNumber = 1;
int16_t value[PAGES];
int16_t value[PAGES + 1] = {0};
void pageChange();

Fader fader201(FADER_1, 201);

void upButton() {
if (fader201.lock() == false)
value[pageNumber] = fader201.value(); // stores value if the fader is not locked
if (pageNumber >= PAGES) pageNumber = 1; // rollover to last page
else pageNumber++;
char cmd[12] = "Page ";
strcat(cmd, itoa(pageNumber));
command(cmd);
page(pageNumber);
if (value[pageNumber] != fader201.value())
fader201.fetch(value[pageNumber]); // force to value of the new page
else fader201.lock(false); // no lock needed because stored and fader value are equal
Serial.print("Page ");
Serial.println(pageNumber);
}

void downButton() {
if (fader201.lock() == false)
value[pageNumber] = fader201.value(); // stores value if the fader is not locked
if (pageNumber <= 1) pageNumber = PAGES; // rollover to first page
else pageNumber--;
char cmd[12] = "Page ";
strcat(cmd, itoa(pageNumber));
command(cmd);
page(pageNumber);
if (value[pageNumber] != fader201.value())
fader201.fetch(value[pageNumber]); // force to value of the new page
else fader201.lock(false); // no lock needed because stored and fader value are equal
Serial.print("Page ");
Serial.println(pageNumber);
}

// add Up / Down keys
Button pageUp(BTN_1, upButton);
Button pageDown(BTN_2, downButton);
Pages pages(BTN_1, BTN_2, 1, 4, GLOBAL, pageChange); // using 4 pages starting with page 1

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
Ethernet.begin(mac, localIP, subnet);
interfaceGMA3(gma3IP);
interfaceUDP(udp, gma3UdpPort);
interfaceTCP(tcp, gma3TcpPort);
Ethernet.begin(mac, localIP);
interface(tcp, TCP, gma3IP, gma3TcpPort); // init inteface for TCP
//interface(udp, gma3IP, gma3UdpPort); // init interface for UDP
fader201.jitter(2);
fader201.fetch(0); // force fader to 0
}

void loop() {
fader201.update();
pageUp.update();
pageDown.update();
pages.update();
digitalWrite(LED_BUILTIN, fader201.lock()); // shows if fader is locked
}

void pageChange() {
if(fader201.lock() == false) value[pages.lastPage()] = fader201.value(); // if not locked store the value for the last page
if(fader201.value() != value[pages.currentPage()]) { // if the fader value is not the expected value then fetch to current value
fader201.fetch(value[pages.currentPage()]);
}
Serial.print("Page changed to page ");
Serial.println(pages.currentPage());
}
Loading

0 comments on commit ea734e0

Please sign in to comment.