Compare commits
	
		
			No commits in common. "46af8916e7ebd2e1a1b3ac4fb465ec70338d990c" and "988e7ccbc78da4934b8de82c83ac3899629f8ba0" have entirely different histories.
		
	
	
		
			46af8916e7
			...
			988e7ccbc7
		
	
		|  | @ -70,9 +70,6 @@ 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) | ||||||
|  | @ -121,35 +118,6 @@ 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,12 +64,6 @@ 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((useenvsensor == "BME280") or (useenvsensor == "BMP280") or (useenvsensor == "BMP180")){ |         if((String(useenvsensor) == "BME280") or (String(useenvsensor) == "BMP280")){ | ||||||
|             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(useenvsensor == "BME280"){ |         if(String(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((useenvsensor == "BME280") or (useenvsensor == "BMP280") or (useenvsensor == "BMP180")){ |         if((String(useenvsensor) == "BME280") or (String(useenvsensor) == "BMP280")){ | ||||||
|             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 = "RST"; |         commonData->keydata[3].label = ""; | ||||||
|         commonData->keydata[4].label = "STBY"; |         commonData->keydata[4].label = "STBY"; | ||||||
|         commonData->keydata[5].label = "ILUM"; |         commonData->keydata[5].label = "ILUM"; | ||||||
|     } |     } | ||||||
|  | @ -67,19 +67,9 @@ public: | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // grab cursor keys to disable page navigation
 |         // grab cursor keys to disable page navigation
 | ||||||
|         if (key == 3) { |         if (key == 3 or key == 4) { | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         // soft reset
 |  | ||||||
|         if (key == 4) { |  | ||||||
|             ESP.restart(); |  | ||||||
|         } |  | ||||||
| #ifdef BOARD_OBP60S3 |  | ||||||
|         // standby / deep sleep
 |  | ||||||
|         if (key == 5) { |  | ||||||
|            deepSleep(*commonData); |  | ||||||
|         } |  | ||||||
| #endif |  | ||||||
|         // Code for keylock
 |         // Code for keylock
 | ||||||
|         if (key == 11) { |         if (key == 11) { | ||||||
|             commonData->keylock = !commonData->keylock; |             commonData->keylock = !commonData->keylock; | ||||||
|  | @ -143,25 +133,11 @@ 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); | ||||||
|  | @ -170,6 +146,11 @@ 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); | ||||||
|  | @ -180,11 +161,6 @@ 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); | ||||||
|  |  | ||||||
|  | @ -13,7 +13,6 @@ public: | ||||||
|     PageWhite(CommonData &common){ |     PageWhite(CommonData &common){ | ||||||
|         commonData = &common; |         commonData = &common; | ||||||
|         common.logger->logDebug(GwLog::LOG,"Instantiate PageWhite"); |         common.logger->logDebug(GwLog::LOG,"Instantiate PageWhite"); | ||||||
|         refreshtime = 15000; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     virtual int handleKey(int key) { |     virtual int handleKey(int key) { | ||||||
|  | @ -54,11 +53,7 @@ public: | ||||||
|         int bgcolor = GxEPD_WHITE; |         int bgcolor = GxEPD_WHITE; | ||||||
| 
 | 
 | ||||||
|         // Set display in partial refresh mode
 |         // Set display in partial refresh mode
 | ||||||
|         if (mode == 'W') { |         getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
 | ||||||
|             getdisplay().setFullWindow(); |  | ||||||
|         } else { |  | ||||||
|             getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update
 |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         if (mode == 'L') { |         if (mode == 'L') { | ||||||
|             getdisplay().drawBitmap(0, 0, gImage_Logo_OBP_400x300_sw, getdisplay().width(), getdisplay().height(), commonData->fgcolor); |             getdisplay().drawBitmap(0, 0, gImage_Logo_OBP_400x300_sw, getdisplay().width(), getdisplay().height(), commonData->fgcolor); | ||||||
|  | @ -67,10 +62,7 @@ public: | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Update display
 |         // Update display
 | ||||||
|         getdisplay().nextPage(); |         getdisplay().nextPage();    // Partial update (fast)
 | ||||||
|         if (mode == 'W') { |  | ||||||
|             getdisplay().hibernate(); |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|     }; |     }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -100,7 +100,6 @@ class Page{ | ||||||
|   protected: |   protected: | ||||||
|     CommonData *commonData; |     CommonData *commonData; | ||||||
|   public: |   public: | ||||||
|     int refreshtime = 1000; |  | ||||||
|     virtual void displayPage(PageData &pageData)=0; |     virtual void displayPage(PageData &pageData)=0; | ||||||
|     virtual void displayNew(PageData &pageData){} |     virtual void displayNew(PageData &pageData){} | ||||||
|     virtual void setupKeys() { |     virtual void setupKeys() { | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ | ||||||
| #include <NMEA0183.h>                   // NMEA0183
 | #include <NMEA0183.h>                   // NMEA0183
 | ||||||
| #include <NMEA0183Msg.h> | #include <NMEA0183Msg.h> | ||||||
| #include <NMEA0183Messages.h> | #include <NMEA0183Messages.h> | ||||||
| #include <GxEPD2_BW.h>                  // GxEPD2 lib for b/w E-Ink displays
 | #include <GxEPD2_BW.h>                  // GxEPD2 lib for black 6 white E-Ink displays
 | ||||||
| #include "OBP60Extensions.h"            // Functions lib for extension board
 | #include "OBP60Extensions.h"            // Functions lib for extension board
 | ||||||
| #include "OBP60Keypad.h"                // Functions for keypad
 | #include "OBP60Keypad.h"                // Functions for keypad
 | ||||||
| 
 | 
 | ||||||
|  | @ -117,16 +117,6 @@ 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); | ||||||
|  | @ -366,8 +356,6 @@ void deepSleep(CommonData &common){ | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| // OBP60 Task
 | // OBP60 Task
 | ||||||
| //####################################################################################
 | //####################################################################################
 | ||||||
| void OBP60Task(GwApi *api){ | void OBP60Task(GwApi *api){ | ||||||
|  | @ -452,18 +440,6 @@ 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
 | ||||||
|  | @ -574,10 +550,8 @@ void OBP60Task(GwApi *api){ | ||||||
|     //####################################################################################
 |     //####################################################################################
 | ||||||
| 
 | 
 | ||||||
|     bool systemPage = false; |     bool systemPage = false; | ||||||
|     Page *currentPage; |  | ||||||
|     while (true){ |     while (true){ | ||||||
|         delay(100);     // Delay 100ms (loop time)
 |         delay(100);     // Delay 100ms (loop time)
 | ||||||
|         bool keypressed = false; |  | ||||||
| 
 | 
 | ||||||
|         // Undervoltage detection
 |         // Undervoltage detection
 | ||||||
|         if(uvoltage == true){ |         if(uvoltage == true){ | ||||||
|  | @ -619,8 +593,8 @@ void OBP60Task(GwApi *api){ | ||||||
|             int keyboardMessage=0; |             int keyboardMessage=0; | ||||||
|             while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){ |             while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){ | ||||||
|                 LOG_DEBUG(GwLog::LOG,"new key from keyboard %d",keyboardMessage); |                 LOG_DEBUG(GwLog::LOG,"new key from keyboard %d",keyboardMessage); | ||||||
|                 keypressed = true; |  | ||||||
| 
 | 
 | ||||||
|  |                 Page *currentPage; | ||||||
|                 if (keyboardMessage == 12) { |                 if (keyboardMessage == 12) { | ||||||
|                     LOG_DEBUG(GwLog::LOG, "Calling system page"); |                     LOG_DEBUG(GwLog::LOG, "Calling system page"); | ||||||
|                     systemPage = true; // System page is out of band
 |                     systemPage = true; // System page is out of band
 | ||||||
|  | @ -751,17 +725,9 @@ void OBP60Task(GwApi *api){ | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|              |              | ||||||
|             // Refresh display data, default all 1s
 |             // Refresh display data all 1s
 | ||||||
|             currentPage = pages[pageNumber].page; |             if(millis() > starttime3 + 1000){ | ||||||
|             int pagetime = 1000; |  | ||||||
|             if ((lastPage == pageNumber) and (!keypressed)) { |  | ||||||
|                 // same page we use page defined time
 |  | ||||||
|                 pagetime = currentPage->refreshtime; |  | ||||||
|             } |  | ||||||
|             if(millis() > starttime3 + pagetime){ |  | ||||||
|                 LOG_DEBUG(GwLog::DEBUG,"Page with refreshtime=%d", pagetime); |  | ||||||
|                 starttime3 = millis(); |                 starttime3 = millis(); | ||||||
| 
 |  | ||||||
|                 //refresh data from api
 |                 //refresh data from api
 | ||||||
|                 api->getBoatDataValues(boatValues.numValues,boatValues.allBoatValues); |                 api->getBoatDataValues(boatValues.numValues,boatValues.allBoatValues); | ||||||
|                 api->getStatus(commonData.status); |                 api->getStatus(commonData.status); | ||||||
|  | @ -783,6 +749,7 @@ void OBP60Task(GwApi *api){ | ||||||
|                     syspage->displayPage(sysparams); |                     syspage->displayPage(sysparams); | ||||||
|                 } |                 } | ||||||
|                 else { |                 else { | ||||||
|  |                     Page *currentPage = pages[pageNumber].page; | ||||||
|                     if (currentPage == NULL){ |                     if (currentPage == NULL){ | ||||||
|                         LOG_DEBUG(GwLog::ERROR,"page number %d not found", pageNumber); |                         LOG_DEBUG(GwLog::ERROR,"page number %d not found", pageNumber); | ||||||
|                         // Error handling for missing page
 |                         // Error handling for missing page
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue