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 cc8a68f..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 = 6+3; -#else -const uint8_t DISP_Pages = 6; -#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,25 +165,34 @@ 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; -#ifdef WITH_U8G2_LISTS - case 6: OLED_DrawRelay (&U8G2_OLED, GPS); break; - case 7: 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 ) OLED_DrawStatusBar(&U8G2_OLED, GPS); u8g2_SendBuffer(&U8G2_OLED); } diff --git a/main/disp_oled.cpp b/main/disp_oled.cpp index 4d29e2a..b4fed14 100644 --- a/main/disp_oled.cpp +++ b/main/disp_oled.cpp @@ -692,6 +692,95 @@ void OLED_DrawID(u8g2_t *OLED, GPS_Position *GPS) u8g2_DrawStr(OLED, 96, 62, "v0.1.1"); } +void OLED_DrawAltitudeAndSpeed(u8g2_t *OLED, GPS_Position *GPS) +{ uint8_t Len=0; + + // Altitude + if(GPS && GPS->hasBaro) + //Len+=Format_UnsDec(Line+Len, (95634+5)/10, 1, 0); + Len+=Format_UnsDec(Line+Len, (GPS->StdAltitude+5)/10, 1, 0); + else + Len+=Format_String(Line+Len, "----"); + Line[Len]=0; + u8g2_SetFont(OLED, u8g2_font_fub20_tr); + uint8_t Altitude_width = u8g2_GetStrWidth(OLED, Line); + u8g2_DrawStr(OLED, 80-Altitude_width, 40, Line); + + Len=0; + Len+=Format_String(Line+Len, "m"); + Line[Len]=0; + u8g2_SetFont(OLED, u8g2_font_9x15_tr); + u8g2_DrawStr(OLED, 84, 40, Line); + + + // Climb Rate + Len=0; + if(GPS && GPS->hasBaro) { + //int16_t vario_value = 129; + int16_t vario_value = GPS->ClimbRate; + if(vario_value<0) { + vario_value=(-vario_value); + #define minus_width 10 + #define minus_height 17 + static unsigned char minus_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + u8g2_DrawXBM(OLED,0,47,minus_width, minus_height, minus_bits); + } + else { + #define plus_width 10 + #define plus_height 17 + static unsigned char plus_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, + 0x30, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + u8g2_DrawXBM(OLED,0,47,plus_width, plus_height, plus_bits); + } + Len+=Format_UnsDec(Line+Len, vario_value, 2, 1); + } + else + Len+=Format_String(Line+Len, "-.-"); + Line[Len]=0; + u8g2_SetFont(OLED, u8g2_font_fub17_tr); + uint8_t Vario_width = u8g2_GetStrWidth(OLED, Line); + u8g2_DrawStr(OLED, 54-Vario_width, 64, Line); + + #define ms_width 7 + #define ms_height 17 + static unsigned char ms_bits[] = { + 0x00, 0x00, 0x16, 0x2a, 0x2a, 0x2a, 0x2a, 0x00, 0x7f, 0x00, 0x1c, 0x22, + 0x02, 0x1c, 0x20, 0x22, 0x1c }; + + + u8g2_DrawXBM(OLED,58,47,ms_width, ms_height, ms_bits); + + + // Speed + Len=0; + if(GPS) { + uint16_t speed = round(GPS->Speed * 0.36f); // Speed is in 0.1m/s + Len+=Format_UnsDec(Line+Len, speed, 1, 0); + //Len+=Format_UnsDec(Line+Len, 623, 1, 0); + } + else + Len+=Format_String(Line+Len, "-"); + Line[Len]=0; + u8g2_SetFont(OLED, u8g2_font_fub17_tr); + uint8_t Speed_width = u8g2_GetStrWidth(OLED, Line); + u8g2_DrawStr(OLED, 114-Speed_width, 64, Line); + + #define kmh_width 10 + #define kmh_height 17 + static unsigned char kmh_bits[] = { + 0x01, 0x00, 0x01, 0x00, 0x69, 0x01, 0xa5, 0x02, 0xa3, 0x02, 0xa5, 0x02, + 0xa9, 0x02, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, + 0x08, 0x00, 0x38, 0x00, 0x48, 0x00, 0x48, 0x00, 0x48, 0x00 }; + + u8g2_DrawXBM(OLED,118,47,kmh_width, kmh_height, kmh_bits); + +} + #endif // ======================================================================================================================== diff --git a/main/disp_oled.h b/main/disp_oled.h index 49bde51..2165afe 100644 --- a/main/disp_oled.h +++ b/main/disp_oled.h @@ -22,5 +22,6 @@ void OLED_DrawBattery (u8g2_t *OLED, GPS_Position *GPS=0); void OLED_DrawStatusBar(u8g2_t *OLED, GPS_Position *GPS=0); void OLED_DrawSystem (u8g2_t *OLED, GPS_Position *GPS=0); void OLED_DrawID (u8g2_t *OLED, GPS_Position *GPS=0); +void OLED_DrawAltitudeAndSpeed(u8g2_t *OLED, GPS_Position *GPS=0); #endif