update main app handling to include an off state

Signed-off-by: Thomas Schmid <tom@binary-kitchen.de>
This commit is contained in:
Thomas 2022-06-26 00:24:44 +02:00
parent 02aea42207
commit 9f3c929fcd
1 changed files with 52 additions and 5 deletions

View File

@ -22,25 +22,72 @@ std::vector<std::reference_wrapper<App>> apps = {
std::ref<App>(fackel_app) std::ref<App>(fackel_app)
}; };
<<<<<<< HEAD
unsigned int current_app = 1; unsigned int current_app = 1;
unsigned int next_app; unsigned int next_app;
=======
static unsigned int current_app = 0;
static unsigned int next_app;
static bool init_successfull = false;
static bool sleep_active=false;
void switch_app() {
if (!sleep_active) {
next_app = current_app + 1;
} else {
sleep_active = false;
next_app = 0;
}
if (next_app >= apps.size()) {
next_app = 0;
// Turn off leds before going to sleep
fadeToBlackBy(leds, NUM_LEDS, 0xFF);
FastLED.show();
//configure wakeup source
esp_sleep_enable_ext0_wakeup(GPIO_NUM_4, 1);
//bedtime
sleep_active = true;
esp_deep_sleep_start();
}
next_app = next_app % apps.size();
}
>>>>>>> update main app handling to include an off state
void setup() void setup()
{ {
next_app = current_app; next_app = current_app;
<<<<<<< HEAD
zauberstab_init(); zauberstab_init();
//Serial.begin(115200); //Serial.begin(115200);
=======
if (zauberstab_init() != 0) {
return;
}
Serial.begin(115200);
>>>>>>> update main app handling to include an off state
init_successfull = true;
apps[current_app].get().init(); apps[current_app].get().init();
} }
void loop() void loop()
{ {
/* EVERY_N_SECONDS(30) if (!init_successfull) {
{ return;
next_app++; }
next_app = next_app % apps.size();
} */ if (acc_has_event()) {
String axes = myAcc.getActTapStatusAsString();
byte intSource = myAcc.readAndClearInterrupts();
if (myAcc.checkInterrupt(intSource, ADXL345_DOUBLE_TAP)) {
switch_app();
}
}
if (next_app != current_app) if (next_app != current_app)
{ {