techo-display: first bits

This commit is contained in:
Florent
2025-04-15 22:37:50 +02:00
parent 1f1d39d179
commit ea24a12ba3
6 changed files with 135 additions and 3 deletions

View File

@@ -61,6 +61,8 @@
#include "UITask.h"
#ifdef ST7789
#include <helpers/ui/ST7789Display.h>
#elif defined(HAS_GxEPD)
#include <helpers/ui/GxEPDDisplay.h>
#else
#include <helpers/ui/SSD1306Display.h>
#endif

View File

@@ -0,0 +1,63 @@
#include "GxEPDDisplay.h"
bool GxEPDDisplay::begin() {
display.epd2.selectSPI(SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
SPI1.begin();
display.init(115200, true, 2, false);
display.setRotation(3);
display.setFont(&FreeMono9pt7b);
display.setPartialWindow(0, 0, display.width(), display.height());
display.fillScreen(GxEPD_WHITE);
display.display();
_init = true;
return true;
}
void GxEPDDisplay::turnOn() {
if (!_init) begin();
}
void GxEPDDisplay::turnOff() {
}
void GxEPDDisplay::clear() {
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
}
void GxEPDDisplay::startFrame(Color bkg) {
display.fillScreen(GxEPD_WHITE);
}
void GxEPDDisplay::setTextSize(int sz) {
}
void GxEPDDisplay::setColor(Color c) {
display.setTextColor(GxEPD_BLACK);
}
void GxEPDDisplay::setCursor(int x, int y) {
display.setCursor(x*1.5, (y*1.5)+10);
}
void GxEPDDisplay::print(const char* str) {
display.print(str);
}
void GxEPDDisplay::fillRect(int x, int y, int w, int h) {
}
void GxEPDDisplay::drawRect(int x, int y, int w, int h) {
}
void GxEPDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
display.drawBitmap(x*1.5, (y*1.5) + 10, bits, w, h, GxEPD_BLACK);
}
void GxEPDDisplay::endFrame() {
display.display(true);
}

View File

@@ -0,0 +1,49 @@
#pragma once
#include <SPI.h>
#include <Wire.h>
#define ENABLE_GxEPD2_GFX 0
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include <GxEPD2_4C.h>
#include <GxEPD2_7C.h>
#include <Fonts/FreeMono9pt7b.h>
#define GxEPD2_DISPLAY_CLASS GxEPD2_BW
#define GxEPD2_DRIVER_CLASS GxEPD2_150_BN // DEPG0150BN 200x200, SSD1681, (FPC8101), TTGO T5 V2.4.1
#include <epd/GxEPD2_150_BN.h> // 1.54" b/w
#include "DisplayDriver.h"
//GxEPD2_BW<GxEPD2_150_BN, 200> display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)); // DEPG0150BN 200x200, SSD1681, TTGO T5 V2.4.1
class GxEPDDisplay : public DisplayDriver {
GxEPD2_BW<GxEPD2_150_BN, 200> display;
bool _init = false;
public:
GxEPDDisplay() : DisplayDriver(200, 200), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) {
}
bool begin();
bool isOn() override { return true; }
void turnOn() override;
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setCursor(int x, int y) override;
void print(const char* str) override;
void fillRect(int x, int y, int w, int h) override;
void drawRect(int x, int y, int w, int h) override;
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
void endFrame() override;
};

View File

@@ -56,17 +56,23 @@ build_flags =
extends = LilyGo_Techo
build_flags =
${LilyGo_Techo.build_flags}
-I src/helpers/ui
-D MAX_CONTACTS=100
-D MAX_GROUP_CHANNELS=8
-D BLE_PIN_CODE=123456
-D BLE_DEBUG_LOGGING=1
-D DISPLAY_CLASS=GxEPDDisplay
-D HAS_GxEPD
; -D ENABLE_PRIVATE_KEY_IMPORT=1
; -D ENABLE_PRIVATE_KEY_EXPORT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_Techo.build_src_filter}
+<helpers/nrf52/*.cpp>
+<../examples/companion_radio/main.cpp>
+<helpers/nrf52/TechoBoard.cpp>
+<helpers/nrf52/SerialBLEInterface.cpp>
+<helpers/ui/GxEPDDisplay.cpp>
+<../examples/companion_radio>
lib_deps =
${LilyGo_Techo.lib_deps}
densaugeo/base64 @ ~1.4.0
zinggjm/GxEPD2 @ 1.6.2

View File

@@ -2,6 +2,10 @@
#include "wiring_constants.h"
#include "wiring_digital.h"
const int MISO = PIN_SPI1_MISO;
const int MOSI = PIN_SPI1_MOSI;
const int SCK = PIN_SPI1_SCK;
const uint32_t g_ADigitalPinMap[] = {
0xff, 0xff, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,

View File

@@ -96,10 +96,18 @@
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
#define PIN_SPI1_MISO (39)
////////////////////////////////////////////////////////////////////////////////
// SPI1
#define PIN_SPI1_MISO (38)
#define PIN_SPI1_MOSI (29)
#define PIN_SPI1_SCK (31)
// GxEPD2 needs that for a panel that is not even used !
extern const int MISO;
extern const int MOSI;
extern const int SCK;
////////////////////////////////////////////////////////////////////////////////
// Display