diff --git a/Boards.h b/Boards.h
index 601a432..64a92a4 100644
--- a/Boards.h
+++ b/Boards.h
@@ -395,7 +395,7 @@
#define HAS_BUSY true
#define HAS_TCXO true
- #define HAS_DISPLAY false
+ #define HAS_DISPLAY true
#define HAS_CONSOLE false
#define HAS_BLUETOOTH false
#define HAS_BLE true
@@ -425,7 +425,13 @@
const int SD_MOSI = 41;
const int SD_CLK = 40;
const int SD_CS = 39;
+
+ const int DISPLAY_DC = 11;
const int DISPLAY_CS = 12;
+ const int DISPLAY_MISO = 38;
+ const int DISPLAY_MOSI = 41;
+ const int DISPLAY_CLK = 40;
+ const int DISPLAY_BL_PIN = 42;
#if HAS_NP == false
#if defined(EXTERNAL_LEDS)
diff --git a/Display.h b/Display.h
index d4effde..0c87a39 100644
--- a/Display.h
+++ b/Display.h
@@ -14,9 +14,15 @@
// along with this program. If not, see .
#include "Graphics.h"
-#include
#include
-#include
+
+#if BOARD_MODEL == BOARD_TDECK
+ #include
+#else
+ #include
+ #include
+#endif
+
#include "Fonts/Org_01.h"
#define DISP_W 128
#define DISP_H 64
@@ -53,7 +59,13 @@
#define SMALL_FONT &Org_01
-Adafruit_SSD1306 display(DISP_W, DISP_H, &Wire, DISP_RST);
+#if BOARD_MODEL == BOARD_TDECK
+ Adafruit_ST7789 display = Adafruit_ST7789(DISPLAY_CS, DISPLAY_DC, -1);
+ #define SSD1306_WHITE ST77XX_WHITE
+ #define SSD1306_BLACK ST77XX_BLACK
+#else
+ Adafruit_SSD1306 display(DISP_W, DISP_H, &Wire, DISP_RST);
+#endif
#define DISP_MODE_UNKNOWN 0x00
#define DISP_MODE_LANDSCAPE 0x01
@@ -102,10 +114,37 @@ void update_area_positions() {
}
uint8_t display_contrast = 0x00;
-void set_contrast(Adafruit_SSD1306 *display, uint8_t contrast) {
+#if BOARD_MODEL != BOARD_TDECK
+ void set_contrast(Adafruit_SSD1306 *display, uint8_t contrast) {
display->ssd1306_command(SSD1306_SETCONTRAST);
display->ssd1306_command(contrast);
-}
+ }
+#else
+ void set_contrast(Adafruit_ST7789 *display, uint8_t value) {
+ static uint8_t level = 0;
+ static uint8_t steps = 16;
+ if (value > 15) value = 15;
+ if (value == 0) {
+ digitalWrite(DISPLAY_BL_PIN, 0);
+ delay(3);
+ level = 0;
+ return;
+ }
+ if (level == 0) {
+ digitalWrite(DISPLAY_BL_PIN, 1);
+ level = steps;
+ delayMicroseconds(30);
+ }
+ int from = steps - level;
+ int to = steps - value;
+ int num = (steps + to - from) % steps;
+ for (int i = 0; i < num; i++) {
+ digitalWrite(DISPLAY_BL_PIN, 0);
+ digitalWrite(DISPLAY_BL_PIN, 1);
+ }
+ level = value;
+ }
+#endif
bool display_init() {
#if HAS_DISPLAY
@@ -161,7 +200,13 @@ bool display_init() {
}
#endif
- if(!display.begin(SSD1306_SWITCHCAPVCC, display_address)) {
+ #if BOARD_MODEL == BOARD_TDECK
+ display.init(240, 320);
+ display.setSPISpeed(80e6);
+ if (false) {
+ #else
+ if (!display.begin(SSD1306_SWITCHCAPVCC, display_address)) {
+ #endif
return false;
} else {
set_contrast(&display, display_contrast);
@@ -188,10 +233,10 @@ bool display_init() {
display.setRotation(1);
#elif BOARD_MODEL == BOARD_HELTEC32_V3
disp_mode = DISP_MODE_PORTRAIT;
- // Antenna conx up
display.setRotation(1);
- // USB-C up
- // display.setRotation(3);
+ #elif BOARD_MODEL == BOARD_TDECK
+ disp_mode = DISP_MODE_PORTRAIT;
+ display.setRotation(3);
#else
disp_mode = DISP_MODE_PORTRAIT;
display.setRotation(3);
@@ -216,6 +261,10 @@ bool display_init() {
#endif
#endif
+ #if BOARD_MODEL == BOARD_TDECK
+ display.fillScreen(SSD1306_BLACK);
+ #endif
+
return true;
}
#else
@@ -412,7 +461,7 @@ void draw_stat_area() {
void update_stat_area() {
if (eeprom_ok && !firmware_update_mode && !console_active) {
-
+
draw_stat_area();
if (disp_mode == DISP_MODE_PORTRAIT) {
display.drawBitmap(p_as_x, p_as_y, stat_area.getBuffer(), stat_area.width(), stat_area.height(), SSD1306_WHITE, SSD1306_BLACK);
@@ -587,6 +636,7 @@ void draw_disp_area() {
void update_disp_area() {
draw_disp_area();
+
display.drawBitmap(p_ad_x, p_ad_y, disp_area.getBuffer(), disp_area.width(), disp_area.height(), SSD1306_WHITE, SSD1306_BLACK);
if (disp_mode == DISP_MODE_LANDSCAPE) {
if (device_init_done && !firmware_update_mode && !disp_ext_fb) {
@@ -617,8 +667,14 @@ void update_display(bool blank = false) {
display_contrast = display_intensity;
set_contrast(&display, display_contrast);
}
- display.clearDisplay();
- display.display();
+
+ #if BOARD_MODEL != BOARD_TDECK
+ display.clearDisplay();
+ display.display();
+ #else
+ // TODO: Clear screen
+ #endif
+
last_disp_update = millis();
}
} else {
@@ -627,10 +683,17 @@ void update_display(bool blank = false) {
display_contrast = display_intensity;
set_contrast(&display, display_contrast);
}
- display.clearDisplay();
+
+ #if BOARD_MODEL != BOARD_TDECK
+ display.clearDisplay();
+ #endif
+
update_stat_area();
update_disp_area();
- display.display();
+
+ #if BOARD_MODEL != BOARD_TDECK
+ display.display();
+ #endif
last_disp_update = millis();
}
}
diff --git a/Makefile b/Makefile
index edb3a24..0ffb789 100644
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,7 @@ prep-esp32:
arduino-cli core update-index --config-file arduino-cli.yaml
arduino-cli core install esp32:esp32@$(ARDUINO_ESP_CORE_VER) --config-file arduino-cli.yaml
arduino-cli lib install "Adafruit SSD1306"
+ arduino-cli lib install "Adafruit ST7735 and ST7789 Library"
arduino-cli lib install "Adafruit NeoPixel"
arduino-cli lib install "XPowersLib"
arduino-cli lib install "Crypto"
@@ -173,8 +174,8 @@ upload-tdeck:
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3
@sleep 1
rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin)
- @sleep 3
- python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
+ #@sleep 3
+ #python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
upload-rnode_ng_20:
arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:ttgo-lora32
diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino
index f00191d..2344132 100644
--- a/RNode_Firmware.ino
+++ b/RNode_Firmware.ino
@@ -61,6 +61,8 @@ void setup() {
pinMode(DISPLAY_CS, OUTPUT);
digitalWrite(SD_CS, HIGH);
digitalWrite(DISPLAY_CS, HIGH);
+
+ pinMode(DISPLAY_BL_PIN, OUTPUT);
#endif
#endif