mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 19:15:49 +00:00
Merge branch 'ripplebiz:dev' into dev
This commit is contained in:
@@ -25,7 +25,8 @@ static const uint8_t meshcore_logo [] PROGMEM = {
|
||||
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8,
|
||||
};
|
||||
|
||||
void UITask::begin(const char* node_name, const char* build_date, uint32_t pin_code) {
|
||||
void UITask::begin(DisplayDriver* display, const char* node_name, const char* build_date, uint32_t pin_code) {
|
||||
_display = display;
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS;
|
||||
clearMsgPreview();
|
||||
_node_name = node_name;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <MeshCore.h>
|
||||
#include <helpers/ui/DisplayDriver.h>
|
||||
#include <stddef.h>
|
||||
|
||||
class UITask {
|
||||
DisplayDriver* _display;
|
||||
@@ -21,13 +22,14 @@ class UITask {
|
||||
|
||||
public:
|
||||
|
||||
UITask(mesh::MainBoard* board, DisplayDriver* display) : _board(board), _display(display){
|
||||
UITask(mesh::MainBoard* board) : _board(board), _display(NULL) {
|
||||
_next_refresh = 0;
|
||||
_connected = false;
|
||||
}
|
||||
void begin(const char* node_name, const char* build_date, uint32_t pin_code);
|
||||
void begin(DisplayDriver* display, const char* node_name, const char* build_date, uint32_t pin_code);
|
||||
|
||||
void setHasConnection(bool connected) { _connected = connected; }
|
||||
bool hasDisplay() const { return _display != NULL; }
|
||||
void clearMsgPreview();
|
||||
void msgRead(int msgcount);
|
||||
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount);
|
||||
|
||||
@@ -109,12 +109,13 @@
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
|
||||
static DISPLAY_CLASS display;
|
||||
static UITask ui_task(&board, &display);
|
||||
#define HAS_UI
|
||||
#elif defined(HAS_UI)
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UI)
|
||||
#include "UITask.h"
|
||||
|
||||
static UITask ui_task(&board, NULL);
|
||||
static UITask ui_task(&board);
|
||||
#endif
|
||||
|
||||
// Believe it or not, this std C function is busted on some platforms!
|
||||
@@ -719,7 +720,7 @@ public:
|
||||
//_prefs.rx_delay_base = 10.0f; enable once new algo fixed
|
||||
}
|
||||
|
||||
void begin(FILESYSTEM& fs, mesh::RNG& trng) {
|
||||
void begin(FILESYSTEM& fs, mesh::RNG& trng, bool has_display) {
|
||||
_fs = &fs;
|
||||
|
||||
BaseChatMesh::begin();
|
||||
@@ -770,8 +771,12 @@ public:
|
||||
|
||||
#ifdef BLE_PIN_CODE
|
||||
if (_prefs.ble_pin == 0) {
|
||||
#ifdef DISPLAY_CLASS
|
||||
_active_ble_pin = trng.nextInt(100000, 999999); // random pin each session
|
||||
#ifdef HAS_UI
|
||||
if (has_display) {
|
||||
_active_ble_pin = trng.nextInt(100000, 999999); // random pin each session
|
||||
} else {
|
||||
_active_ble_pin = BLE_PIN_CODE; // otherwise static pin
|
||||
}
|
||||
#else
|
||||
_active_ble_pin = BLE_PIN_CODE; // otherwise static pin
|
||||
#endif
|
||||
@@ -1432,9 +1437,24 @@ void setup() {
|
||||
|
||||
RadioNoiseListener trng(radio);
|
||||
|
||||
#ifdef HAS_UI
|
||||
DisplayDriver* disp = NULL;
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (display.begin()) {
|
||||
disp = &display;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
InternalFS.begin();
|
||||
the_mesh.begin(InternalFS, trng);
|
||||
the_mesh.begin(InternalFS, trng,
|
||||
#ifdef HAS_UI
|
||||
disp != NULL
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
);
|
||||
|
||||
#ifdef BLE_PIN_CODE
|
||||
char dev_name[32+16];
|
||||
@@ -1446,7 +1466,13 @@ void setup() {
|
||||
the_mesh.startInterface(serial_interface);
|
||||
#elif defined(ESP32)
|
||||
SPIFFS.begin(true);
|
||||
the_mesh.begin(SPIFFS, trng);
|
||||
the_mesh.begin(SPIFFS, trng,
|
||||
#ifdef HAS_UI
|
||||
disp != NULL
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
);
|
||||
|
||||
#ifdef WIFI_SSID
|
||||
WiFi.begin(WIFI_SSID, WIFI_PWD);
|
||||
@@ -1463,11 +1489,8 @@ void setup() {
|
||||
#error "need to define filesystem"
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
display.begin();
|
||||
#endif
|
||||
#ifdef HAS_UI
|
||||
ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE, the_mesh.getBLEPin());
|
||||
ui_task.begin(disp, the_mesh.getNodeName(), FIRMWARE_BUILD_DATE, the_mesh.getBLEPin());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#include "SSD1306Display.h"
|
||||
|
||||
bool SSD1306Display::i2c_probe(TwoWire& wire, uint8_t addr) {
|
||||
wire.beginTransmission(addr);
|
||||
uint8_t error = wire.endTransmission();
|
||||
return (error == 0);
|
||||
}
|
||||
|
||||
bool SSD1306Display::begin() {
|
||||
return display.begin(SSD1306_SWITCHCAPVCC, DISPLAY_ADDRESS, true, false);
|
||||
return display.begin(SSD1306_SWITCHCAPVCC, DISPLAY_ADDRESS, true, false) && i2c_probe(Wire, DISPLAY_ADDRESS);
|
||||
}
|
||||
|
||||
void SSD1306Display::turnOn() {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "DisplayDriver.h"
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#define SSD1306_NO_SPLASH
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#ifndef PIN_OLED_RESET
|
||||
@@ -18,6 +19,7 @@ class SSD1306Display : public DisplayDriver {
|
||||
bool _isOn;
|
||||
uint8_t _color;
|
||||
|
||||
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
||||
public:
|
||||
SSD1306Display() : DisplayDriver(128, 64), display(128, 64, &Wire, PIN_OLED_RESET) { _isOn = false; }
|
||||
bool begin();
|
||||
|
||||
Reference in New Issue
Block a user