From fa077d1cd86b2476bf1cac52663bd8615da3fd94 Mon Sep 17 00:00:00 2001 From: Ev Lbibass Date: Tue, 7 Apr 2026 05:55:48 -0400 Subject: [PATCH] display is working now --- src/helpers/ui/SH1107Display.cpp | 12 +++++- src/helpers/ui/SH1107Display.h | 5 ++- variants/muzi_base_duo/muzi_base_duoBoard.cpp | 20 +++++++--- variants/muzi_base_duo/platformio.ini | 38 +++++++++++++++++++ variants/muzi_base_duo/target.cpp | 19 +++++++--- variants/muzi_base_duo/target.h | 17 ++++++--- variants/muzi_base_duo/variant.cpp | 8 ++-- variants/muzi_base_duo/variant.h | 9 +++-- 8 files changed, 101 insertions(+), 27 deletions(-) diff --git a/src/helpers/ui/SH1107Display.cpp b/src/helpers/ui/SH1107Display.cpp index 01cccc2f..de084198 100644 --- a/src/helpers/ui/SH1107Display.cpp +++ b/src/helpers/ui/SH1107Display.cpp @@ -2,6 +2,10 @@ #include #include "Adafruit_SH110X.h" +#ifndef DISPLAY_ROTATION +#define DISPLAY_ROTATION 0 +#endif + bool SH1107Display::i2c_probe(TwoWire &wire, uint8_t addr) { wire.beginTransmission(addr); @@ -11,7 +15,11 @@ bool SH1107Display::i2c_probe(TwoWire &wire, uint8_t addr) bool SH1107Display::begin() { - return display.begin(DISPLAY_ADDRESS, true) && i2c_probe(Wire, DISPLAY_ADDRESS); + bool result = display.begin(DISPLAY_ADDRESS, true) && i2c_probe(Wire, DISPLAY_ADDRESS); + if (result) { + display.setRotation(DISPLAY_ROTATION); + } + return result; } void SH1107Display::turnOn() @@ -35,6 +43,8 @@ void SH1107Display::clear() void SH1107Display::startFrame(Color bkg) { display.clearDisplay(); // TODO: apply 'bkg' + display.setContrast(300); // 0-255. default setting was causing some flickering. + // display.SH110X_SETPRECHARGE(255); _color = SH110X_WHITE; display.setTextColor(_color); display.setTextSize(1); diff --git a/src/helpers/ui/SH1107Display.h b/src/helpers/ui/SH1107Display.h index 6c6b7247..b9c2a76b 100644 --- a/src/helpers/ui/SH1107Display.h +++ b/src/helpers/ui/SH1107Display.h @@ -11,14 +11,15 @@ #ifndef PIN_OLED_12V_EN #define PIN_OLED_12V_EN -1 #endif +#endif #ifndef DISPLAY_ADDRESS -#define DISPLAY_ADDRESS 0x3D +#define DISPLAY_ADDRESS 0x3c #endif class SH1107Display : public DisplayDriver { - Adafruit_SH1107G display; + Adafruit_SH1107 display; bool _isOn; uint8_t _color; diff --git a/variants/muzi_base_duo/muzi_base_duoBoard.cpp b/variants/muzi_base_duo/muzi_base_duoBoard.cpp index c7aacee3..13213bcf 100644 --- a/variants/muzi_base_duo/muzi_base_duoBoard.cpp +++ b/variants/muzi_base_duo/muzi_base_duoBoard.cpp @@ -23,18 +23,28 @@ void muzi_base_duoBoard::initiateShutdown(uint8_t reason) { void muzi_base_duoBoard::begin() { NRF52BoardDCDC::begin(); - pinMode(PIN_VBAT_READ, INPUT); + pinMode(SCREEN_12V_ENABLE, OUTPUT); + digitalWrite(SCREEN_12V_ENABLE, HIGH); // Enable 12V power for SH1107 display + delay(250); + Wire.begin(); + // delay(1000); // wait for display to initialize. otherwise it doesn't come up on boot. #ifdef PIN_USER_BTN pinMode(PIN_USER_BTN, INPUT_PULLUP); #endif + pinMode(PIN_BUTTON1, INPUT_PULLUP); + pinMode(PIN_BUTTON2, INPUT_PULLUP); + pinMode(PIN_BUTTON3, INPUT_PULLUP); + pinMode(PIN_BUTTON4, INPUT_PULLUP); + pinMode(PIN_BUTTON5, INPUT_PULLUP); + pinMode(PIN_BUTTON6, INPUT_PULLUP); -#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL) - Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL); -#endif +// #if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL) +// Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL); +// #endif #ifdef NRF52_POWER_MANAGEMENT checkBootVoltage(&power_config); #endif - delay(10); // give sx1262 some time to power up + // delay(10); // give LR1121 some time to power up } \ No newline at end of file diff --git a/variants/muzi_base_duo/platformio.ini b/variants/muzi_base_duo/platformio.ini index 5c2d4e82..818d27cc 100644 --- a/variants/muzi_base_duo/platformio.ini +++ b/variants/muzi_base_duo/platformio.ini @@ -117,3 +117,41 @@ lib_deps = ${muzi_base_duo.lib_deps} densaugeo/base64 @ ~1.4.0 ; stevemarple/MicroNMEA @ ^2.0.6 end2endzone/NonBlockingRTTTL@^1.3.0 +[env:muzi_base_duo_companion_radio_ble_superIO] +extends = muzi_base_duo +board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld +board_upload.maximum_size = 708608 +build_flags = ${muzi_base_duo.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 + -D BLE_PIN_CODE=123456 + -D BLE_TX_POWER=0 + -D QSPIFLASH=1 + -D UI_HAS_JOYSTICK=1 +; -D BLE_DEBUG_LOGGING=1 +; -D MESH_PACKET_LOGGING=1 + ; -D MESH_DEBUG=1 + -D OFFLINE_QUEUE_SIZE=256 + -D DISPLAY_CLASS=SH1107Display + -D DISPLAY_ROTATION=2 + ; -D ADVERT_NAME='"@@MAC"' + -D ENV_INCLUDE_GPS=1 + ; -D PIN_BUZZER=22 +build_src_filter = ${muzi_base_duo.build_src_filter} + + + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> + + + + + + + +lib_deps = ${muzi_base_duo.lib_deps} + densaugeo/base64 @ ~1.4.0 + stevemarple/MicroNMEA @ ^2.0.6 + end2endzone/NonBlockingRTTTL@^1.3.0 + adafruit/Adafruit SH110X@^2.1.14 + artronshop/ArtronShop_RX8130CE@1.0.0 + adafruit/Adafruit GFX Library @ ^1.12.1 + diff --git a/variants/muzi_base_duo/target.cpp b/variants/muzi_base_duo/target.cpp index c0521a73..c5891303 100644 --- a/variants/muzi_base_duo/target.cpp +++ b/variants/muzi_base_duo/target.cpp @@ -1,7 +1,6 @@ #include #include "target.h" #include "variant.h" -// #include muzi_base_duoBoard board; @@ -9,12 +8,22 @@ RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BU WRAPPER_CLASS radio_driver(radio, board); -VolatileRTCClock rtc_clock; -// MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock); +VolatileRTCClock fallback_clock; +AutoDiscoverRTCClock rtc_clock(fallback_clock); +#if ENV_INCLUDE_GPS + #include + MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock); + EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea); +#else + EnvironmentSensorManager sensors; +#endif -EnvironmentSensorManager sensors; // only enable environment sensors. GPS is disabled. #ifdef DISPLAY_CLASS - NullDisplayDriver display; + DISPLAY_CLASS display; + MomentaryButton user_btn(PIN_USER_BTN, 1000, true, false, false); + MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false); + MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false); + MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, true); #endif #ifndef LORA_CR diff --git a/variants/muzi_base_duo/target.h b/variants/muzi_base_duo/target.h index babaaafb..053c23b9 100644 --- a/variants/muzi_base_duo/target.h +++ b/variants/muzi_base_duo/target.h @@ -8,19 +8,24 @@ #include #include #include +#include #include // Added: Include for EnvironmentSensorManager -#ifdef DISPLAY_CLASS - #include "NullDisplayDriver.h" -#endif - #ifdef DISPLAY_CLASS - extern NullDisplayDriver display; + #include + extern DISPLAY_CLASS display; + #include + extern MomentaryButton user_btn; + extern MomentaryButton joystick_left; + extern MomentaryButton joystick_right; + extern MomentaryButton joystick_up; + extern MomentaryButton joystick_down; + extern MomentaryButton back_btn; #endif extern muzi_base_duoBoard board; extern WRAPPER_CLASS radio_driver; -extern VolatileRTCClock rtc_clock; +extern AutoDiscoverRTCClock rtc_clock; extern EnvironmentSensorManager sensors; bool radio_init(); diff --git a/variants/muzi_base_duo/variant.cpp b/variants/muzi_base_duo/variant.cpp index e6293b40..ad24c6f3 100644 --- a/variants/muzi_base_duo/variant.cpp +++ b/variants/muzi_base_duo/variant.cpp @@ -81,9 +81,9 @@ void initVariant() digitalWrite(LED_BLUE, LOW); pinMode(BUZZER_PIN, OUTPUT); digitalWrite(BUZZER_PIN, LOW); // turn off buzzer at start. don't leave it high. - pinMode(GPS_EN, OUTPUT); - digitalWrite(GPS_EN, LOW); // lets turn off the GPS at start. we can turn it on when we need it. + pinMode(GPS_EN_GPIO, OUTPUT); + digitalWrite(GPS_EN_GPIO, HIGH); // needs to turn on for GPS detection pinMode(SCREEN_12V_ENABLE, OUTPUT); - digitalWrite(SCREEN_12V_ENABLE, LOW); // -} + digitalWrite(SCREEN_12V_ENABLE, LOW); // disable 12V power for SH1107 display for now. +} \ No newline at end of file diff --git a/variants/muzi_base_duo/variant.h b/variants/muzi_base_duo/variant.h index 4e60e372..22fcde49 100644 --- a/variants/muzi_base_duo/variant.h +++ b/variants/muzi_base_duo/variant.h @@ -67,6 +67,7 @@ static const uint8_t AREF = (PIN_AREF); // not used #define PIN_WIRE1_SCL (6) // P0.6 #define PIN_WIRE_SDA (24) // P0.24 OLED I2C #define PIN_WIRE_SCL (25) // P0.25 OLED I2C +#define I2C_NO_RESCAN // #define I2C_NO_RESCAN // #define HAS_QMA6100P // #define QMA_6100P_INT_PIN (34) // P1.2 @@ -134,10 +135,10 @@ static const uint8_t AREF = (PIN_AREF); // not used //////////////////////////////////////////////////////////////////////////////// // GPS -// #define HAS_GPS 1 -#define GPS_RX_PIN PIN_SERIAL1_RX -#define GPS_TX_PIN PIN_SERIAL1_TX -#define GPS_EN (32+1) // P1.01 PWR_IO2 on schematic. just cuts power to gps. +#define HAS_GPS 1 +#define PIN_GPS_RX PIN_SERIAL1_RX +#define PIN_GPS_TX PIN_SERIAL1_TX +#define GPS_EN_GPIO (32+1) // P1.01 PWR_IO2 on schematic. just cuts power to gps. //////////////////////////////////////////////////////////////////////////////// // Buzzer