Skip to content

Commit

Permalink
symbols on TFT
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed Apr 18, 2024
1 parent 5521286 commit f477154
Showing 1 changed file with 48 additions and 12 deletions.
60 changes: 48 additions & 12 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
TFT_eSPI tft = TFT_eSPI();

#ifdef HELTEC_WIRELESS_TRACKER
#define bigSizeFont 2
#define smallSizeFont 1
#define lineSpacing 9
#define bigSizeFont 2
#define smallSizeFont 1
#define lineSpacing 9
#endif
#ifdef TTGO_T_DECK_GPS
#define bigSizeFont 4
#define smallSizeFont 2
#define lineSpacing 18
#define bigSizeFont 4
#define smallSizeFont 2
#define lineSpacing 18
#endif

#else
Expand All @@ -41,12 +41,11 @@ Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST);
#include <Adafruit_SH110X.h>
Adafruit_SH1106G display(128, 64, &Wire, OLED_RST);
#endif

#define SYM_HEIGHT 14
#define SYM_WIDTH 16

#endif

#define SYMBOL_HEIGHT 14
#define SYMBOL_WIDTH 16

extern Configuration Config;
extern Beacon *currentBeacon;
extern int menuDisplay;
Expand Down Expand Up @@ -342,6 +341,43 @@ void show_display(String header, String line1, String line2, String line3, Strin
tft.print(line4);
tft.setCursor(0, ((lineSpacing *6) - 2));
tft.print(line5);

if (menuDisplay == 0 && Config.display.showSymbol) {
int symbol = 100;
for (int i = 0; i < symbolArraySize; i++) {
if (currentBeacon->symbol == symbolArray[i]) {
symbol = i;
break;
}
}

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
* Otherwise, we are in the second part of the clock, then we show BT connected
*/
const auto time_now = now();
if (!bluetoothConnected || time_now % 10 < 5) {
if (symbolAvailable) {
#if HELTEC_WIRELESS_TRACKER
tft.drawBitmap((TFT_WIDTH - SYMBOL_WIDTH + (128 - TFT_WIDTH)), 0, symbolsAPRS[symbol], SYMBOL_WIDTH, SYMBOL_HEIGHT, TFT_WHITE);//, TFT_RED);
#endif
#if TTGO_T_DECK_GPS
tft.drawBitmap((TFT_WIDTH - SYMBOL_WIDTH), 0, symbolsAPRS[symbol], SYMBOL_WIDTH, SYMBOL_HEIGHT, TFT_WHITE);//, TFT_RED);
#endif
}
} else if (bluetoothConnected) { // TODO In this case, the text symbol stay displayed due to symbolAvailable false in menu_utils
#if HELTEC_WIRELESS_TRACKER
tft.drawBitmap((TFT_WIDTH - SYMBOL_WIDTH + (128 - TFT_WIDTH)), 0, bluetoothSymbol, SYMBOL_WIDTH, SYMBOL_HEIGHT, TFT_WHITE);
#endif
#if TTGO_T_DECK_GPS
tft.drawBitmap((TFT_WIDTH - SYMBOL_WIDTH), 0, bluetoothSymbol, SYMBOL_WIDTH, SYMBOL_HEIGHT, TFT_WHITE);
#endif
}
}

#else
display.clearDisplay();
#ifdef ssd1306
Expand Down Expand Up @@ -387,11 +423,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 (symbolAvailable) {
display.drawBitmap((display.width() - SYM_WIDTH), 0, symbolsAPRS[symbol], SYM_WIDTH, SYM_HEIGHT, 1);
display.drawBitmap((display.width() - SYMBOL_WIDTH), 0, symbolsAPRS[symbol], SYMBOL_WIDTH, SYMBOL_HEIGHT, 1);
}
} 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);
display.drawBitmap((display.width() - SYMBOL_WIDTH), 0, bluetoothSymbol, SYMBOL_WIDTH, SYMBOL_HEIGHT, 1);
}
}

Expand Down

0 comments on commit f477154

Please sign in to comment.