Skip to content

Commit bd451ea

Browse files
committed
eeprom_is_ready
1 parent 580b67c commit bd451ea

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Diff for: primer.ino

+8-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
#define ADDR_SLEEPING 1023
3333

3434
#define PRESS_DELAY 100
35-
/* #define SHORT_HOLD 1000 */
36-
/* #define LONG_HOLD 2000 */
37-
/* #define VERY_LONG_HOLD 6000 */
3835
#define SHORT_HOLD 500
3936
#define LONG_HOLD 1000
4037
#define VERY_LONG_HOLD 3000
@@ -256,6 +253,7 @@ void setup() {
256253
attachInterrupt(0, pushInterrupt, FALLING);
257254

258255
if (EEPROM.read(ADDR_SLEEPING)) {
256+
while (!eeprom_is_ready());
259257
EEPROM.update(ADDR_SLEEPING, 0);
260258
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_ON);
261259
button_state = new_state = S_SLEEP_WAKE;
@@ -474,6 +472,7 @@ void handlePress(bool pressed) {
474472
flash(128, 128, 128, 5);
475473
new_state = S_PLAY_SLEEP_WAIT;
476474
} else if (!pressed) {
475+
while (!eeprom_is_ready());
477476
EEPROM.update(ADDR_LOCKED, 1);
478477
enterSleep();
479478
}
@@ -651,6 +650,7 @@ void handlePress(bool pressed) {
651650
new_state = S_BUNDLE_EDIT_WAIT;
652651
} else if (!pressed) {
653652
flash(128, 128, 128, 5);
653+
while (!eeprom_is_ready());
654654
EEPROM.update(ADDR_CUR_BUNDLE, cur_bundle);
655655
new_state = S_PLAY_OFF;
656656
}
@@ -713,6 +713,7 @@ void handlePress(bool pressed) {
713713
if (since_trans == VERY_LONG_HOLD) flash(0, 128, 0, 5);
714714
if (!pressed) {
715715
if (since_trans > VERY_LONG_HOLD) {
716+
while (!eeprom_is_ready());
716717
EEPROM.update(ADDR_LOCKED, 0);
717718
new_state = S_PLAY_OFF;
718719
} else {
@@ -784,6 +785,7 @@ void handlePress(bool pressed) {
784785
flash(128, 128, 128, 1);
785786
flash(0, 128, 0, 1);
786787
flash(128, 128, 128, 1);
788+
while (!eeprom_is_ready());
787789
saveMode(cur_mode_idx);
788790
new_state = S_PLAY_OFF;
789791
break;
@@ -794,6 +796,7 @@ void handlePress(bool pressed) {
794796
flash(128, 128, 128, 1);
795797
flash(0, 0, 128, 1);
796798
flash(128, 128, 128, 1);
799+
while (!eeprom_is_ready());
797800
saveBundles();
798801
new_state = S_PLAY_OFF;
799802
break;
@@ -826,6 +829,7 @@ void handlePress(bool pressed) {
826829
void enterSleep() {
827830
writeFrame(0, 0, 0);
828831
accelStandby();
832+
while (!eeprom_is_ready());
829833
EEPROM.update(ADDR_SLEEPING, 1);
830834
digitalWrite(PIN_LDO, LOW);
831835
delay(64000);
@@ -896,6 +900,7 @@ void loadBundles() {
896900
}
897901

898902
void resetMemory() {
903+
while (!eeprom_is_ready());
899904
clearMemory();
900905
initModes();
901906
saveModes();

Diff for: tekton/tekton.pde

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ void readResp() {
132132
int target = port.read();
133133
int addr = port.read();
134134
int val = port.read();
135-
136135
/* println("in << " + target + " " + addr + " " + val); */
137136

138137
if (target == 100) { // Ack from light

0 commit comments

Comments
 (0)