From 3a82baf506729ee9d6afdf1f2736350d59d40b6a Mon Sep 17 00:00:00 2001 From: Pawel Jalocha Date: Sat, 4 Jul 2020 00:13:45 +0100 Subject: [PATCH] Add BT icon on the OLED status bar --- main/disp_oled.cpp | 9 +++++++-- main/hal.cpp | 4 +++- main/hal.h | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/main/disp_oled.cpp b/main/disp_oled.cpp index f18d1bd..4d29e2a 100644 --- a/main/disp_oled.cpp +++ b/main/disp_oled.cpp @@ -517,7 +517,7 @@ void OLED_DrawBattery(u8g2_t *OLED, GPS_Position *GPS) // draw battery status pa #endif } -void OLED_DrawStatusBar(u8g2_t *OLED, GPS_Position *GPS) +void OLED_DrawStatusBar(u8g2_t *OLED, GPS_Position *GPS) // status bar on top of the OLED { static bool Odd=0; #ifdef WITH_MAVLINK uint8_t Cap = MAVLINK_BattCap; // [%] @@ -546,7 +546,12 @@ void OLED_DrawStatusBar(u8g2_t *OLED, GPS_Position *GPS) #ifdef WITH_SD if(SD_isMounted()) { u8g2_SetFont(OLED, u8g2_font_twelvedings_t_all); - u8g2_DrawGlyph(OLED, 30, 12, 0x73); } + u8g2_DrawGlyph(OLED, 24, 12, 0x73); } +#endif +#ifdef WITH_BT_SPP + if(BT_SPP_isConnected()) + { u8g2_SetFont(OLED, u8g2_font_open_iconic_embedded_1x_t); + u8g2_DrawGlyph(OLED, 36, 11, 0x4A); } #endif // u8g2_SetFont(OLED, u8g2_font_5x7_tr); // u8g2_SetFont(OLED, u8g2_font_5x8_tr); diff --git a/main/hal.cpp b/main/hal.cpp index 9c92cd5..ae113b6 100644 --- a/main/hal.cpp +++ b/main/hal.cpp @@ -590,6 +590,8 @@ static uint32_t BT_SPP_TxCong = 0; // congestion control // static const char *BT_SPP_Welcome = "ESP32 OGN-Tracker\n"; +bool BT_SPP_isConnected(void) { return BT_SPP_Conn; } // is a client conencted to BT_SPP ? + static void setPilotID(esp_bd_addr_t MAC, size_t Len=6) // set PilotID in the parameters from the BT SPP client MAC (thus Pilot's smartphone) { char *ID = Parameters.PilotID; ID[0]='B'; ID[1]='T'; ID[2]='_'; ID+=3; @@ -626,7 +628,7 @@ static void esp_spp_cb(esp_spp_cb_event_t Event, esp_spp_cb_param_t *Param) BT_SPP_TxFIFO.Clear(); // clear the TxFIFO BT_SPP_Conn = Param->srv_open.handle; // store handle for esp_spp_write() BT_SPP_TxCong = 0; // assume no congestion - setPilotID(Param->srv_open.rem_bda, sizeof(esp_bd_addr_t)); // PilotID is not taken from the connected BT client + setPilotID(Param->srv_open.rem_bda, sizeof(esp_bd_addr_t)); // PilotID is now taken from the connected BT client // memcpy(BT_SPP_MAC, Param->srv_open.rem_bda, sizeof(esp_bd_addr_t)); // esp_spp_write(Param->srv_open.handle, BT_SPP_Wait, (uint8_t *)BT_SPP_Welcome); // write Welcome message to the BT_SPP #ifdef DEBUG_PRINT diff --git a/main/hal.h b/main/hal.h index d5e5b49..1f6c1e9 100644 --- a/main/hal.h +++ b/main/hal.h @@ -168,6 +168,7 @@ int NVS_Init(void); // initialize non-volatile-storage in t #ifdef WITH_BT_SPP int BT_SPP_Init(void); +bool BT_SPP_isConnected(void); #endif #ifdef WITH_SPIFFS