diff --git a/.gitattributes b/.gitattributes index 6f12955..0a0c700 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -ModeSwitch/* linguist-vendored=false +ModeSwitch/* linguist-vendored=true \ No newline at end of file diff --git a/README.md b/README.md index e44977d..63a2266 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ In combination with the PN5180-cardio project, the whole IO from a Pop'n Music c # Leonardo version -Because I loved the ModeSwitch feature, I adapted the code so it could compile for Leonardo as well. Due to lack of gpio, in this case there's only 11 buttons and 9 lights, no keypad support, and reactive mode won't include AC light simulation (there's no side or top lamps, duh) +Because I loved the ModeSwitch feature, I adapted the code so it could compile for Leonardo as well. Due to lack of gpio, in this case there's only 11 buttons and 9 lights, no keypad support, and reactive mode won't include AC light simulation (there's no side or top lamps, duh). + +I'm also taking advantage of the Leonardo EEPROM. On manually switching, the resulting lightmode is stored in the EEPROM so that it persists on controller disconnect/reconnect. # Demo diff --git a/popnWithKeypad/POPNHID.cpp b/popnWithKeypad/POPNHID.cpp index bc83d32..e8c7541 100644 --- a/popnWithKeypad/POPNHID.cpp +++ b/popnWithKeypad/POPNHID.cpp @@ -323,7 +323,7 @@ static const byte PROGMEM _hidReportPOPN[] = { if (*bitfield>>28&1){ uint8_t mode = (*bitfield>>24) & 0x0F; setLightMode(mode); - *bitfield &= ~(0xFF<<24); + *bitfield &= ~((uint32_t)0xFF<<24); } } diff --git a/popnWithKeypad/popnWithKeypad.ino b/popnWithKeypad/popnWithKeypad.ino index a648689..bc4e4e0 100644 --- a/popnWithKeypad/popnWithKeypad.ino +++ b/popnWithKeypad/popnWithKeypad.ino @@ -3,6 +3,8 @@ #if defined(ARDUINO_ARCH_SAM) #include #include +#else +#include #endif #include "POPNHID.h" /* 125µs delay is 1 frame on highspeed USB spec */ @@ -81,6 +83,12 @@ void setup() { delay(500); Keyboard.release(136+83); */ +#else + uint8_t lightMode; + EEPROM.get(0, lightMode); + if (lightMode < 0 || lightMode > 3) + lightMode = 2; + POPNHID.setLightMode(lightMode); #endif //boot animation @@ -178,6 +186,9 @@ void loop() { uint8_t mode = POPNHID.getLightMode()+1; if (mode > 3) mode = 0; POPNHID.setLightMode(mode); +#if defined(ARDUINO_ARCH_AVR) + EEPROM.put(0, mode); +#endif } else if (!(buttonsState&2)) { modeChanged = false;