Skip to content

Commit

Permalink
more accurated wakeup
Browse files Browse the repository at this point in the history
  • Loading branch information
lunokjod committed Jun 22, 2023
1 parent 8f91890 commit 0f68d24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/system/SystemEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,16 @@ static void BMAEventDirection(void *handler_args, esp_event_base_t base, int32_t
ttgo->power->setPowerOutPut(AXP202_EXTEN, false);
ttgo->power->setPowerOutPut(AXP202_DCDC2, false);

// wake with movement
ttgo->bma->enableFeature(BMA423_TILT, true);
ttgo->bma->enableFeature(BMA423_ANY_MOTION, true);
ttgo->bma->enableFeature(BMA423_ACTIVITY, true);
ttgo->bma->enableFeature(BMA423_WAKEUP, true);
ttgo->bma->enableActivityInterrupt();
// wake with button
ttgo->power->enableIRQ(AXP202_PEK_SHORTPRESS_IRQ | AXP202_PEK_LONGPRESS_IRQ, true);
ttgo->power->clearIRQ();

// dont set timer timeout
//esp_err_t wakeTimer = esp_sleep_enable_timer_wakeup(uS_TO_S_FACTOR * newTime); // periodical wakeup to take samples
//if ( ESP_OK != wakeTimer ) { lSysLog("ERROR: Unable to set timer wakeup in %u seconds\n",newTime); }
Expand All @@ -591,6 +601,7 @@ static void BMAEventDirection(void *handler_args, esp_event_base_t base, int32_t
// the only good ones :(
esp_err_t wakeBMA = esp_sleep_enable_ext1_wakeup( GPIO_SEL_39, ESP_EXT1_WAKEUP_ANY_HIGH);
if ( ESP_OK != wakeBMA ) { lSysLog("ERROR: Unable to set ext1 (BMA) wakeup\n"); }

lSysLog("Device in deep sleep NOW!\n");
esp_deep_sleep_start();
}
Expand Down
2 changes: 1 addition & 1 deletion tool/.buildCount.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
26381
26384

0 comments on commit 0f68d24

Please sign in to comment.