Merge pull request #21 from lupus78/oled_custom

OLED custom pages
pull/30/head
Paweł Jałocha 2020-07-04 20:30:39 +01:00 zatwierdzone przez GitHub
commit 850494ed04
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 120 dodań i 23 usunięć

Wyświetl plik

@ -21,6 +21,8 @@
// #define WITH_OLED2 // 2nd OLED display, I2C address next higher // #define WITH_OLED2 // 2nd OLED display, I2C address next higher
#define WITH_U8G2_OLED // I2C OLED through the U8g2 library #define WITH_U8G2_OLED // I2C OLED through the U8g2 library
// #define WITH_U8G2_SH1106 // #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 #define WITH_RFM95 // RF chip selection: both HELTEC and TTGO use sx1276 which is same as RFM95

Wyświetl plik

@ -25,12 +25,8 @@
#include "disp_lcd.h" #include "disp_lcd.h"
#ifdef WITH_U8G2_OLED #ifdef WITH_U8G2_OLED
#ifdef WITH_U8G2_LISTS const uint8_t DISP_Pages = 10;
const uint8_t DISP_Pages = 6+3; static uint8_t DISP_Page = 0;
#else
const uint8_t DISP_Pages = 6;
#endif
static uint8_t DISP_Page = 1;
#endif #endif
#if defined(WITH_ST7789) || defined(WITH_ILI9341) #if defined(WITH_ST7789) || defined(WITH_ILI9341)
const uint8_t DISP_Pages = 9; const uint8_t DISP_Pages = 9;
@ -45,7 +41,7 @@ void vTaskDISP(void* pvParameters)
u8g2_ClearBuffer(&U8G2_OLED); u8g2_ClearBuffer(&U8G2_OLED);
OLED_DrawLogo(&U8G2_OLED); // draw logo OLED_DrawLogo(&U8G2_OLED); // draw logo
u8g2_SendBuffer(&U8G2_OLED); 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 #endif
#if defined(WITH_ST7789) || defined(WITH_ILI9341) #if defined(WITH_ST7789) || defined(WITH_ILI9341)
// LCD_Start(); // LCD_Start();
@ -169,25 +165,34 @@ void vTaskDISP(void* pvParameters)
// { OLED_DrawTrafWarn(&U8G2_OLED, GPS); } // { OLED_DrawTrafWarn(&U8G2_OLED, GPS); }
// else // else
// #endif // #endif
{ switch(DISP_Page) // skip not enabled pages
{ case 2: OLED_DrawGPS (&U8G2_OLED, GPS); break; while ( (U8G2_OLED_PAGES_ENABLED & (1 << DISP_Page)) == 0 ) {
case 3: OLED_DrawRF (&U8G2_OLED, GPS); break; DISP_Page++;
case 4: OLED_DrawBaro (&U8G2_OLED, GPS); break; if(DISP_Page>=DISP_Pages) DISP_Page=0;
case 1: OLED_DrawID (&U8G2_OLED, GPS); break; }
case 5: OLED_DrawSystem(&U8G2_OLED, GPS); break;
// case 6: OLED_DrawRelay (&U8G2_OLED, GPS); break; #ifdef DEBUG_PRINT
// case 7: OLED_DrawLookout(&U8G2_OLED, GPS); break; xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
case 0: OLED_DrawBattery(&U8G2_OLED, GPS); break; Format_String(CONS_UART_Write, "DISP_Page: ");
#ifdef WITH_U8G2_LISTS Format_Hex(CONS_UART_Write, DISP_Page);
case 6: OLED_DrawRelay (&U8G2_OLED, GPS); break; Format_String(CONS_UART_Write, "\n");
case 7: OLED_DrawLookout(&U8G2_OLED, GPS); break; xSemaphoreGive(CONS_Mutex);
case 9: OLED_DrawTrafWarn(&U8G2_OLED, GPS); break;
#endif #endif
// default:
// { OLED_DrawStatus(&U8G2_OLED, Time, 0); { switch(DISP_Page)
// OLED_DrawPosition(&U8G2_OLED, GPS, 2); } { 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); OLED_DrawStatusBar(&U8G2_OLED, GPS);
u8g2_SendBuffer(&U8G2_OLED); u8g2_SendBuffer(&U8G2_OLED);
} }

Wyświetl plik

@ -692,6 +692,95 @@ void OLED_DrawID(u8g2_t *OLED, GPS_Position *GPS)
u8g2_DrawStr(OLED, 96, 62, "v0.1.1"); 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 #endif
// ======================================================================================================================== // ========================================================================================================================

Wyświetl plik

@ -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_DrawStatusBar(u8g2_t *OLED, GPS_Position *GPS=0);
void OLED_DrawSystem (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_DrawID (u8g2_t *OLED, GPS_Position *GPS=0);
void OLED_DrawAltitudeAndSpeed(u8g2_t *OLED, GPS_Position *GPS=0);
#endif #endif