mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* big refactor of the 'display' object. Now defined in variants/*/target modules.
This commit is contained in:
parent
bc4e0b52fa
commit
a73eb9823d
43 changed files with 210 additions and 58 deletions
|
|
@ -85,7 +85,7 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
|
|||
}
|
||||
}
|
||||
|
||||
void renderBatteryIndicator(DisplayDriver* _display, uint16_t batteryMilliVolts) {
|
||||
void UITask::renderBatteryIndicator(uint16_t batteryMilliVolts) {
|
||||
// Convert millivolts to percentage
|
||||
const int minMilliVolts = 3000; // Minimum voltage (e.g., 3.0V)
|
||||
const int maxMilliVolts = 4200; // Maximum voltage (e.g., 4.2V)
|
||||
|
|
@ -155,7 +155,7 @@ void UITask::renderCurrScreen() {
|
|||
_display->print(_node_prefs->node_name);
|
||||
|
||||
// battery voltage
|
||||
renderBatteryIndicator(_display, _board->getBattMilliVolts());
|
||||
renderBatteryIndicator(_board->getBattMilliVolts());
|
||||
|
||||
// freq / sf
|
||||
_display->setCursor(0, 20);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class UITask {
|
|||
void renderCurrScreen();
|
||||
void buttonHandler();
|
||||
void userLedHandler();
|
||||
void renderBatteryIndicator(uint16_t batteryMilliVolts);
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -60,30 +60,7 @@
|
|||
|
||||
#define PUBLIC_GROUP_PSK "izOH6cXN6mrJ5e26oRXNcg=="
|
||||
|
||||
#ifdef DISPLAY_CLASS // TODO: refactor this -- move to variants/*/target
|
||||
#include "UITask.h"
|
||||
#ifdef ST7735
|
||||
#include <helpers/ui/ST7735Display.h>
|
||||
#elif ST7789
|
||||
#include <helpers/ui/ST7789Display.h>
|
||||
#elif SH1106
|
||||
#include <helpers/ui/SH1106Display.h>
|
||||
#elif defined(HAS_GxEPD)
|
||||
#include <helpers/ui/GxEPDDisplay.h>
|
||||
#else
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#endif
|
||||
|
||||
#if defined(HELTEC_LORA_V3) && defined(ST7735)
|
||||
static DISPLAY_CLASS display(&board.periph_power); // peripheral power pin is shared
|
||||
#else
|
||||
static DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#define HAS_UI
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UI)
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include "UITask.h"
|
||||
|
||||
static UITask ui_task(&board);
|
||||
|
|
@ -609,7 +586,7 @@ protected:
|
|||
} else {
|
||||
soundBuzzer();
|
||||
}
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.newMsg(path_len, from.name, text, offline_queue_len);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -660,7 +637,7 @@ protected:
|
|||
} else {
|
||||
soundBuzzer();
|
||||
}
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.newMsg(path_len, "Public", text, offline_queue_len);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -895,7 +872,7 @@ public:
|
|||
|
||||
#ifdef BLE_PIN_CODE
|
||||
if (_prefs.ble_pin == 0) {
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (has_display) {
|
||||
StdRNG rng;
|
||||
_active_ble_pin = rng.nextInt(100000, 999999); // random pin each session
|
||||
|
|
@ -1244,7 +1221,7 @@ public:
|
|||
int out_len;
|
||||
if ((out_len = getFromOfflineQueue(out_frame)) > 0) {
|
||||
_serial->writeFrame(out_frame, out_len);
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.msgRead(offline_queue_len);
|
||||
#endif
|
||||
} else {
|
||||
|
|
@ -1572,7 +1549,7 @@ public:
|
|||
checkConnections();
|
||||
}
|
||||
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.setHasConnection(_serial->isConnected());
|
||||
ui_task.loop();
|
||||
#endif
|
||||
|
|
@ -1643,16 +1620,14 @@ void setup() {
|
|||
|
||||
board.begin();
|
||||
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
DisplayDriver* disp = NULL;
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (display.begin()) {
|
||||
disp = &display;
|
||||
disp->startFrame();
|
||||
disp->print("Please wait...");
|
||||
disp->endFrame();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!radio_init()) { halt(); }
|
||||
|
|
@ -1662,7 +1637,7 @@ void setup() {
|
|||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
InternalFS.begin();
|
||||
the_mesh.begin(InternalFS,
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
disp != NULL
|
||||
#else
|
||||
false
|
||||
|
|
@ -1680,7 +1655,7 @@ void setup() {
|
|||
#elif defined(RP2040_PLATFORM)
|
||||
LittleFS.begin();
|
||||
the_mesh.begin(LittleFS,
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
disp != NULL
|
||||
#else
|
||||
false
|
||||
|
|
@ -1705,7 +1680,7 @@ void setup() {
|
|||
#elif defined(ESP32)
|
||||
SPIFFS.begin(true);
|
||||
the_mesh.begin(SPIFFS,
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
disp != NULL
|
||||
#else
|
||||
false
|
||||
|
|
@ -1733,7 +1708,7 @@ void setup() {
|
|||
|
||||
sensors.begin();
|
||||
|
||||
#ifdef HAS_UI
|
||||
#ifdef DISPLAY_CLASS
|
||||
ui_task.begin(disp, the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION, the_mesh.getBLEPin());
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,10 +60,6 @@
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
|
||||
static DISPLAY_CLASS display;
|
||||
|
||||
#include "UITask.h"
|
||||
static UITask ui_task(display);
|
||||
#endif
|
||||
|
|
@ -735,7 +731,7 @@ void setup() {
|
|||
board.begin();
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
if(display.begin()){
|
||||
if (display.begin()) {
|
||||
display.startFrame();
|
||||
display.print("Please wait...");
|
||||
display.endFrame();
|
||||
|
|
|
|||
|
|
@ -68,10 +68,6 @@
|
|||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
|
||||
static DISPLAY_CLASS display;
|
||||
|
||||
#include "UITask.h"
|
||||
static UITask ui_task(display);
|
||||
#endif
|
||||
|
|
@ -909,7 +905,7 @@ void setup() {
|
|||
board.begin();
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
if(display.begin()){
|
||||
if (display.begin()) {
|
||||
display.startFrame();
|
||||
display.print("Please wait...");
|
||||
display.endFrame();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue