Merge pull request #148 from thooge/system
Deep sleep for OBP60 and small fix for BMP180
This commit is contained in:
commit
d6a7323600
|
@ -70,6 +70,9 @@ bool statusBacklightLED = false;// Actual status of flash LED on/off
|
||||||
|
|
||||||
int uvDuration = 0; // Under voltage duration in n x 100ms
|
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;
|
LedTaskData *ledTaskData=nullptr;
|
||||||
|
|
||||||
void hardwareInit(GwApi *api)
|
void hardwareInit(GwApi *api)
|
||||||
|
@ -118,6 +121,35 @@ void startLedTask(GwApi *api){
|
||||||
createSpiLedTask(ledTaskData);
|
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
|
// Valid colors see hue
|
||||||
Color colorMapping(const String &colorString){
|
Color colorMapping(const String &colorString){
|
||||||
Color color = COLOR_RED;
|
Color color = COLOR_RED;
|
||||||
|
|
|
@ -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);
|
std::vector<Point> rotatePoints(const Point& origin, const std::vector<Point>& pts, double angle);
|
||||||
void fillPoly4(const std::vector<Point>& p4, uint16_t color);
|
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 hardwareInit(GwApi *api);
|
||||||
|
|
||||||
void setPortPin(uint pin, bool value); // Set port pin for extension port
|
void setPortPin(uint pin, bool value); // Set port pin for extension port
|
||||||
|
|
|
@ -48,7 +48,7 @@ class PageBME280 : public Page
|
||||||
value1 = 23.0 + float(random(0, 10)) / 10.0;
|
value1 = 23.0 + float(random(0, 10)) / 10.0;
|
||||||
}
|
}
|
||||||
// Display data when sensor activated
|
// 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
|
svalue1 = String(value1, 1); // Formatted value as string including unit conversion and switching decimal places
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -66,7 +66,7 @@ class PageBME280 : public Page
|
||||||
value2 = 43 + float(random(0, 4));
|
value2 = 43 + float(random(0, 4));
|
||||||
}
|
}
|
||||||
// Display data when sensor activated
|
// 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
|
svalue2 = String(value2, 0); // Formatted value as string including unit conversion and switching decimal places
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -84,7 +84,7 @@ class PageBME280 : public Page
|
||||||
value3 = 1006 + float(random(0, 5));
|
value3 = 1006 + float(random(0, 5));
|
||||||
}
|
}
|
||||||
// Display data when sensor activated
|
// 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
|
svalue3 = String(value3 / 100, 1); // Formatted value as string including unit conversion and switching decimal places
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
commonData->keydata[0].label = "EXIT";
|
commonData->keydata[0].label = "EXIT";
|
||||||
commonData->keydata[1].label = "MODE";
|
commonData->keydata[1].label = "MODE";
|
||||||
commonData->keydata[2].label = "";
|
commonData->keydata[2].label = "";
|
||||||
commonData->keydata[3].label = "";
|
commonData->keydata[3].label = "RST";
|
||||||
commonData->keydata[4].label = "STBY";
|
commonData->keydata[4].label = "STBY";
|
||||||
commonData->keydata[5].label = "ILUM";
|
commonData->keydata[5].label = "ILUM";
|
||||||
}
|
}
|
||||||
|
@ -67,9 +67,17 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// grab cursor keys to disable page navigation
|
// grab cursor keys to disable page navigation
|
||||||
if (key == 3 or key == 4) {
|
if (key == 3) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
// soft reset
|
||||||
|
if (key == 4) {
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
// standby / deep sleep
|
||||||
|
if (key == 5) {
|
||||||
|
deepSleep(*commonData);
|
||||||
|
}
|
||||||
// Code for keylock
|
// Code for keylock
|
||||||
if (key == 11) {
|
if (key == 11) {
|
||||||
commonData->keylock = !commonData->keylock;
|
commonData->keylock = !commonData->keylock;
|
||||||
|
@ -133,11 +141,25 @@ public:
|
||||||
getdisplay().setCursor(120, y0 + 16);
|
getdisplay().setCursor(120, y0 + 16);
|
||||||
getdisplay().print(env_module);
|
getdisplay().print(env_module);
|
||||||
|
|
||||||
|
// total RAM free
|
||||||
|
int Heap_free = esp_get_free_heap_size();
|
||||||
|
getdisplay().setCursor(202, y0 + 16);
|
||||||
|
getdisplay().print("Total free:");
|
||||||
|
getdisplay().setCursor(300, y0 + 16);
|
||||||
|
getdisplay().print(String(Heap_free));
|
||||||
|
|
||||||
getdisplay().setCursor(2, y0 + 32);
|
getdisplay().setCursor(2, y0 + 32);
|
||||||
getdisplay().print("Buzzer:");
|
getdisplay().print("Buzzer:");
|
||||||
getdisplay().setCursor(120, y0 + 32);
|
getdisplay().setCursor(120, y0 + 32);
|
||||||
getdisplay().print(buzzer_mode);
|
getdisplay().print(buzzer_mode);
|
||||||
|
|
||||||
|
// RAM free for task
|
||||||
|
int RAM_free = uxTaskGetStackHighWaterMark(NULL);
|
||||||
|
getdisplay().setCursor(202, y0 + 32);
|
||||||
|
getdisplay().print("Task free:");
|
||||||
|
getdisplay().setCursor(300, y0 + 32);
|
||||||
|
getdisplay().print(String(RAM_free));
|
||||||
|
|
||||||
getdisplay().setCursor(2, y0 + 48);
|
getdisplay().setCursor(2, y0 + 48);
|
||||||
getdisplay().print("CPU speed:");
|
getdisplay().print("CPU speed:");
|
||||||
getdisplay().setCursor(120, y0 + 48);
|
getdisplay().setCursor(120, y0 + 48);
|
||||||
|
@ -146,11 +168,6 @@ public:
|
||||||
int cpu_freq = esp_clk_cpu_freq() / 1000000;
|
int cpu_freq = esp_clk_cpu_freq() / 1000000;
|
||||||
getdisplay().print(String(cpu_freq));
|
getdisplay().print(String(cpu_freq));
|
||||||
|
|
||||||
getdisplay().setCursor(2, y0 + 64);
|
|
||||||
getdisplay().print("RTC:");
|
|
||||||
getdisplay().setCursor(120, y0 + 64);
|
|
||||||
getdisplay().print(rtc_module);
|
|
||||||
|
|
||||||
getdisplay().setCursor(202, y0 + 64);
|
getdisplay().setCursor(202, y0 + 64);
|
||||||
getdisplay().print("GPS:");
|
getdisplay().print("GPS:");
|
||||||
getdisplay().setCursor(300, y0 + 64);
|
getdisplay().setCursor(300, y0 + 64);
|
||||||
|
@ -161,6 +178,11 @@ public:
|
||||||
getdisplay().setCursor(120, y0 + 80);
|
getdisplay().setCursor(120, y0 + 80);
|
||||||
getdisplay().print(hasFRAM ? "available" : "not found");
|
getdisplay().print(hasFRAM ? "available" : "not found");
|
||||||
|
|
||||||
|
getdisplay().setCursor(202, y0 + 80);
|
||||||
|
getdisplay().print("RTC:");
|
||||||
|
getdisplay().setCursor(300, y0 + 80);
|
||||||
|
getdisplay().print(rtc_module);
|
||||||
|
|
||||||
getdisplay().setCursor(2, y0 + 120);
|
getdisplay().setCursor(2, y0 + 120);
|
||||||
getdisplay().print("Firmware Version: ");
|
getdisplay().print("Firmware Version: ");
|
||||||
getdisplay().print(VERSINFO);
|
getdisplay().print(VERSINFO);
|
||||||
|
|
|
@ -117,6 +117,16 @@ void OBP60Init(GwApi *api){
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
// Get CPU speed
|
||||||
int freq = getCpuFrequencyMhz();
|
int freq = getCpuFrequencyMhz();
|
||||||
api->getLogger()->logDebug(GwLog::LOG,"CPU speed at boot: %i MHz", freq);
|
api->getLogger()->logDebug(GwLog::LOG,"CPU speed at boot: %i MHz", freq);
|
||||||
|
@ -356,6 +366,8 @@ void deepSleep(CommonData &common){
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// OBP60 Task
|
// OBP60 Task
|
||||||
//####################################################################################
|
//####################################################################################
|
||||||
void OBP60Task(GwApi *api){
|
void OBP60Task(GwApi *api){
|
||||||
|
@ -440,6 +452,18 @@ void OBP60Task(GwApi *api){
|
||||||
PageStruct pages[MAX_PAGE_NUMBER];
|
PageStruct pages[MAX_PAGE_NUMBER];
|
||||||
// Set start page
|
// Set start page
|
||||||
int pageNumber = int(api->getConfig()->getConfigItem(api->getConfig()->startPage,true)->asInt()) - 1;
|
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;
|
int lastPage=pageNumber;
|
||||||
|
|
||||||
BoatValueList boatValues; //all the boat values for the api query
|
BoatValueList boatValues; //all the boat values for the api query
|
||||||
|
|
Loading…
Reference in New Issue