From c8bda95289b40d0800a80ca823daaafb687e0b6e Mon Sep 17 00:00:00 2001 From: Valentin Saugnier Date: Thu, 10 Aug 2023 17:25:47 +0200 Subject: [PATCH] Improve symbols management --- src/display.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 6876055..91182c7 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -24,10 +24,9 @@ extern int menuDisplay; extern bool symbolAvailable; extern bool bluetoothConnected; -String symbolArray[13] = {"BT", "[", ">", "j", "b", "<", "s", "u", "R", "v", "(", ";"}; +const char* symbolArray[] = { "[", ">", "j", "b", "<", "s", "u", "R", "v", "(", ";"}; int symbolArraySize = sizeof(symbolArray)/sizeof(symbolArray[0]); -const uint8_t *symbolsAPRS[] = {bluetoothSymbol, runnerSymbol, carSymbol, jeepSymbol, bikeSymbol, motorcycleSymbol, shipSymbol, truckSymbol, recreationalVehicleSymbol, vanSymbol, carsateliteSymbol, tentSymbol}; -uint32_t symbolTime = millis(); +const uint8_t *symbolsAPRS[] = {runnerSymbol, carSymbol, jeepSymbol, bikeSymbol, motorcycleSymbol, shipSymbol, truckSymbol, recreationalVehicleSymbol, vanSymbol, carsateliteSymbol, tentSymbol}; // T-Beams bought with soldered OLED Screen comes with only 4 pins (VCC, GND, SDA, SCL) // If your board didn't come with 4 pins OLED Screen and comes with 5 and one of them is RST... // Uncomment Next Line (Remember ONLY if your OLED Screen has a RST pin). This is to avoid memory issues. @@ -248,6 +247,8 @@ void show_display(String header, String line1, String line2, String line3, Strin } } + symbolAvailable = symbol != 100; + /* * Symbol alternate every 5s * If bluetooth is disconnected or if we are in the first part of the clock, then we show the APRS symbol @@ -255,13 +256,11 @@ void show_display(String header, String line1, String line2, String line3, Strin */ const auto time_now = now(); if (!bluetoothConnected || time_now % 10 < 5) { - if (symbol != 100) { - symbolAvailable = true; + if (symbolAvailable) { display.drawBitmap((display.width() - SYM_WIDTH), 0, symbolsAPRS[symbol], SYM_WIDTH, SYM_HEIGHT, 1); - } else { - symbolAvailable = false; } } else if (bluetoothConnected) { + // TODO In this case, the text symbol stay displayed due to symbolAvailable false in menu_utils display.drawBitmap((display.width() - SYM_WIDTH), 0, bluetoothSymbol, SYM_WIDTH, SYM_HEIGHT, 1); } }