Deep sleep for OBP60 and small fix for BMP180

This commit is contained in:
Thomas Hooge 2025-01-23 19:49:44 +01:00
parent a42d31ff49
commit 1ff0de5d24
5 changed files with 69 additions and 3 deletions

View File

@ -70,6 +70,9 @@ bool statusBacklightLED = false;// Actual status of flash LED on/off
int uvDuration = 0; // Under voltage duration in n x 100ms
RTC_DATA_ATTR uint8_t RTC_lastpage; // Remember last page while deep sleeping
LedTaskData *ledTaskData=nullptr;
void hardwareInit(GwApi *api)
@ -118,6 +121,35 @@ void startLedTask(GwApi *api){
createSpiLedTask(ledTaskData);
}
uint8_t getLastPage() {
return RTC_lastpage;
}
#ifdef BOARD_OBP60S3
void deepSleep(CommonData &common){
RTC_lastpage = common.data.actpage - 1;
// Switch off all power lines
setPortPin(OBP_BACKLIGHT_LED, false); // Backlight Off
setFlashLED(false); // Flash LED Off
buzzer(TONE4, 20); // Buzzer tone 4kHz 20ms
// Shutdown EInk display
getdisplay().setFullWindow(); // Set full Refresh
getdisplay().fillScreen(common.bgcolor); // Clear screen
getdisplay().setTextColor(common.fgcolor);
getdisplay().setFont(&Ubuntu_Bold20pt7b);
getdisplay().setCursor(85, 150);
getdisplay().print("Sleep Mode");
getdisplay().setFont(&Ubuntu_Bold8pt7b);
getdisplay().setCursor(65, 175);
getdisplay().print("For wakeup press key and wait 5s");
getdisplay().nextPage(); // Update display contents
getdisplay().powerOff(); // Display power off
setPortPin(OBP_POWER_50, false); // Power off ePaper display
// Stop system
esp_deep_sleep_start(); // Deep Sleep with weakup via GPIO pin
}
#endif
// Valid colors see hue
Color colorMapping(const String &colorString){
Color color = COLOR_RED;

View File

@ -64,6 +64,12 @@ Point rotatePoint(const Point& origin, const Point& p, double angle);
std::vector<Point> rotatePoints(const Point& origin, const std::vector<Point>& pts, double angle);
void fillPoly4(const std::vector<Point>& p4, uint16_t color);
#ifdef BOARD_OBP60S3
void deepSleep(CommonData &common);
#endif
uint8_t getLastPage();
void hardwareInit(GwApi *api);
void setPortPin(uint pin, bool value); // Set port pin for extension port

View File

@ -48,7 +48,7 @@ class PageBME280 : public Page
value1 = 23.0 + float(random(0, 10)) / 10.0;
}
// Display data when sensor activated
if((String(useenvsensor) == "BME280") or (String(useenvsensor) == "BMP280")){
if((useenvsensor == "BME280") or (useenvsensor == "BMP280") or (useenvsensor == "BMP180")){
svalue1 = String(value1, 1); // Formatted value as string including unit conversion and switching decimal places
}
else{
@ -66,7 +66,7 @@ class PageBME280 : public Page
value2 = 43 + float(random(0, 4));
}
// Display data when sensor activated
if(String(useenvsensor) == "BME280"){
if(useenvsensor == "BME280"){
svalue2 = String(value2, 0); // Formatted value as string including unit conversion and switching decimal places
}
else{
@ -84,7 +84,7 @@ class PageBME280 : public Page
value3 = 1006 + float(random(0, 5));
}
// Display data when sensor activated
if((String(useenvsensor) == "BME280") or (String(useenvsensor) == "BMP280")){
if((useenvsensor == "BME280") or (useenvsensor == "BMP280") or (useenvsensor == "BMP180")){
svalue3 = String(value3 / 100, 1); // Formatted value as string including unit conversion and switching decimal places
}
else{

View File

@ -74,6 +74,10 @@ public:
if (key == 4) {
ESP.restart();
}
// standby / deep sleep
if (key == 5) {
deepSleep(*commonData);
}
// Code for keylock
if (key == 11) {
commonData->keylock = !commonData->keylock;

View File

@ -117,6 +117,16 @@ void OBP60Init(GwApi *api){
}
#endif
#ifdef BOARD_OBP60S3
touchSleepWakeUpEnable(TP1, 45);
touchSleepWakeUpEnable(TP2, 45);
touchSleepWakeUpEnable(TP3, 45);
touchSleepWakeUpEnable(TP4, 45);
touchSleepWakeUpEnable(TP5, 45);
touchSleepWakeUpEnable(TP6, 45);
esp_sleep_enable_touchpad_wakeup();
#endif
// Get CPU speed
int freq = getCpuFrequencyMhz();
api->getLogger()->logDebug(GwLog::LOG,"CPU speed at boot: %i MHz", freq);
@ -356,6 +366,8 @@ void deepSleep(CommonData &common){
}
#endif
// OBP60 Task
//####################################################################################
void OBP60Task(GwApi *api){
@ -440,6 +452,18 @@ void OBP60Task(GwApi *api){
PageStruct pages[MAX_PAGE_NUMBER];
// Set start page
int pageNumber = int(api->getConfig()->getConfigItem(api->getConfig()->startPage,true)->asInt()) - 1;
#ifdef BOARD_OBP60S3
LOG_DEBUG(GwLog::LOG,"Checking wakeup...");
if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_TOUCHPAD) {
LOG_DEBUG(GwLog::LOG,"Wake up by touch pad %d",esp_sleep_get_touchpad_wakeup_status());
pageNumber = getLastPage();
} else {
LOG_DEBUG(GwLog::LOG,"Other wakeup reason");
}
LOG_DEBUG(GwLog::LOG,"...done");
#endif
int lastPage=pageNumber;
BoatValueList boatValues; //all the boat values for the api query