выбор драйвера дисплея по DISPLAY_CLASS, правки SH1106 и OLED_RU
Build and deploy Docs site to GitHub Pages / github-pages (push) Canceled after 0s
PR Build Check / build (Heltec_v3_companion_radio_ble) (push) Canceled after 0s
PR Build Check / build (Heltec_v3_repeater) (push) Canceled after 0s
PR Build Check / build (Heltec_v3_room_server) (push) Canceled after 0s
PR Build Check / build (LilyGo_Tlora_C6_repeater_) (push) Canceled after 0s
PR Build Check / build (PicoW_repeater) (push) Canceled after 0s
PR Build Check / build (RAK_4631_companion_radio_ble) (push) Canceled after 0s
PR Build Check / build (RAK_4631_companion_radio_ethernet) (push) Canceled after 0s
PR Build Check / build (RAK_4631_repeater) (push) Canceled after 0s
PR Build Check / build (RAK_4631_repeater_ethernet) (push) Canceled after 0s
PR Build Check / build (RAK_4631_room_server) (push) Canceled after 0s
PR Build Check / build (RAK_4631_room_server_ethernet) (push) Canceled after 0s
PR Build Check / build (Tbeam_SX1276_repeater) (push) Canceled after 0s
PR Build Check / build (wio-e5-mini_repeater) (push) Canceled after 0s
PR Build Check / build (wio_wm1110_repeater) (push) Canceled after 0s
Run Unit Tests / test (push) Canceled after 0s
Build and deploy Docs site to GitHub Pages / github-pages (push) Canceled after 0s
PR Build Check / build (Heltec_v3_companion_radio_ble) (push) Canceled after 0s
PR Build Check / build (Heltec_v3_repeater) (push) Canceled after 0s
PR Build Check / build (Heltec_v3_room_server) (push) Canceled after 0s
PR Build Check / build (LilyGo_Tlora_C6_repeater_) (push) Canceled after 0s
PR Build Check / build (PicoW_repeater) (push) Canceled after 0s
PR Build Check / build (RAK_4631_companion_radio_ble) (push) Canceled after 0s
PR Build Check / build (RAK_4631_companion_radio_ethernet) (push) Canceled after 0s
PR Build Check / build (RAK_4631_repeater) (push) Canceled after 0s
PR Build Check / build (RAK_4631_repeater_ethernet) (push) Canceled after 0s
PR Build Check / build (RAK_4631_room_server) (push) Canceled after 0s
PR Build Check / build (RAK_4631_room_server_ethernet) (push) Canceled after 0s
PR Build Check / build (Tbeam_SX1276_repeater) (push) Canceled after 0s
PR Build Check / build (wio-e5-mini_repeater) (push) Canceled after 0s
PR Build Check / build (wio_wm1110_repeater) (push) Canceled after 0s
Run Unit Tests / test (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
// Единая точка подключения драйвера дисплея по макросу DISPLAY_CLASS.
|
||||
//
|
||||
// Вариант задаёт в platformio.ini только имя класса, например
|
||||
// -D DISPLAY_CLASS=SH1106Display
|
||||
// и больше ничего не правит: ни target.h, ни build_src_filter (последний
|
||||
// обрабатывает build_as_lib.py, либо он задан явно в env).
|
||||
//
|
||||
// Приём: имена классов на время вычисления подменяются числовыми маркерами,
|
||||
// поэтому DISPLAY_CLASS можно сравнить через #if. Маркеры снимаются до
|
||||
// include драйвера, чтобы имя класса осталось обычным идентификатором, а не
|
||||
// макросом (иначе `extern DISPLAY_CLASS display;` превратился бы в `extern 1
|
||||
// display;`).
|
||||
//
|
||||
// Чтобы добавить драйвер: дописать маркер, ветку и #include ниже.
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
|
||||
#define SSD1306Display 1
|
||||
#define SH1106Display 2
|
||||
|
||||
#if DISPLAY_CLASS == 1
|
||||
#define MC_DISPLAY_SSD1306
|
||||
#elif DISPLAY_CLASS == 2
|
||||
#define MC_DISPLAY_SH1106
|
||||
#else
|
||||
#error "DisplaySelect.h: unsupported DISPLAY_CLASS (SSD1306Display or SH1106Display expected)"
|
||||
#endif
|
||||
|
||||
#undef SSD1306Display
|
||||
#undef SH1106Display
|
||||
|
||||
#ifdef MC_DISPLAY_SSD1306
|
||||
#include "SSD1306Display.h"
|
||||
#endif
|
||||
#ifdef MC_DISPLAY_SH1106
|
||||
#include "SH1106Display.h"
|
||||
#endif
|
||||
|
||||
#endif // DISPLAY_CLASS
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "SH1106Display.h"
|
||||
#include <Adafruit_GrayOLED.h>
|
||||
#include "Adafruit_SH110X.h"
|
||||
#ifdef OLED_RU
|
||||
#include "glcdfont6x8.h"
|
||||
#endif
|
||||
|
||||
bool SH1106Display::i2c_probe(TwoWire &wire, uint8_t addr)
|
||||
{
|
||||
@@ -63,14 +66,23 @@ void SH1106Display::startFrame(ColorVal bkg)
|
||||
{
|
||||
display.clearDisplay(); // TODO: apply 'bkg'
|
||||
_color = SH110X_WHITE;
|
||||
#ifdef OLED_RU
|
||||
display.setFont(&glcdfont6x8);
|
||||
#endif
|
||||
display.setTextColor(_color);
|
||||
display.setTextSize(1);
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
#ifdef OLED_RU
|
||||
display.setCursor(0, 7);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SH1106Display::setTextSize(int sz)
|
||||
{
|
||||
display.setTextSize(sz);
|
||||
#ifdef OLED_RU
|
||||
_size = sz;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SH1106Display::setColor(ColorVal c)
|
||||
@@ -81,7 +93,11 @@ void SH1106Display::setColor(ColorVal c)
|
||||
|
||||
void SH1106Display::setCursor(int x, int y)
|
||||
{
|
||||
#ifdef OLED_RU
|
||||
display.setCursor(x, y + (_size * 7));
|
||||
#else
|
||||
display.setCursor(x, y);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SH1106Display::print(const char *str)
|
||||
|
||||
@@ -19,11 +19,19 @@ class SH1106Display : public DisplayDriver
|
||||
Adafruit_SH1106G display;
|
||||
bool _isOn;
|
||||
uint8_t _color;
|
||||
#ifdef OLED_RU
|
||||
uint8_t _size;
|
||||
#endif
|
||||
|
||||
bool i2c_probe(TwoWire &wire, uint8_t addr);
|
||||
|
||||
public:
|
||||
SH1106Display() : DisplayDriver(128, 64), display(128, 64, &Wire, PIN_OLED_RESET) { _isOn = false; }
|
||||
SH1106Display() : DisplayDriver(128, 64), display(128, 64, &Wire, PIN_OLED_RESET) {
|
||||
_isOn = false;
|
||||
#ifdef OLED_RU
|
||||
_size = 1; // setCursor() смещает текст на _size*7, без этого до первого setTextSize() в _size мусор
|
||||
#endif
|
||||
}
|
||||
bool begin();
|
||||
|
||||
bool isOn() override { return _isOn; }
|
||||
|
||||
@@ -31,6 +31,9 @@ public:
|
||||
_peripher_power(peripher_power)
|
||||
{
|
||||
_isOn = false;
|
||||
#ifdef OLED_RU
|
||||
_size = 1; // setCursor() смещает текст на _size*7, без этого до первого setTextSize() в _size мусор
|
||||
#endif
|
||||
}
|
||||
bool begin();
|
||||
|
||||
|
||||
@@ -156,6 +156,31 @@ lib_deps = ${Promicro.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:ProMicro_SH1106_companion_radio_ble]
|
||||
extends = Promicro
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags = ${Promicro.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D DISPLAY_CLASS=SH1106Display
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Promicro.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<helpers/ui/SH1106Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps = ${Promicro.lib_deps}
|
||||
adafruit/Adafruit SH110X @ ^2.1.13
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:ProMicro_companion_xiaowa_radio_ble]
|
||||
extends = Promicro
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
// драйвер выбирается по значению DISPLAY_CLASS (SSD1306Display / SH1106Display)
|
||||
#include <helpers/ui/DisplaySelect.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user