Skip to content

Commit ea24a12

Browse files
committed
techo-display: first bits
1 parent 1f1d39d commit ea24a12

File tree

6 files changed

+135
-3
lines changed

6 files changed

+135
-3
lines changed

examples/companion_radio/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
#include "UITask.h"
6262
#ifdef ST7789
6363
#include <helpers/ui/ST7789Display.h>
64+
#elif defined(HAS_GxEPD)
65+
#include <helpers/ui/GxEPDDisplay.h>
6466
#else
6567
#include <helpers/ui/SSD1306Display.h>
6668
#endif

src/helpers/ui/GxEPDDisplay.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
#include "GxEPDDisplay.h"
3+
4+
bool GxEPDDisplay::begin() {
5+
display.epd2.selectSPI(SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
6+
SPI1.begin();
7+
display.init(115200, true, 2, false);
8+
display.setRotation(3);
9+
display.setFont(&FreeMono9pt7b);
10+
11+
display.setPartialWindow(0, 0, display.width(), display.height());
12+
13+
display.fillScreen(GxEPD_WHITE);
14+
display.display();
15+
_init = true;
16+
return true;
17+
}
18+
19+
void GxEPDDisplay::turnOn() {
20+
if (!_init) begin();
21+
}
22+
23+
void GxEPDDisplay::turnOff() {
24+
25+
}
26+
27+
void GxEPDDisplay::clear() {
28+
display.fillScreen(GxEPD_WHITE);
29+
display.setTextColor(GxEPD_BLACK);
30+
}
31+
32+
void GxEPDDisplay::startFrame(Color bkg) {
33+
display.fillScreen(GxEPD_WHITE);
34+
}
35+
36+
void GxEPDDisplay::setTextSize(int sz) {
37+
}
38+
39+
void GxEPDDisplay::setColor(Color c) {
40+
display.setTextColor(GxEPD_BLACK);
41+
}
42+
43+
void GxEPDDisplay::setCursor(int x, int y) {
44+
display.setCursor(x*1.5, (y*1.5)+10);
45+
}
46+
47+
void GxEPDDisplay::print(const char* str) {
48+
display.print(str);
49+
}
50+
51+
void GxEPDDisplay::fillRect(int x, int y, int w, int h) {
52+
}
53+
54+
void GxEPDDisplay::drawRect(int x, int y, int w, int h) {
55+
}
56+
57+
void GxEPDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
58+
display.drawBitmap(x*1.5, (y*1.5) + 10, bits, w, h, GxEPD_BLACK);
59+
}
60+
61+
void GxEPDDisplay::endFrame() {
62+
display.display(true);
63+
}

src/helpers/ui/GxEPDDisplay.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#pragma once
2+
3+
#include <SPI.h>
4+
#include <Wire.h>
5+
6+
#define ENABLE_GxEPD2_GFX 0
7+
8+
#include <GxEPD2_BW.h>
9+
#include <GxEPD2_3C.h>
10+
#include <GxEPD2_4C.h>
11+
#include <GxEPD2_7C.h>
12+
#include <Fonts/FreeMono9pt7b.h>
13+
14+
#define GxEPD2_DISPLAY_CLASS GxEPD2_BW
15+
#define GxEPD2_DRIVER_CLASS GxEPD2_150_BN // DEPG0150BN 200x200, SSD1681, (FPC8101), TTGO T5 V2.4.1
16+
17+
#include <epd/GxEPD2_150_BN.h> // 1.54" b/w
18+
19+
#include "DisplayDriver.h"
20+
21+
//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
22+
23+
24+
class GxEPDDisplay : public DisplayDriver {
25+
26+
GxEPD2_BW<GxEPD2_150_BN, 200> display;
27+
bool _init = false;
28+
29+
public:
30+
GxEPDDisplay() : DisplayDriver(200, 200), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) {
31+
32+
}
33+
34+
bool begin();
35+
36+
bool isOn() override { return true; }
37+
void turnOn() override;
38+
void turnOff() override;
39+
void clear() override;
40+
void startFrame(Color bkg = DARK) override;
41+
void setTextSize(int sz) override;
42+
void setColor(Color c) override;
43+
void setCursor(int x, int y) override;
44+
void print(const char* str) override;
45+
void fillRect(int x, int y, int w, int h) override;
46+
void drawRect(int x, int y, int w, int h) override;
47+
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
48+
void endFrame() override;
49+
};

variants/techo/platformio.ini

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,23 @@ build_flags =
5656
extends = LilyGo_Techo
5757
build_flags =
5858
${LilyGo_Techo.build_flags}
59+
-I src/helpers/ui
5960
-D MAX_CONTACTS=100
6061
-D MAX_GROUP_CHANNELS=8
6162
-D BLE_PIN_CODE=123456
6263
-D BLE_DEBUG_LOGGING=1
64+
-D DISPLAY_CLASS=GxEPDDisplay
65+
-D HAS_GxEPD
6366
; -D ENABLE_PRIVATE_KEY_IMPORT=1
6467
; -D ENABLE_PRIVATE_KEY_EXPORT=1
6568
; -D MESH_PACKET_LOGGING=1
6669
; -D MESH_DEBUG=1
6770
build_src_filter = ${LilyGo_Techo.build_src_filter}
68-
+<helpers/nrf52/*.cpp>
69-
+<../examples/companion_radio/main.cpp>
71+
+<helpers/nrf52/TechoBoard.cpp>
72+
+<helpers/nrf52/SerialBLEInterface.cpp>
73+
+<helpers/ui/GxEPDDisplay.cpp>
74+
+<../examples/companion_radio>
7075
lib_deps =
7176
${LilyGo_Techo.lib_deps}
7277
densaugeo/base64 @ ~1.4.0
78+
zinggjm/GxEPD2 @ 1.6.2

variants/techo/variant.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include "wiring_constants.h"
33
#include "wiring_digital.h"
44

5+
const int MISO = PIN_SPI1_MISO;
6+
const int MOSI = PIN_SPI1_MOSI;
7+
const int SCK = PIN_SPI1_SCK;
8+
59
const uint32_t g_ADigitalPinMap[] = {
610
0xff, 0xff, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
711
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,

variants/techo/variant.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,18 @@
9696
#define SX126X_DIO2_AS_RF_SWITCH
9797
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
9898

99-
#define PIN_SPI1_MISO (39)
99+
////////////////////////////////////////////////////////////////////////////////
100+
// SPI1
101+
102+
#define PIN_SPI1_MISO (38)
100103
#define PIN_SPI1_MOSI (29)
101104
#define PIN_SPI1_SCK (31)
102105

106+
// GxEPD2 needs that for a panel that is not even used !
107+
extern const int MISO;
108+
extern const int MOSI;
109+
extern const int SCK;
110+
103111
////////////////////////////////////////////////////////////////////////////////
104112
// Display
105113

0 commit comments

Comments
 (0)