mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 12:45:45 +00:00
@@ -99,7 +99,7 @@ void UITask::renderCurrScreen() {
|
||||
_display->setColor(DisplayDriver::LIGHT);
|
||||
_display->print(_msg);
|
||||
|
||||
_display->setCursor(100, 9);
|
||||
_display->setCursor(_display->width() - 28, 9);
|
||||
_display->setTextSize(2);
|
||||
_display->setColor(DisplayDriver::ORANGE);
|
||||
sprintf(tmp, "%d", _msgcount);
|
||||
|
||||
@@ -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
|
||||
|
||||
99
src/helpers/ui/GxEPDDisplay.cpp
Normal file
99
src/helpers/ui/GxEPDDisplay.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
|
||||
#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);
|
||||
#ifdef TECHO_ZOOM
|
||||
display.setFont(&FreeMono9pt7b);
|
||||
#endif
|
||||
display.setPartialWindow(0, 0, display.width(), display.height());
|
||||
|
||||
display.fillScreen(GxEPD_WHITE);
|
||||
display.display(true);
|
||||
#if DISP_BACKLIGHT
|
||||
pinMode(DISP_BACKLIGHT, OUTPUT);
|
||||
#endif
|
||||
_init = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GxEPDDisplay::turnOn() {
|
||||
if (!_init) begin();
|
||||
#if DISP_BACKLIGHT
|
||||
digitalWrite(DISP_BACKLIGHT, HIGH);
|
||||
_isOn = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxEPDDisplay::turnOff() {
|
||||
#if DISP_BACKLIGHT
|
||||
digitalWrite(DISP_BACKLIGHT, LOW);
|
||||
#endif
|
||||
_isOn = false;
|
||||
}
|
||||
|
||||
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) {
|
||||
display.setTextSize(sz);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::setColor(Color c) {
|
||||
display.setTextColor(GxEPD_BLACK);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::setCursor(int x, int y) {
|
||||
#ifdef TECHO_ZOOM
|
||||
x = x + (x >> 1);
|
||||
y = y + (y >> 1);
|
||||
#endif
|
||||
display.setCursor(x, (y+10));
|
||||
}
|
||||
|
||||
void GxEPDDisplay::print(const char* str) {
|
||||
display.print(str);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::fillRect(int x, int y, int w, int h) {
|
||||
#ifdef TECHO_ZOOM
|
||||
x = x + (x >> 1);
|
||||
y = y + (y >> 1);
|
||||
w = w + (w >> 1);
|
||||
h = h + (h >> 1);
|
||||
#endif
|
||||
display.fillRect(x, y, w, h, GxEPD_BLACK);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::drawRect(int x, int y, int w, int h) {
|
||||
#ifdef TECHO_ZOOM
|
||||
x = x + (x >> 1);
|
||||
y = y + (y >> 1);
|
||||
w = w + (w >> 1);
|
||||
h = h + (h >> 1);
|
||||
#endif
|
||||
display.drawRect(x, y, w, h, GxEPD_BLACK);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
||||
#ifdef TECHO_ZOOM
|
||||
x = x + (x >> 1);
|
||||
y = y + (y >> 1);
|
||||
w = w + (w >> 1);
|
||||
h = h + (h >> 1);
|
||||
#endif
|
||||
display.drawBitmap(x*1.5, (y*1.5) + 10, bits, w, h, GxEPD_BLACK);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::endFrame() {
|
||||
display.display(true);
|
||||
}
|
||||
51
src/helpers/ui/GxEPDDisplay.h
Normal file
51
src/helpers/ui/GxEPDDisplay.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#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;
|
||||
bool _isOn = false;
|
||||
|
||||
public:
|
||||
// there is a margin in y...
|
||||
GxEPDDisplay() : DisplayDriver(200, 200-10), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) {
|
||||
|
||||
}
|
||||
|
||||
bool begin();
|
||||
|
||||
bool isOn() override {return _isOn;};
|
||||
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;
|
||||
};
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
#define LED_GREEN (33)
|
||||
#define LED_BLUE (14)
|
||||
|
||||
#define PIN_STATUS_LED LED_GREEN
|
||||
#define LED_BUILTIN LED_GREEN
|
||||
#define PIN_LED LED_BUILTIN
|
||||
#define LED_PIN LED_BUILTIN
|
||||
@@ -78,6 +79,7 @@
|
||||
|
||||
#define PIN_BUTTON1 (42)
|
||||
#define BUTTON_PIN PIN_BUTTON1
|
||||
#define PIN_USER_BTN BUTTON_PIN
|
||||
|
||||
#define PIN_BUTTON2 (11)
|
||||
#define BUTTON_PIN2 PIN_BUTTON2
|
||||
@@ -96,10 +98,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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user