Leonardo EEPROM + linguist-vendored fix

This commit is contained in:
CrazyRedMachine
2020-07-04 14:07:47 +02:00
parent cd398a3468
commit 73e8160f2d
4 changed files with 16 additions and 3 deletions
+1 -1
View File
@@ -1 +1 @@
ModeSwitch/* linguist-vendored=false
ModeSwitch/* linguist-vendored=true
+3 -1
View File
@@ -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
+1 -1
View File
@@ -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);
}
}
+11
View File
@@ -3,6 +3,8 @@
#if defined(ARDUINO_ARCH_SAM)
#include <Keypad.h>
#include <Keyboard.h>
#else
#include <EEPROM.h>
#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;