|
|
@@ -4,45 +4,61 @@ |
|
|
USBHost usb; |
|
|
MonomeController monome(usb); |
|
|
|
|
|
#if (USB_VID==0x2341 && defined(ARDUINO_SAMD_ZERO)) || (USB_VID==0x2a03 && defined(ARDUINO_SAM_ZERO)) |
|
|
#define SerialDebug SERIAL_PORT_MONITOR |
|
|
#else |
|
|
#define SerialDebug Serial1 |
|
|
#endif |
|
|
|
|
|
void GridKeyCallback(byte x, byte y, byte z) { |
|
|
Serial.print("grid key: "); |
|
|
Serial.print(x); |
|
|
Serial.print(" , "); |
|
|
Serial.print(y); |
|
|
Serial.print(" , "); |
|
|
Serial.print(z); |
|
|
Serial.print("\r\n"); |
|
|
SerialDebug.print("grid key: "); |
|
|
SerialDebug.print(x); |
|
|
SerialDebug.print(" , "); |
|
|
SerialDebug.print(y); |
|
|
SerialDebug.print(" , "); |
|
|
SerialDebug.print(z); |
|
|
SerialDebug.print("\r\n"); |
|
|
|
|
|
monome.led_clear(); |
|
|
monome.led_set(x, y, 15); |
|
|
monome.refresh(); |
|
|
if (z == 1) { |
|
|
monome.led_set(x, y, 1); |
|
|
monome.refresh(); |
|
|
} |
|
|
} |
|
|
|
|
|
void ConnectCallback(const char * name, byte cols, byte rows) { |
|
|
Serial.print("\r\nmonome device connected; type: "); |
|
|
Serial.print(name); |
|
|
Serial.print(" ; columns: "); |
|
|
Serial.print(cols); |
|
|
Serial.print(" ; rows: "); |
|
|
Serial.print(rows); |
|
|
Serial.print("\r\n"); |
|
|
SerialDebug.print("\r\nmonome device connected; type: "); |
|
|
SerialDebug.print(name); |
|
|
SerialDebug.print(" ; columns: "); |
|
|
SerialDebug.print(cols); |
|
|
SerialDebug.print(" ; rows: "); |
|
|
SerialDebug.print(rows); |
|
|
SerialDebug.print("\r\n"); |
|
|
|
|
|
monome.led_set(1, 1, 15); |
|
|
monome.led_set(1, 3, 10); |
|
|
monome.led_set(1, 5, 5); |
|
|
|
|
|
monome.refresh(); |
|
|
} |
|
|
|
|
|
void setup() { |
|
|
SerialDebug.begin(9600); |
|
|
|
|
|
void setup() { |
|
|
SerialDebug.print("\n\nStarting...\n"); |
|
|
delay(200); |
|
|
|
|
|
// set connection callback |
|
|
monome.SetConnectCallback(&ConnectCallback); |
|
|
// set key event callback |
|
|
monome.SetGridKeyCallback(&GridKeyCallback); |
|
|
SerialDebug.print("\n\nConnect set...\n"); |
|
|
|
|
|
Serial.begin(115200); |
|
|
Serial.print("\n\nStarting...\n"); |
|
|
delay(200); |
|
|
|
|
|
} |
|
|
|
|
|
void loop() { |
|
|
void loop() { |
|
|
usb.Task(); |
|
|
/// alternatively, refresh on every tick: |
|
|
// monome.refresh(); |
|
|
// monome.refresh(); |
|
|
} |