From 832f84d0bedba337e5949560520fcbd058623f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Farkas=20Szil=C3=A1rd?= Date: Sat, 4 Jul 2020 16:04:05 +0200 Subject: [PATCH] Ability to enable or disable pages on the u8g2 OLED display --- main/config.h | 2 ++ main/disp.cpp | 51 +++++++++++++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/main/config.h b/main/config.h index b1c1029..51d9d4b 100644 --- a/main/config.h +++ b/main/config.h @@ -21,6 +21,8 @@ // #define WITH_OLED2 // 2nd OLED display, I2C address next higher #define WITH_U8G2_OLED // I2C OLED through the U8g2 library // #define WITH_U8G2_SH1106 +#define U8G2_OLED_PAGES_ENABLED 0b0001111111 // use if WITH_U8G2_OLED is on, 10 pages currently, see end of disp.ccp for the list of pages + #define WITH_RFM95 // RF chip selection: both HELTEC and TTGO use sx1276 which is same as RFM95 diff --git a/main/disp.cpp b/main/disp.cpp index e177bbb..77f6a25 100644 --- a/main/disp.cpp +++ b/main/disp.cpp @@ -25,12 +25,8 @@ #include "disp_lcd.h" #ifdef WITH_U8G2_OLED -#ifdef WITH_U8G2_LISTS -const uint8_t DISP_Pages = 7+3; -#else -const uint8_t DISP_Pages = 7; -#endif -static uint8_t DISP_Page = 1; +const uint8_t DISP_Pages = 10; +static uint8_t DISP_Page = 0; #endif #if defined(WITH_ST7789) || defined(WITH_ILI9341) const uint8_t DISP_Pages = 9; @@ -45,7 +41,7 @@ void vTaskDISP(void* pvParameters) u8g2_ClearBuffer(&U8G2_OLED); OLED_DrawLogo(&U8G2_OLED); // draw logo u8g2_SendBuffer(&U8G2_OLED); - vTaskDelay(5000); // allow 5sec for the user to see the logo + vTaskDelay(2000); // allow 2sec for the user to see the logo #endif #if defined(WITH_ST7789) || defined(WITH_ILI9341) // LCD_Start(); @@ -169,24 +165,31 @@ void vTaskDISP(void* pvParameters) // { OLED_DrawTrafWarn(&U8G2_OLED, GPS); } // else // #endif - { switch(DISP_Page) - { case 2: OLED_DrawGPS (&U8G2_OLED, GPS); break; - case 3: OLED_DrawRF (&U8G2_OLED, GPS); break; - case 4: OLED_DrawBaro (&U8G2_OLED, GPS); break; - case 1: OLED_DrawID (&U8G2_OLED, GPS); break; - case 5: OLED_DrawSystem(&U8G2_OLED, GPS); break; - // case 6: OLED_DrawRelay (&U8G2_OLED, GPS); break; - // case 7: OLED_DrawLookout(&U8G2_OLED, GPS); break; - case 0: OLED_DrawBattery(&U8G2_OLED, GPS); break; - case 6: OLED_DrawAltitudeAndSpeed (&U8G2_OLED, GPS); break; -#ifdef WITH_U8G2_LISTS - case 7: OLED_DrawRelay (&U8G2_OLED, GPS); break; - case 8: OLED_DrawLookout(&U8G2_OLED, GPS); break; - case 9: OLED_DrawTrafWarn(&U8G2_OLED, GPS); break; + // skip not enabled pages + while ( (U8G2_OLED_PAGES_ENABLED & (1 << DISP_Page)) == 0 ) { + DISP_Page++; + if(DISP_Page>=DISP_Pages) DISP_Page=0; + } + +#ifdef DEBUG_PRINT + xSemaphoreTake(CONS_Mutex, portMAX_DELAY); + Format_String(CONS_UART_Write, "DISP_Page: "); + Format_Hex(CONS_UART_Write, DISP_Page); + Format_String(CONS_UART_Write, "\n"); + xSemaphoreGive(CONS_Mutex); #endif - // default: - // { OLED_DrawStatus(&U8G2_OLED, Time, 0); - // OLED_DrawPosition(&U8G2_OLED, GPS, 2); } + + { switch(DISP_Page) + { case 0: OLED_DrawID (&U8G2_OLED, GPS); break; + case 1: OLED_DrawGPS (&U8G2_OLED, GPS); break; + case 2: OLED_DrawRF (&U8G2_OLED, GPS); break; + case 3: OLED_DrawBaro (&U8G2_OLED, GPS); break; + case 4: OLED_DrawSystem (&U8G2_OLED, GPS); break; + case 5: OLED_DrawBattery (&U8G2_OLED, GPS); break; + case 6: OLED_DrawAltitudeAndSpeed (&U8G2_OLED, GPS); break; + case 7: OLED_DrawRelay (&U8G2_OLED, GPS); break; + case 8: OLED_DrawLookout (&U8G2_OLED, GPS); break; + case 9: OLED_DrawTrafWarn (&U8G2_OLED, GPS); break; } } //if ( DISP_Page != 6 )