From d1cd686644b2c36b8c51276ab51c72e1b49003f4 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 15 Apr 2024 17:24:08 +0100 Subject: [PATCH 01/19] Fixed XPT2046 syntax and using unPhone library to clean up main and TFTDisplay. --- src/graphics/TFTDisplay.cpp | 48 ++++++++++++--------------------- src/main.cpp | 16 +---------- variants/unphone/platformio.ini | 15 +++++++++-- variants/unphone/variant.cpp | 20 ++++++++++++++ variants/unphone/variant.h | 14 +++++++--- 5 files changed, 62 insertions(+), 51 deletions(-) create mode 100644 variants/unphone/variant.cpp diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index fb64553ef..ddc4df2b3 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -411,8 +411,7 @@ class LGFX : public lgfx::LGFX_Device lgfx::Panel_HX8357D _panel_instance; lgfx::Bus_SPI _bus_instance; #if defined(USE_XPT2046) - lgfx::ITouch *_touch_instance; -// lgfx::Touch_XPT2046 _touch_instance; + lgfx::Touch_XPT2046 _touch_instance; #endif public: @@ -466,8 +465,7 @@ class LGFX : public lgfx::LGFX_Device #if defined(USE_XPT2046) { // Configure settings for touch control. - _touch_instance = new lgfx::Touch_XPT2046; - auto touch_cfg = _touch_instance->config(); + auto touch_cfg = _touch_instance.config(); touch_cfg.pin_cs = TOUCH_CS; touch_cfg.x_min = 0; @@ -478,8 +476,8 @@ class LGFX : public lgfx::LGFX_Device touch_cfg.bus_shared = true; touch_cfg.offset_rotation = 1; - _touch_instance->config(touch_cfg); - //_panel_instance->setTouch(_touch_instance); + _touch_instance.config(touch_cfg); + _panel_instance.setTouch(&_touch_instance); } #endif setPanel(&_panel_instance); @@ -496,6 +494,11 @@ static LGFX *tft = nullptr; #include "TFTDisplay.h" #include +#ifdef UNPHONE +#include "unPhone.h" +extern unPhone unphone; +#endif + TFTDisplay::TFTDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY geometry, HW_I2C i2cBus) { LOG_DEBUG("TFTDisplay!\n"); @@ -561,10 +564,8 @@ void TFTDisplay::sendCommand(uint8_t com) #elif defined(ST7735_BL_V05) pinMode(ST7735_BL_V05, OUTPUT); digitalWrite(ST7735_BL_V05, TFT_BACKLIGHT_ON); -#elif !defined(RAK14014) && !defined(M5STACK) && !defined(UNPHONE) - tft->wakeup(); - tft->powerSaveOff(); -#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) +#endif +#if defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); #endif @@ -576,11 +577,7 @@ void TFTDisplay::sendCommand(uint8_t com) digitalWrite(VTFT_CTRL, LOW); #endif #ifdef UNPHONE - Wire.beginTransmission(0x26); - Wire.write(0x02); - Wire.write(0x04); // Backlight on - Wire.write(0x22); // G&B LEDs off - Wire.endTransmission(); + unphone.backlight(true); // using unPhone library #endif #ifdef RAK14014 #elif !defined(M5STACK) @@ -598,13 +595,10 @@ void TFTDisplay::sendCommand(uint8_t com) #elif defined(ST7735_BL_V05) pinMode(ST7735_BL_V05, OUTPUT); digitalWrite(ST7735_BL_V05, !TFT_BACKLIGHT_ON); -#elif !defined(RAK14014) && !defined(M5STACK) && !defined(UNPHONE) - tft->sleep(); - tft->powerSaveOn(); -#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) +#endif +#if defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) digitalWrite(TFT_BL, !TFT_BACKLIGHT_ON); #endif - #ifdef VTFT_CTRL_V03 digitalWrite(VTFT_CTRL_V03, HIGH); #endif @@ -612,11 +606,7 @@ void TFTDisplay::sendCommand(uint8_t com) digitalWrite(VTFT_CTRL, HIGH); #endif #ifdef UNPHONE - Wire.beginTransmission(0x26); - Wire.write(0x02); - Wire.write(0x00); // Backlight off - Wire.write(0x22); // G&B LEDs off - Wire.endTransmission(); + unphone.backlight(false); // using unPhone library #endif #ifdef RAK14014 #elif !defined(M5STACK) @@ -690,11 +680,7 @@ bool TFTDisplay::connect() digitalWrite(ST7735_BL_V05, TFT_BACKLIGHT_ON); #endif #ifdef UNPHONE - Wire.beginTransmission(0x26); - Wire.write(0x02); - Wire.write(0x04); // Backlight on - Wire.write(0x22); // G&B LEDs off - Wire.endTransmission(); + unphone.backlight(true); // using unPhone library LOG_INFO("Power to TFT Backlight\n"); #endif @@ -718,4 +704,4 @@ bool TFTDisplay::connect() return true; } -#endif +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 587bcb56e..744fda4de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -590,20 +590,6 @@ void setup() if (config.display.oled != meshtastic_Config_DisplayConfig_OledType_OLED_AUTO) screen_model = config.display.oled; -#ifdef UNPHONE - // initialise IO expander with pinmodes - Wire.beginTransmission(0x26); - Wire.write(0x06); - Wire.write(0x7A); - Wire.write(0xDD); - Wire.endTransmission(); - Wire.beginTransmission(0x26); - Wire.write(0x02); - Wire.write(0x04); // Backlight on - Wire.write(0x22); // G&B LEDs off - Wire.endTransmission(); -#endif - #if defined(USE_SH1107) screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // set dimension of 128x128 display_geometry = GEOMETRY_128_128; @@ -1017,4 +1003,4 @@ void loop() mainDelay.delay(delayMsec); } // if (didWake) LOG_DEBUG("wake!\n"); -} +} \ No newline at end of file diff --git a/variants/unphone/platformio.ini b/variants/unphone/platformio.ini index 06314eaa3..dad9a7177 100644 --- a/variants/unphone/platformio.ini +++ b/variants/unphone/platformio.ini @@ -1,5 +1,7 @@ +; platformio.ini for unphone meshtastic + [env:unphone] -;build_type = debug ; to make it possible to step through our jtag debugger + extends = esp32s3_base board_level = extra board = unphone9 @@ -14,6 +16,15 @@ build_flags = ${esp32_base.build_flags} -D UNPHONE -I variants/unphone -D ARDUINO_USB_MODE=0 + -D UNPHONE_ACCEL=0 + -D UNPHONE_TOUCHS=0 + -D UNPHONE_SDCARD=0 + -D UNPHONE_UI0=0 + -D UNPHONE_LORA=0 + -D UNPHONE_FACTORY_MODE=0 + +build_src_filter = ${esp32_base.build_src_filter} +<../variants/unphone> lib_deps = ${esp32s3_base.lib_deps} - lovyan03/LovyanGFX@^1.1.8 \ No newline at end of file + lovyan03/LovyanGFX @ ^1.1.8 + https://gitlab.com/hamishcunningham/unphonelibrary#meshtastic @ ^9.0.0 \ No newline at end of file diff --git a/variants/unphone/variant.cpp b/variants/unphone/variant.cpp new file mode 100644 index 000000000..3f6d1c54d --- /dev/null +++ b/variants/unphone/variant.cpp @@ -0,0 +1,20 @@ +// meshtastic/firmware/variants/unphone/variant.cpp + +#include "unPhone.h" +unPhone unphone = unPhone("meshtastic_unphone"); + +void initVariant() +{ + unphone.begin(); // initialise hardware etc. + unphone.store(unphone.buildTime); + unphone.printWakeupReason(); // what woke us up? (stored, not printed :|) + unphone.checkPowerSwitch(); // if power switch is off, shutdown + unphone.backlight(false); // setup backlight and make sure its off + + for (int i = 0; i < 3; i++) { // buzz a bit + unphone.vibe(true); + delay(150); + unphone.vibe(false); + delay(150); + } +} \ No newline at end of file diff --git a/variants/unphone/variant.h b/variants/unphone/variant.h index 9306537f2..180fdfe2c 100644 --- a/variants/unphone/variant.h +++ b/variants/unphone/variant.h @@ -1,3 +1,7 @@ +// meshtastic/firmware/variants/unphone/variant.h + +#pragma once + #define SPI_SCK 39 #define SPI_MOSI 40 #define SPI_MISO 41 @@ -28,7 +32,7 @@ #define TFT_WIDTH 320 #define TFT_OFFSET_X 0 #define TFT_OFFSET_Y 0 -#define TFT_OFFSET_ROTATION 6 // the unPhone's screen is wired unusually, 0 is typical value here +#define TFT_OFFSET_ROTATION 6 // unPhone's screen wired unusually, 0 typical #define TFT_INVERT false #define SCREEN_ROTATE true #define SCREEN_TRANSITION_FRAMERATE 5 @@ -37,7 +41,10 @@ #define USE_XPT2046 1 #define TOUCH_CS 38 -#define HAS_GPS 0 // the unphone doesn't have a gps module +#define HAS_GPS \ + 0 // the unphone doesn't have a gps module by default (though + // GPS featherwing -- https://www.adafruit.com/product/3133 + // -- can be added) #undef GPS_RX_PIN #undef GPS_TX_PIN @@ -49,6 +56,7 @@ #define BUTTON_PIN 21 // Button 3 - square - top button in landscape mode #define BUTTON_NEED_PULLUP // we do need a helping hand up +#define BUTTON_PIN_ALT 45 // Button 1 - triangle - bottom button in landscape mode #define I2C_SDA 3 // I2C pins for this board #define I2C_SCL 4 @@ -58,6 +66,6 @@ // ratio of voltage divider = 3.20 (R1=100k, R2=220k) // #define ADC_MULTIPLIER 3.2 -// #define BATTERY_PIN 13 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +// #define BATTERY_PIN 13 // battery V measurement pin; vbat divider is here // #define ADC_CHANNEL ADC2_GPIO13_CHANNEL // #define BAT_MEASURE_ADC_UNIT 2 \ No newline at end of file From 385d7296fee2ee4a0ad2260dbe44591cf3836381 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 15 Apr 2024 17:37:39 +0100 Subject: [PATCH 02/19] strange extra edits removed wtf --- src/graphics/TFTDisplay.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index ddc4df2b3..b561f3b56 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -564,8 +564,10 @@ void TFTDisplay::sendCommand(uint8_t com) #elif defined(ST7735_BL_V05) pinMode(ST7735_BL_V05, OUTPUT); digitalWrite(ST7735_BL_V05, TFT_BACKLIGHT_ON); -#endif -#if defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) +#elif !defined(RAK14014) && !defined(M5STACK) && !defined(UNPHONE) + tft->wakeup(); + tft->powerSaveOff(); +#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); #endif @@ -595,10 +597,13 @@ void TFTDisplay::sendCommand(uint8_t com) #elif defined(ST7735_BL_V05) pinMode(ST7735_BL_V05, OUTPUT); digitalWrite(ST7735_BL_V05, !TFT_BACKLIGHT_ON); -#endif -#if defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) +#elif !defined(RAK14014) && !defined(M5STACK) && !defined(UNPHONE) + tft->sleep(); + tft->powerSaveOn(); +#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) digitalWrite(TFT_BL, !TFT_BACKLIGHT_ON); #endif + #ifdef VTFT_CTRL_V03 digitalWrite(VTFT_CTRL_V03, HIGH); #endif @@ -704,4 +709,4 @@ bool TFTDisplay::connect() return true; } -#endif \ No newline at end of file +#endif From 8a3322fbcbb470df00e71dbe0b861241e860a29f Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Tue, 16 Apr 2024 21:28:12 +0100 Subject: [PATCH 03/19] rgb led support for unPhone --- src/AmbientLightingThread.h | 25 ++++++++++-- src/detect/ScanI2C.h | 3 +- src/main.cpp | 20 +++++++++- src/modules/ExternalNotificationModule.cpp | 45 +++++++++++++++++++++- 4 files changed, 86 insertions(+), 7 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index 98ccedde4..fd3c66cda 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -5,6 +5,11 @@ NCP5623 rgb; #endif +#ifdef UNPHONE +#include "unPhone.h" +extern unPhone unphone; +#endif + namespace concurrency { class AmbientLightingThread : public concurrency::OSThread @@ -20,8 +25,8 @@ class AmbientLightingThread : public concurrency::OSThread // moduleConfig.ambient_lighting.green = (myNodeInfo.my_node_num & 0x00FF00) >> 8; // moduleConfig.ambient_lighting.blue = myNodeInfo.my_node_num & 0x0000FF; -#ifdef HAS_NCP5623 _type = type; +#ifdef HAS_NCP5623 if (_type == ScanI2C::DeviceType::NONE) { LOG_DEBUG("AmbientLightingThread disabling due to no RGB leds found on I2C bus\n"); disable(); @@ -37,14 +42,23 @@ class AmbientLightingThread : public concurrency::OSThread rgb.begin(); setLighting(); } +#endif +#ifdef UNPHONE + if (!moduleConfig.ambient_lighting.led_state) { + LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); + disable(); + return; + } + LOG_DEBUG("AmbientLightingThread initializing\n"); + setLighting(); #endif } protected: int32_t runOnce() override { -#ifdef HAS_NCP5623 - if (_type == ScanI2C::NCP5623 && moduleConfig.ambient_lighting.led_state) { +#if defined(HAS_NCP5623) || defined(UNPHONE) + if ((_type == ScanI2C::NCP5623 || _type == ScanI2C::RGBLED_CA) && moduleConfig.ambient_lighting.led_state) { setLighting(); return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification } else { @@ -68,6 +82,11 @@ class AmbientLightingThread : public concurrency::OSThread LOG_DEBUG("Initializing Ambient lighting w/ current=%d, red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); +#endif +#ifdef UNPHONE + unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); + LOG_DEBUG("Initializing Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, + moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); #endif } }; diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index c8fcfee10..b4341bcc0 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,9 +41,8 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, -#ifdef HAS_NCP5623 + RGBLED_CA, NCP5623, -#endif } DeviceType; // typedef uint8_t DeviceAddress; diff --git a/src/main.cpp b/src/main.cpp index 744fda4de..4b3212f5f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -494,11 +494,15 @@ void setup() * "found". */ -// Only one supported RGB LED currently +// Only one supported I2C RGB LED currently (plus common anode RGB LED used by the unPhone) #ifdef HAS_NCP5623 rgb_found = i2cScanner->find(ScanI2C::DeviceType::NCP5623); #endif +#ifdef UNPHONE + rgb_found.type = ScanI2C::DeviceType::RGBLED_CA; +#endif + #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) auto acc_info = i2cScanner->firstAccelerometer(); accelerometer_found = acc_info.type != ScanI2C::DeviceType::NONE ? acc_info.address : accelerometer_found; @@ -590,6 +594,20 @@ void setup() if (config.display.oled != meshtastic_Config_DisplayConfig_OledType_OLED_AUTO) screen_model = config.display.oled; +#ifdef UNPHONE + // initialise IO expander with pinmodes + Wire.beginTransmission(0x26); + Wire.write(0x06); + Wire.write(0x7A); + Wire.write(0xDD); + Wire.endTransmission(); + Wire.beginTransmission(0x26); + Wire.write(0x02); + Wire.write(0x04); // Backlight on + Wire.write(0x22); // G&B LEDs off + Wire.endTransmission(); +#endif + #if defined(USE_SH1107) screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // set dimension of 128x128 display_geometry = GEOMETRY_128_128; diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index a38b231af..be8fd2be2 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -36,6 +36,18 @@ uint8_t brightnessValues[] = {0, 10, 20, 30, 50, 90, 160, 170}; // blue gets mul bool ascending = true; #endif +#ifdef UNPHONE +#include "unPhone.h" +extern unPhone unphone; + +uint8_t red = 0; +uint8_t green = 0; +uint8_t blue = 0; +uint8_t colorState = 1; +const uint8_t duration = 15; +uint8_t counter = 0; +#endif + #ifndef PIN_BUZZER #define PIN_BUZZER false #endif @@ -72,7 +84,6 @@ int32_t ExternalNotificationModule::runOnce() if (!moduleConfig.external_notification.enabled) { return INT32_MAX; // we don't need this thread here... } else { - bool isPlaying = rtttl::isPlaying(); #ifdef HAS_I2S isPlaying = rtttl::isPlaying() || audioThread->isPlaying(); @@ -133,6 +144,25 @@ int32_t ExternalNotificationModule::runOnce() } #endif +#ifdef UNPHONE + if (rgb_found.type == ScanI2C::RGBLED_CA) { + red = colorState & 4; // Red enabled on colorState = 4,5,6,7 + green = colorState & 2; // Green enabled on colorState = 2,3,6,7 + blue = colorState & 1; // Blue enabled on colorState = 1,3,5,7 + unphone.rgb(red, green, blue); + LOG_DEBUG("RGB runOnce: %i, %i, %i\n", red, green, blue); + + counter++; // tick on + if (counter > duration) { + counter = 0; + colorState++; // next color + if (colorState > 7) { + colorState = 1; + } + } + } +#endif + #ifdef T_WATCH_S3 drv.go(); #endif @@ -197,6 +227,11 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) rgb.setColor(red, green, blue); } #endif +#ifdef UNPHONE + if (rgb_found.type == ScanI2C::RGBLED_CA) { + unphone.rgb(red, green, blue); + } +#endif #ifdef T_WATCH_S3 drv.go(); #endif @@ -230,6 +265,14 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) rgb.setColor(red, green, blue); } #endif +#ifdef UNPHONE + if (rgb_found.type == ScanI2C::RGBLED_CA) { + red = 0; + green = 0; + blue = 0; + unphone.rgb(red, green, blue); + } +#endif #ifdef T_WATCH_S3 drv.stop(); #endif From 0632b96fcbeda61f4b21d236c4047429e7057a58 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Tue, 16 Apr 2024 21:40:13 +0100 Subject: [PATCH 04/19] just tiny tweak to minimise changes --- src/modules/ExternalNotificationModule.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index be8fd2be2..304b93389 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -84,7 +84,10 @@ int32_t ExternalNotificationModule::runOnce() if (!moduleConfig.external_notification.enabled) { return INT32_MAX; // we don't need this thread here... } else { - bool isPlaying = rtttl::isPlaying(); + + bool isPlaying = rtttl::isPlaying();This PR just tidies up support for the unPhone by using its [library](https://gitlab.com/hamishcunningham/unphonelibrary) + +Also fixes incomplete syntax for the touchscreen driver invocation for XPT2046 when attached to a HX8357. #ifdef HAS_I2S isPlaying = rtttl::isPlaying() || audioThread->isPlaying(); #endif @@ -551,4 +554,4 @@ void ExternalNotificationModule::handleSetRingtone(const char *from_msg) if (changed) { nodeDB->saveProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, &meshtastic_RTTTLConfig_msg, &rtttlConfig); } -} \ No newline at end of file +} From afb4de21d9331a435281766b02af3c07080cee0a Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Tue, 16 Apr 2024 22:37:57 +0100 Subject: [PATCH 05/19] yet another random edit, think i'm brushing the touchpad or perhaps my computer is possessed by the devil determined to make me look foolish --- src/modules/ExternalNotificationModule.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 304b93389..be8fd2be2 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -84,10 +84,7 @@ int32_t ExternalNotificationModule::runOnce() if (!moduleConfig.external_notification.enabled) { return INT32_MAX; // we don't need this thread here... } else { - - bool isPlaying = rtttl::isPlaying();This PR just tidies up support for the unPhone by using its [library](https://gitlab.com/hamishcunningham/unphonelibrary) - -Also fixes incomplete syntax for the touchscreen driver invocation for XPT2046 when attached to a HX8357. + bool isPlaying = rtttl::isPlaying(); #ifdef HAS_I2S isPlaying = rtttl::isPlaying() || audioThread->isPlaying(); #endif @@ -554,4 +551,4 @@ void ExternalNotificationModule::handleSetRingtone(const char *from_msg) if (changed) { nodeDB->saveProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, &meshtastic_RTTTLConfig_msg, &rtttlConfig); } -} +} \ No newline at end of file From 4b5549be8fa48cfe80a7de77ac6f9099fea7915b Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Thu, 18 Apr 2024 09:22:31 +0100 Subject: [PATCH 06/19] added vibration notifications --- src/modules/ExternalNotificationModule.cpp | 44 +++++++++++----------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index be8fd2be2..d7997b849 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -145,20 +145,16 @@ int32_t ExternalNotificationModule::runOnce() #endif #ifdef UNPHONE - if (rgb_found.type == ScanI2C::RGBLED_CA) { - red = colorState & 4; // Red enabled on colorState = 4,5,6,7 - green = colorState & 2; // Green enabled on colorState = 2,3,6,7 - blue = colorState & 1; // Blue enabled on colorState = 1,3,5,7 - unphone.rgb(red, green, blue); - LOG_DEBUG("RGB runOnce: %i, %i, %i\n", red, green, blue); - - counter++; // tick on - if (counter > duration) { - counter = 0; - colorState++; // next color - if (colorState > 7) { - colorState = 1; - } + red = colorState & 4; // Red enabled on colorState = 4,5,6,7 + green = colorState & 2; // Green enabled on colorState = 2,3,6,7 + blue = colorState & 1; // Blue enabled on colorState = 1,3,5,7 + unphone.rgb(red, green, blue); + counter++; // tick on + if (counter > duration) { + counter = 0; + colorState++; // next color + if (colorState > 7) { + colorState = 1; } } #endif @@ -209,6 +205,9 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) switch (index) { case 1: +#ifdef UNPHONE + unphone.vibe(true); // the unPhone's vibration motor is on a i2c GPIO expander +#endif if (moduleConfig.external_notification.output_vibra) digitalWrite(moduleConfig.external_notification.output_vibra, true); break; @@ -228,9 +227,7 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) } #endif #ifdef UNPHONE - if (rgb_found.type == ScanI2C::RGBLED_CA) { - unphone.rgb(red, green, blue); - } + unphone.rgb(red, green, blue); #endif #ifdef T_WATCH_S3 drv.go(); @@ -244,6 +241,9 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) switch (index) { case 1: +#ifdef UNPHONE + unphone.vibe(false); // the unPhone's vibration motor is on a i2c GPIO expander +#endif if (moduleConfig.external_notification.output_vibra) digitalWrite(moduleConfig.external_notification.output_vibra, false); break; @@ -266,12 +266,10 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) } #endif #ifdef UNPHONE - if (rgb_found.type == ScanI2C::RGBLED_CA) { - red = 0; - green = 0; - blue = 0; - unphone.rgb(red, green, blue); - } + red = 0; + green = 0; + blue = 0; + unphone.rgb(red, green, blue); #endif #ifdef T_WATCH_S3 drv.stop(); From a149999ceca1248d7cb4097384a61356d2b4f10b Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Thu, 18 Apr 2024 20:57:03 +0100 Subject: [PATCH 07/19] tidy up first --- src/detect/ScanI2C.h | 3 ++- src/main.cpp | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index b4341bcc0..c8fcfee10 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,8 +41,9 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, - RGBLED_CA, +#ifdef HAS_NCP5623 NCP5623, +#endif } DeviceType; // typedef uint8_t DeviceAddress; diff --git a/src/main.cpp b/src/main.cpp index 1699344a9..b1a15634f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -494,15 +494,11 @@ void setup() * "found". */ -// Only one supported I2C RGB LED currently (plus common anode RGB LED used by the unPhone) +// Only one supported RGB LED currently #ifdef HAS_NCP5623 rgb_found = i2cScanner->find(ScanI2C::DeviceType::NCP5623); #endif -#ifdef UNPHONE - rgb_found.type = ScanI2C::DeviceType::RGBLED_CA; -#endif - #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) auto acc_info = i2cScanner->firstAccelerometer(); accelerometer_found = acc_info.type != ScanI2C::DeviceType::NONE ? acc_info.address : accelerometer_found; From 7d77b23eb6a3383e4950f2f06ac7524b6a8102da Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Thu, 18 Apr 2024 22:00:33 +0100 Subject: [PATCH 08/19] support for generic 4 pin CC and CA RGB LEDS --- src/AmbientLightingThread.h | 48 ++++++++++++++---- src/main.cpp | 2 +- src/modules/ExternalNotificationModule.cpp | 59 ++++++++++++++++++++++ 3 files changed, 99 insertions(+), 10 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index fd3c66cda..1425d3266 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -25,8 +25,8 @@ class AmbientLightingThread : public concurrency::OSThread // moduleConfig.ambient_lighting.green = (myNodeInfo.my_node_num & 0x00FF00) >> 8; // moduleConfig.ambient_lighting.blue = myNodeInfo.my_node_num & 0x0000FF; - _type = type; #ifdef HAS_NCP5623 + _type = type; if (_type == ScanI2C::DeviceType::NONE) { LOG_DEBUG("AmbientLightingThread disabling due to no RGB leds found on I2C bus\n"); disable(); @@ -51,22 +51,39 @@ class AmbientLightingThread : public concurrency::OSThread } LOG_DEBUG("AmbientLightingThread initializing\n"); setLighting(); +#endif +#ifdef RGBLED_RED + if (!moduleConfig.ambient_lighting.led_state) { + LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); + disable(); + return; + } + LOG_DEBUG("AmbientLightingThread initializing\n"); + pinMode(RGBLED_RED, output); + pinMode(RGBLED_GREEN, output); + pinMode(RGBLED_BLUE, output); + setLighting(); #endif } protected: int32_t runOnce() override { -#if defined(HAS_NCP5623) || defined(UNPHONE) - if ((_type == ScanI2C::NCP5623 || _type == ScanI2C::RGBLED_CA) && moduleConfig.ambient_lighting.led_state) { +#ifdef HAS_NCP5623 + if (_type == ScanI2C::NCP5623 && moduleConfig.ambient_lighting.led_state) { setLighting(); return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification - } else { - return disable(); } -#else - return disable(); #endif +#ifdef UNPHONE + setLighting(); + return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification +#endif +#ifdef RGBLED_RED + setLighting(); + return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification +#endif + return disable(); } private: @@ -79,14 +96,27 @@ class AmbientLightingThread : public concurrency::OSThread rgb.setRed(moduleConfig.ambient_lighting.red); rgb.setGreen(moduleConfig.ambient_lighting.green); rgb.setBlue(moduleConfig.ambient_lighting.blue); - LOG_DEBUG("Initializing Ambient lighting w/ current=%d, red=%d, green=%d, blue=%d\n", + LOG_DEBUG("Initializing NCP5623 Ambient lighting w/ current=%d, red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); #endif #ifdef UNPHONE unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); - LOG_DEBUG("Initializing Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, + LOG_DEBUG("Initializing unPhone Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); +#endif +#ifdef RGBLED_CA + analogWrite(RGBLED_RED, 255 - moduleConfig.ambient_lighting.red); + analogWrite(RGBLED_GREEN, 255 - moduleConfig.ambient_lighting.green); + analogWrite(RGBLED_BLUE, 255 - moduleConfig.ambient_lighting.blue); + LOG_DEBUG("Initializing Ambient lighting RGB Common Anode w/ red=%d, green=%d, blue=%d\n", + moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); +#elifdef RGBLED_RED + analogWrite(RGBLED_RED, moduleConfig.ambient_lighting.red); + analogWrite(RGBLED_GREEN, moduleConfig.ambient_lighting.green); + analogWrite(RGBLED_BLUE, moduleConfig.ambient_lighting.blue); + LOG_DEBUG("Initializing Ambient lighting RGB Common Cathode w/ red=%d, green=%d, blue=%d\n", + moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); #endif } }; diff --git a/src/main.cpp b/src/main.cpp index b1a15634f..d8640bb59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -608,7 +608,7 @@ void setup() #endif #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) - if (rgb_found.type != ScanI2C::DeviceType::NONE) { + if (rgb_found.type != ScanI2C::DeviceType::NONE || UNPHONE) { ambientLightingThread = new AmbientLightingThread(rgb_found.type); } #endif diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index d7997b849..ee3b73efd 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -48,6 +48,16 @@ const uint8_t duration = 15; uint8_t counter = 0; #endif +#ifdef RGBLED_RED +uint8_t red = 0; +uint8_t green = 0; +uint8_t blue = 0; +uint8_t colorState = 1; +uint8_t brightnessIndex = 0; +uint8_t brightnessValues[] = {0, 10, 20, 30, 50, 90, 160, 170}; // blue gets multiplied by 1.5 +bool ascending = true; +#endif + #ifndef PIN_BUZZER #define PIN_BUZZER false #endif @@ -84,6 +94,7 @@ int32_t ExternalNotificationModule::runOnce() if (!moduleConfig.external_notification.enabled) { return INT32_MAX; // we don't need this thread here... } else { + bool isPlaying = rtttl::isPlaying(); #ifdef HAS_I2S isPlaying = rtttl::isPlaying() || audioThread->isPlaying(); @@ -159,6 +170,30 @@ int32_t ExternalNotificationModule::runOnce() } #endif +#ifdef RGBLED_RED + red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7 + green = (colorState & 2) ? brightnessValues[brightnessIndex] : 0; // Green enabled on colorState = 2,3,6,7 + blue = (colorState & 1) ? (brightnessValues[brightnessIndex] * 1.5) : 0; // Blue enabled on colorState = 1,3,5,7 + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); + if (ascending) { // fade in + brightnessIndex++; + if (brightnessIndex == (sizeof(brightnessValues) - 1)) { + ascending = false; + } + } else { + brightnessIndex--; // fade out + } + if (brightnessIndex == 0) { + ascending = true; + colorState++; // next color + if (colorState > 7) { + colorState = 1; + } + } +#endif + #ifdef T_WATCH_S3 drv.go(); #endif @@ -229,6 +264,15 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) #ifdef UNPHONE unphone.rgb(red, green, blue); #endif +#ifdef RGBLED_CA + analogWrite(RGBLED_RED, 255 - red); + analogWrite(RGBLED_GREEN, 255 - green); + analogWrite(RGBLED_BLUE, 255 - blue); +#elifdef RGBLED_RED + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); +#endif #ifdef T_WATCH_S3 drv.go(); #endif @@ -271,6 +315,21 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) blue = 0; unphone.rgb(red, green, blue); #endif +#ifdef RGBLED_CA + red = 0; + green = 0; + blue = 0; + analogWrite(RGBLED_RED, 255 - red); + analogWrite(RGBLED_GREEN, 255 - green); + analogWrite(RGBLED_BLUE, 255 - blue); +#elifdef RGBLED_RED + red = 0; + green = 0; + blue = 0; + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); +#endif #ifdef T_WATCH_S3 drv.stop(); #endif From 0ae76749820d6bc9a069ddfb8b8313ffbc1bbe7d Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Thu, 18 Apr 2024 22:18:50 +0100 Subject: [PATCH 09/19] I'm sure there's a cleverer way to do this, but I'm stupid and I didn't find it after a few minutes of searching stack overflow --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d8640bb59..a1f2ebea1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -608,11 +608,15 @@ void setup() #endif #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) - if (rgb_found.type != ScanI2C::DeviceType::NONE || UNPHONE) { + if (rgb_found.type != ScanI2C::DeviceType::NONE) { ambientLightingThread = new AmbientLightingThread(rgb_found.type); } #endif +#ifdef UNPHONE + ambientLightingThread = new AmbientLightingThread(rgb_found.type); +#endif + #ifdef T_WATCH_S3 drv.begin(); drv.selectLibrary(1); From eea85d26ca4328fb7a321e9a98815daf0f62864e Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Fri, 19 Apr 2024 00:28:20 +0100 Subject: [PATCH 10/19] oh god the bugs, they are everywhere, I feel so dirty... --- src/AmbientLightingThread.h | 8 ++++---- src/main.cpp | 6 ++++-- src/modules/ExternalNotificationModule.cpp | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index 1425d3266..81c9c85c7 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -59,9 +59,9 @@ class AmbientLightingThread : public concurrency::OSThread return; } LOG_DEBUG("AmbientLightingThread initializing\n"); - pinMode(RGBLED_RED, output); - pinMode(RGBLED_GREEN, output); - pinMode(RGBLED_BLUE, output); + pinMode(RGBLED_RED, OUTPUT); + pinMode(RGBLED_GREEN, OUTPUT); + pinMode(RGBLED_BLUE, OUTPUT); setLighting(); #endif } @@ -111,7 +111,7 @@ class AmbientLightingThread : public concurrency::OSThread analogWrite(RGBLED_BLUE, 255 - moduleConfig.ambient_lighting.blue); LOG_DEBUG("Initializing Ambient lighting RGB Common Anode w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); -#elifdef RGBLED_RED +#elif defined(RGBLED_RED) analogWrite(RGBLED_RED, moduleConfig.ambient_lighting.red); analogWrite(RGBLED_GREEN, moduleConfig.ambient_lighting.green); analogWrite(RGBLED_BLUE, moduleConfig.ambient_lighting.blue); diff --git a/src/main.cpp b/src/main.cpp index a1f2ebea1..fd06e8ae9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -611,11 +611,13 @@ void setup() if (rgb_found.type != ScanI2C::DeviceType::NONE) { ambientLightingThread = new AmbientLightingThread(rgb_found.type); } -#endif - #ifdef UNPHONE ambientLightingThread = new AmbientLightingThread(rgb_found.type); #endif +#ifdef RGBLED_RED + ambientLightingThread = new AmbientLightingThread(rgb_found.type); +#endif +#endif #ifdef T_WATCH_S3 drv.begin(); diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index ee3b73efd..4bab90527 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -268,7 +268,7 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) analogWrite(RGBLED_RED, 255 - red); analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); -#elifdef RGBLED_RED +#elif defined(RGBLED_RED) analogWrite(RGBLED_RED, red); analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); @@ -322,7 +322,7 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) analogWrite(RGBLED_RED, 255 - red); analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); -#elifdef RGBLED_RED +#elif defined(RGBLED_RED) red = 0; green = 0; blue = 0; From 2100f3135e417d8999a8ba9688534644ef82a836 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Fri, 19 Apr 2024 09:25:38 +0100 Subject: [PATCH 11/19] minor edit to have another go at CI --- src/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fd06e8ae9..991fa3648 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -613,8 +613,7 @@ void setup() } #ifdef UNPHONE ambientLightingThread = new AmbientLightingThread(rgb_found.type); -#endif -#ifdef RGBLED_RED +#elifdef RGBLED_RED ambientLightingThread = new AmbientLightingThread(rgb_found.type); #endif #endif From e0513d4078e93b3361145d58d151e706350536b6 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Fri, 19 Apr 2024 09:27:10 +0100 Subject: [PATCH 12/19] ahem, another minor edit to have another go at CI --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 991fa3648..430fa3a6b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -613,7 +613,7 @@ void setup() } #ifdef UNPHONE ambientLightingThread = new AmbientLightingThread(rgb_found.type); -#elifdef RGBLED_RED +#elif defined(RGBLED_RED) ambientLightingThread = new AmbientLightingThread(rgb_found.type); #endif #endif From fb7a878d94874c116191c51784e89e002d5dca65 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Sun, 21 Apr 2024 08:24:51 +0100 Subject: [PATCH 13/19] tweaked guards to allow various combinations of RGB leds --- src/detect/ScanI2C.h | 2 +- src/main.cpp | 11 +- src/modules/ExternalNotificationModule.cpp | 155 +++++++++------------ 3 files changed, 68 insertions(+), 100 deletions(-) diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index c8fcfee10..f2069cd09 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,7 +41,7 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, -#ifdef HAS_NCP5623 +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) NCP5623, #endif } DeviceType; diff --git a/src/main.cpp b/src/main.cpp index 430fa3a6b..4d741d32e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -607,15 +607,14 @@ void setup() } #endif -#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) +#ifdef UNPHONE + ambientLightingThread = new AmbientLightingThread(ScanI2C::DeviceType::NONE); +#elif defined(RGBLED_RED) + ambientLightingThread = new AmbientLightingThread(ScanI2C::DeviceType::NONE); +#elif !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) if (rgb_found.type != ScanI2C::DeviceType::NONE) { ambientLightingThread = new AmbientLightingThread(rgb_found.type); } -#ifdef UNPHONE - ambientLightingThread = new AmbientLightingThread(rgb_found.type); -#elif defined(RGBLED_RED) - ambientLightingThread = new AmbientLightingThread(rgb_found.type); -#endif #endif #ifdef T_WATCH_S3 diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 4bab90527..bc48e419b 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -26,29 +26,14 @@ #ifdef HAS_NCP5623 #include - -uint8_t red = 0; -uint8_t green = 0; -uint8_t blue = 0; -uint8_t colorState = 1; -uint8_t brightnessIndex = 0; -uint8_t brightnessValues[] = {0, 10, 20, 30, 50, 90, 160, 170}; // blue gets multiplied by 1.5 -bool ascending = true; #endif #ifdef UNPHONE #include "unPhone.h" extern unPhone unphone; - -uint8_t red = 0; -uint8_t green = 0; -uint8_t blue = 0; -uint8_t colorState = 1; -const uint8_t duration = 15; -uint8_t counter = 0; #endif -#ifdef RGBLED_RED +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) uint8_t red = 0; uint8_t green = 0; uint8_t blue = 0; @@ -130,53 +115,27 @@ int32_t ExternalNotificationModule::runOnce() millis()) { getExternal(2) ? setExternalOff(2) : setExternalOn(2); } -#ifdef HAS_NCP5623 - if (rgb_found.type == ScanI2C::NCP5623) { - red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7 - green = (colorState & 2) ? brightnessValues[brightnessIndex] : 0; // Green enabled on colorState = 2,3,6,7 - blue = (colorState & 1) ? (brightnessValues[brightnessIndex] * 1.5) : 0; // Blue enabled on colorState = 1,3,5,7 - rgb.setColor(red, green, blue); - - if (ascending) { // fade in - brightnessIndex++; - if (brightnessIndex == (sizeof(brightnessValues) - 1)) { - ascending = false; - } - } else { - brightnessIndex--; // fade out - } - if (brightnessIndex == 0) { - ascending = true; - colorState++; // next color - if (colorState > 7) { - colorState = 1; - } - } - } -#endif - -#ifdef UNPHONE - red = colorState & 4; // Red enabled on colorState = 4,5,6,7 - green = colorState & 2; // Green enabled on colorState = 2,3,6,7 - blue = colorState & 1; // Blue enabled on colorState = 1,3,5,7 - unphone.rgb(red, green, blue); - counter++; // tick on - if (counter > duration) { - counter = 0; - colorState++; // next color - if (colorState > 7) { - colorState = 1; - } - } -#endif - -#ifdef RGBLED_RED +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7 green = (colorState & 2) ? brightnessValues[brightnessIndex] : 0; // Green enabled on colorState = 2,3,6,7 blue = (colorState & 1) ? (brightnessValues[brightnessIndex] * 1.5) : 0; // Blue enabled on colorState = 1,3,5,7 +#ifdef HAS_NCP5623 + if (rgb_found.type == ScanI2C::NCP5623) { + rgb.setColor(red, green, blue); + } +#endif +#ifdef UNPHONE + unphone.rgb(red, green, blue); +#endif +#ifdef RGBLED_CA + analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic + analogWrite(RGBLED_GREEN, 255 - green); + analogWrite(RGBLED_BLUE, 255 - blue); +#elif defined(RGBLED_RED) analogWrite(RGBLED_RED, red); analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); +#endif if (ascending) { // fade in brightnessIndex++; if (brightnessIndex == (sizeof(brightnessValues) - 1)) { @@ -192,35 +151,35 @@ int32_t ExternalNotificationModule::runOnce() colorState = 1; } } + } #endif #ifdef T_WATCH_S3 - drv.go(); + drv.go(); #endif - } - - // Play RTTTL over i2s audio interface if enabled as buzzer -#ifdef HAS_I2S - if (moduleConfig.external_notification.use_i2s_as_buzzer) { - if (audioThread->isPlaying()) { - // Continue playing - } else if (isNagging && (nagCycleCutoff >= millis())) { - audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); - } - } -#endif - // now let the PWM buzzer play - if (moduleConfig.external_notification.use_pwm) { - if (rtttl::isPlaying()) { - rtttl::play(); - } else if (isNagging && (nagCycleCutoff >= millis())) { - // start the song again if we have time left - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); - } - } - - return EXT_NOTIFICATION_DEFAULT_THREAD_MS; } + + // Play RTTTL over i2s audio interface if enabled as buzzer +#ifdef HAS_I2S + if (moduleConfig.external_notification.use_i2s_as_buzzer) { + if (audioThread->isPlaying()) { + // Continue playing + } else if (isNagging && (nagCycleCutoff >= millis())) { + audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); + } + } +#endif + // now let the PWM buzzer play + if (moduleConfig.external_notification.use_pwm) { + if (rtttl::isPlaying()) { + rtttl::play(); + } else if (isNagging && (nagCycleCutoff >= millis())) { + // start the song again if we have time left + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + } + } + + return EXT_NOTIFICATION_DEFAULT_THREAD_MS; } bool ExternalNotificationModule::wantPacket(const meshtastic_MeshPacket *p) @@ -265,13 +224,13 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) unphone.rgb(red, green, blue); #endif #ifdef RGBLED_CA - analogWrite(RGBLED_RED, 255 - red); + analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); #elif defined(RGBLED_RED) - analogWrite(RGBLED_RED, red); - analogWrite(RGBLED_GREEN, green); - analogWrite(RGBLED_BLUE, blue); + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); #endif #ifdef T_WATCH_S3 drv.go(); @@ -315,21 +274,21 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) blue = 0; unphone.rgb(red, green, blue); #endif -#ifdef RGBLED_CA +#ifdef RGBLED_RED red = 0; green = 0; blue = 0; - analogWrite(RGBLED_RED, 255 - red); +#ifdef RGBLED_CA + analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); -#elif defined(RGBLED_RED) - red = 0; - green = 0; - blue = 0; +#else analogWrite(RGBLED_RED, red); analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); #endif +#endif + #ifdef T_WATCH_S3 drv.stop(); #endif @@ -427,6 +386,16 @@ ExternalNotificationModule::ExternalNotificationModule() rgb.begin(); rgb.setCurrent(10); } +#endif +#ifdef RGBLED_RED + pinMode(RGBLED_RED, OUTPUT); // set up the RGB led pins + pinMode(RGBLED_GREEN, OUTPUT); + pinMode(RGBLED_BLUE, OUTPUT); +#endif +#ifdef RGBLED_CA + analogWrite(RGBLED_RED, 255); // with a common anode type, logic is reversed + analogWrite(RGBLED_GREEN, 255); // so we want to initialise with lights off + analogWrite(RGBLED_BLUE, 255); #endif } else { LOG_INFO("External Notification Module Disabled\n"); @@ -489,7 +458,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP #ifdef HAS_I2S audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); #else - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); #endif } if (moduleConfig.external_notification.nag_timeout) { @@ -533,7 +502,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); } #else - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); #endif } if (moduleConfig.external_notification.nag_timeout) { From cf65661c7ca9bce3e470d7f744df219c6af0d525 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Sun, 21 Apr 2024 08:59:40 +0100 Subject: [PATCH 14/19] another silly error --- src/AmbientLightingThread.h | 40 ++++++------------ src/modules/ExternalNotificationModule.cpp | 48 +++++++++++----------- 2 files changed, 37 insertions(+), 51 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index 81c9c85c7..2febc3d8c 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -32,56 +32,42 @@ class AmbientLightingThread : public concurrency::OSThread disable(); return; } +#endif +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) if (!moduleConfig.ambient_lighting.led_state) { LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); disable(); return; } LOG_DEBUG("AmbientLightingThread initializing\n"); +#ifdef HAS_NCP5623 if (_type == ScanI2C::NCP5623) { rgb.begin(); - setLighting(); - } -#endif -#ifdef UNPHONE - if (!moduleConfig.ambient_lighting.led_state) { - LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); - disable(); - return; - } - LOG_DEBUG("AmbientLightingThread initializing\n"); - setLighting(); #endif #ifdef RGBLED_RED - if (!moduleConfig.ambient_lighting.led_state) { - LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); - disable(); - return; + pinMode(RGBLED_RED, OUTPUT); + pinMode(RGBLED_GREEN, OUTPUT); + pinMode(RGBLED_BLUE, OUTPUT); +#endif + setLighting(); +#endif +#ifdef HAS_NCP5623 } - LOG_DEBUG("AmbientLightingThread initializing\n"); - pinMode(RGBLED_RED, OUTPUT); - pinMode(RGBLED_GREEN, OUTPUT); - pinMode(RGBLED_BLUE, OUTPUT); - setLighting(); #endif } protected: int32_t runOnce() override { +#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) #ifdef HAS_NCP5623 if (_type == ScanI2C::NCP5623 && moduleConfig.ambient_lighting.led_state) { +#endif setLighting(); return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification +#ifdef HAS_NCP5623 } #endif -#ifdef UNPHONE - setLighting(); - return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification -#endif -#ifdef RGBLED_RED - setLighting(); - return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification #endif return disable(); } diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index bc48e419b..236178498 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -151,35 +151,35 @@ int32_t ExternalNotificationModule::runOnce() colorState = 1; } } - } #endif #ifdef T_WATCH_S3 - drv.go(); + drv.go(); #endif - } + } - // Play RTTTL over i2s audio interface if enabled as buzzer + // Play RTTTL over i2s audio interface if enabled as buzzer #ifdef HAS_I2S - if (moduleConfig.external_notification.use_i2s_as_buzzer) { - if (audioThread->isPlaying()) { - // Continue playing - } else if (isNagging && (nagCycleCutoff >= millis())) { - audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); + if (moduleConfig.external_notification.use_i2s_as_buzzer) { + if (audioThread->isPlaying()) { + // Continue playing + } else if (isNagging && (nagCycleCutoff >= millis())) { + audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); + } } - } #endif - // now let the PWM buzzer play - if (moduleConfig.external_notification.use_pwm) { - if (rtttl::isPlaying()) { - rtttl::play(); - } else if (isNagging && (nagCycleCutoff >= millis())) { - // start the song again if we have time left - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + // now let the PWM buzzer play + if (moduleConfig.external_notification.use_pwm) { + if (rtttl::isPlaying()) { + rtttl::play(); + } else if (isNagging && (nagCycleCutoff >= millis())) { + // start the song again if we have time left + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + } } - } - return EXT_NOTIFICATION_DEFAULT_THREAD_MS; + return EXT_NOTIFICATION_DEFAULT_THREAD_MS; + } } bool ExternalNotificationModule::wantPacket(const meshtastic_MeshPacket *p) @@ -228,9 +228,9 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); #elif defined(RGBLED_RED) - analogWrite(RGBLED_RED, red); - analogWrite(RGBLED_GREEN, green); - analogWrite(RGBLED_BLUE, blue); + analogWrite(RGBLED_RED, red); + analogWrite(RGBLED_GREEN, green); + analogWrite(RGBLED_BLUE, blue); #endif #ifdef T_WATCH_S3 drv.go(); @@ -458,7 +458,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP #ifdef HAS_I2S audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); #else - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); #endif } if (moduleConfig.external_notification.nag_timeout) { @@ -502,7 +502,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); } #else - rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); + rtttl::begin(config.device.buzzer_gpio, rtttlConfig.ringtone); #endif } if (moduleConfig.external_notification.nag_timeout) { From 9e4ef92e6d9343d7209529799708c24a1f9eb8a0 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Sun, 21 Apr 2024 09:16:50 +0100 Subject: [PATCH 15/19] lets just define it without guards! --- src/detect/ScanI2C.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index f2069cd09..05a5cb2ea 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -41,9 +41,7 @@ class ScanI2C BQ24295, LSM6DS3, TCA9555, -#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) NCP5623, -#endif } DeviceType; // typedef uint8_t DeviceAddress; From 5dd08e95330f009f79f04963711a73092289dece Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 22 Apr 2024 14:42:52 +0100 Subject: [PATCH 16/19] added NeoPixel support using Adafruit library --- src/AmbientLightingThread.h | 31 ++++++++--- src/main.cpp | 4 +- src/modules/ExternalNotificationModule.cpp | 61 ++++++++++++++-------- 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/src/AmbientLightingThread.h b/src/AmbientLightingThread.h index 2febc3d8c..6b3360b1f 100644 --- a/src/AmbientLightingThread.h +++ b/src/AmbientLightingThread.h @@ -5,6 +5,11 @@ NCP5623 rgb; #endif +#ifdef HAS_NEOPIXEL +#include +Adafruit_NeoPixel pixels(NEOPIXEL_COUNT, NEOPIXEL_DATA, NEOPIXEL_TYPE); +#endif + #ifdef UNPHONE #include "unPhone.h" extern unPhone unphone; @@ -33,7 +38,7 @@ class AmbientLightingThread : public concurrency::OSThread return; } #endif -#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) +#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) if (!moduleConfig.ambient_lighting.led_state) { LOG_DEBUG("AmbientLightingThread disabling due to moduleConfig.ambient_lighting.led_state OFF\n"); disable(); @@ -48,6 +53,11 @@ class AmbientLightingThread : public concurrency::OSThread pinMode(RGBLED_RED, OUTPUT); pinMode(RGBLED_GREEN, OUTPUT); pinMode(RGBLED_BLUE, OUTPUT); +#endif +#ifdef HAS_NEOPIXEL + pixels.begin(); // Initialise the pixel(s) + pixels.clear(); // Set all pixel colors to 'off' + pixels.setBrightness(moduleConfig.ambient_lighting.current); #endif setLighting(); #endif @@ -59,7 +69,7 @@ class AmbientLightingThread : public concurrency::OSThread protected: int32_t runOnce() override { -#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) +#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) #ifdef HAS_NCP5623 if (_type == ScanI2C::NCP5623 && moduleConfig.ambient_lighting.led_state) { #endif @@ -86,10 +96,14 @@ class AmbientLightingThread : public concurrency::OSThread moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); #endif -#ifdef UNPHONE - unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); - LOG_DEBUG("Initializing unPhone Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, - moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); +#ifdef HAS_NEOPIXEL + pixels.fill(pixels.Color(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, + moduleConfig.ambient_lighting.blue), + 0, NEOPIXEL_COUNT); + pixels.show(); + LOG_DEBUG("Initializing NeoPixel Ambient lighting w/ brightness(current)=%d, red=%d, green=%d, blue=%d\n", + moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, + moduleConfig.ambient_lighting.blue); #endif #ifdef RGBLED_CA analogWrite(RGBLED_RED, 255 - moduleConfig.ambient_lighting.red); @@ -103,6 +117,11 @@ class AmbientLightingThread : public concurrency::OSThread analogWrite(RGBLED_BLUE, moduleConfig.ambient_lighting.blue); LOG_DEBUG("Initializing Ambient lighting RGB Common Cathode w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); +#endif +#ifdef UNPHONE + unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); + LOG_DEBUG("Initializing unPhone Ambient lighting w/ red=%d, green=%d, blue=%d\n", moduleConfig.ambient_lighting.red, + moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue); #endif } }; diff --git a/src/main.cpp b/src/main.cpp index 4d741d32e..c142ae15a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -607,9 +607,7 @@ void setup() } #endif -#ifdef UNPHONE - ambientLightingThread = new AmbientLightingThread(ScanI2C::DeviceType::NONE); -#elif defined(RGBLED_RED) +#if defined(HAS_NEOPIXEL) || defined(UNPHONE) || defined(RGBLED_RED) ambientLightingThread = new AmbientLightingThread(ScanI2C::DeviceType::NONE); #elif !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) if (rgb_found.type != ScanI2C::DeviceType::NONE) { diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 94e0aeadc..c02559240 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -28,12 +28,16 @@ #include #endif +#ifdef HAS_NEOPIXEL +#include +#endif + #ifdef UNPHONE #include "unPhone.h" extern unPhone unphone; #endif -#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) +#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) uint8_t red = 0; uint8_t green = 0; uint8_t blue = 0; @@ -115,7 +119,7 @@ int32_t ExternalNotificationModule::runOnce() millis()) { getExternal(2) ? setExternalOff(2) : setExternalOn(2); } -#if defined(HAS_NCP5623) || defined(UNPHONE) || defined(RGBLED_RED) +#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7 green = (colorState & 2) ? brightnessValues[brightnessIndex] : 0; // Green enabled on colorState = 2,3,6,7 blue = (colorState & 1) ? (brightnessValues[brightnessIndex] * 1.5) : 0; // Blue enabled on colorState = 1,3,5,7 @@ -124,9 +128,6 @@ int32_t ExternalNotificationModule::runOnce() rgb.setColor(red, green, blue); } #endif -#ifdef UNPHONE - unphone.rgb(red, green, blue); -#endif #ifdef RGBLED_CA analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic analogWrite(RGBLED_GREEN, 255 - green); @@ -135,6 +136,13 @@ int32_t ExternalNotificationModule::runOnce() analogWrite(RGBLED_RED, red); analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); +#endif +#ifdef HAS_NEOPIXEL + pixels.fill(pixels.Color(red, green, blue), 0, NEOPIXEL_COUNT); + pixels.show(); +#endif +#ifdef UNPHONE + unphone.rgb(red, green, blue); #endif if (ascending) { // fade in brightnessIndex++; @@ -220,9 +228,6 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) rgb.setColor(red, green, blue); } #endif -#ifdef UNPHONE - unphone.rgb(red, green, blue); -#endif #ifdef RGBLED_CA analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic analogWrite(RGBLED_GREEN, 255 - green); @@ -232,6 +237,13 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); #endif +#ifdef HAS_NEOPIXEL + pixels.fill(pixels.Color(red, green, blue), 0, NEOPIXEL_COUNT); + pixels.show(); +#endif +#ifdef UNPHONE + unphone.rgb(red, green, blue); +#endif #ifdef T_WATCH_S3 drv.go(); #endif @@ -260,33 +272,31 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) break; } +#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) + red = 0; + green = 0; + blue = 0; #ifdef HAS_NCP5623 if (rgb_found.type == ScanI2C::NCP5623) { - red = 0; - green = 0; - blue = 0; rgb.setColor(red, green, blue); } #endif -#ifdef UNPHONE - red = 0; - green = 0; - blue = 0; - unphone.rgb(red, green, blue); -#endif -#ifdef RGBLED_RED - red = 0; - green = 0; - blue = 0; #ifdef RGBLED_CA analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic analogWrite(RGBLED_GREEN, 255 - green); analogWrite(RGBLED_BLUE, 255 - blue); -#else +#elif defined(RGBLED_RED) analogWrite(RGBLED_RED, red); analogWrite(RGBLED_GREEN, green); analogWrite(RGBLED_BLUE, blue); #endif +#ifdef HAS_NEOPIXEL + pixels.fill(pixels.Color(red, green, blue), 0, NEOPIXEL_COUNT); + pixels.show(); +#endif +#ifdef UNPHONE + unphone.rgb(red, green, blue); +#endif #endif #ifdef T_WATCH_S3 @@ -397,6 +407,11 @@ ExternalNotificationModule::ExternalNotificationModule() analogWrite(RGBLED_RED, 255); // with a common anode type, logic is reversed analogWrite(RGBLED_GREEN, 255); // so we want to initialise with lights off analogWrite(RGBLED_BLUE, 255); +#endif +#ifdef HAS_NEOPIXEL + pixels.begin(); // Initialise the pixel(s) + pixels.clear(); // Set all pixel colors to 'off' + pixels.setBrightness(moduleConfig.ambient_lighting.current); #endif } else { LOG_INFO("External Notification Module Disabled\n"); @@ -578,4 +593,4 @@ void ExternalNotificationModule::handleSetRingtone(const char *from_msg) if (changed) { nodeDB->saveProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, &meshtastic_RTTTLConfig_msg, &rtttlConfig); } -} \ No newline at end of file +} From ec2b854ea28bfc91f33b1ae92678b544afea1872 Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 22 Apr 2024 14:44:59 +0100 Subject: [PATCH 17/19] oops missed the extern enabling little chap --- src/graphics/NeoPixel.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/graphics/NeoPixel.h diff --git a/src/graphics/NeoPixel.h b/src/graphics/NeoPixel.h new file mode 100644 index 000000000..dde74366e --- /dev/null +++ b/src/graphics/NeoPixel.h @@ -0,0 +1,4 @@ +#ifdef HAS_NEOPIXEL +#include +extern Adafruit_NeoPixel pixels; +#endif \ No newline at end of file From 6669b22db386dd0dd40c7315fbf4c1a45d0e4d5c Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 22 Apr 2024 16:37:05 +0100 Subject: [PATCH 18/19] tidied up, prob broke everything --- .../Dongle_nRF52840-pca10059-v1/variant.cpp | 7 ++----- .../Dongle_nRF52840-pca10059-v1/variant.h | 21 +++++-------------- variants/betafpv_2400_tx_micro/platformio.ini | 2 +- variants/betafpv_2400_tx_micro/variant.h | 9 +++++--- variants/esp32-s3-pico/platformio.ini | 2 +- variants/esp32-s3-pico/variant.h | 4 ++++ variants/lora_relay_v1/platformio.ini | 3 ++- variants/lora_relay_v1/variant.h | 12 +++++++---- variants/lora_relay_v2/platformio.ini | 1 + variants/lora_relay_v2/variant.h | 13 ++++++++---- variants/my_esp32s3_diy_eink/platformio.ini | 4 ++-- variants/my_esp32s3_diy_eink/variant.h | 4 ++++ variants/my_esp32s3_diy_oled/platformio.ini | 4 ++-- variants/my_esp32s3_diy_oled/variant.h | 6 +++++- variants/unphone/platformio.ini | 4 +++- variants/unphone/variant.cpp | 1 + variants/unphone/variant.h | 13 ++++++++++-- 17 files changed, 67 insertions(+), 43 deletions(-) diff --git a/variants/Dongle_nRF52840-pca10059-v1/variant.cpp b/variants/Dongle_nRF52840-pca10059-v1/variant.cpp index 8c6bf039c..2fc87c718 100644 --- a/variants/Dongle_nRF52840-pca10059-v1/variant.cpp +++ b/variants/Dongle_nRF52840-pca10059-v1/variant.cpp @@ -29,10 +29,7 @@ const uint32_t g_ADigitalPinMap[] = { void initVariant() { - // LED1 & LED2 + // LED1 pinMode(PIN_LED1, OUTPUT); ledOff(PIN_LED1); - - pinMode(PIN_LED2, OUTPUT); - ledOff(PIN_LED2); -} +} \ No newline at end of file diff --git a/variants/Dongle_nRF52840-pca10059-v1/variant.h b/variants/Dongle_nRF52840-pca10059-v1/variant.h index 533367a30..aef702c7c 100644 --- a/variants/Dongle_nRF52840-pca10059-v1/variant.h +++ b/variants/Dongle_nRF52840-pca10059-v1/variant.h @@ -43,24 +43,13 @@ extern "C" { #define NUM_ANALOG_OUTPUTS (0) // LEDs -#define PIN_LED1 (0 + 12) // Blue LED P1.12 -#define PIN_LED2 (0 + 6) // Built in Green P0.06 - -// Green Built in LED1 -// #define PIN_LED1 (0 + 6) // LED1 P1.15 - -// RGB NeoPixel LED2 -// #define PIN_LED1 (0 + 8) Red -// #define PIN_LED1 (32 + 9) Green -// #define PIN_LED1 (0 + 12) Blue +#define PIN_LED1 (0 + 6) // Built in Green P0.06 +#define RGBLED_RED (0 + 8) // Red of RGB P0.08 +#define RGBLED_GREEN (32 + 9) // Green of RGB P1.09 +#define RGBLED_BLUE (0 + 12) // Blue of RGB P0.12 +#define RGBLED_CA // comment out this line if you have a common cathode type, as defined use common anode logic #define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 - -#define LED_GREEN PIN_LED1 -#define LED_BLUE PIN_LED2 - -#define LED_STATE_ON 0 // State when LED is litted /* * Buttons diff --git a/variants/betafpv_2400_tx_micro/platformio.ini b/variants/betafpv_2400_tx_micro/platformio.ini index 82fe2a9e4..531e8532d 100644 --- a/variants/betafpv_2400_tx_micro/platformio.ini +++ b/variants/betafpv_2400_tx_micro/platformio.ini @@ -15,4 +15,4 @@ upload_protocol = esptool upload_speed = 460800 lib_deps = ${esp32_base.lib_deps} - makuna/NeoPixelBus@^2.7.1 + adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file diff --git a/variants/betafpv_2400_tx_micro/variant.h b/variants/betafpv_2400_tx_micro/variant.h index 8c615d168..fd06183ee 100644 --- a/variants/betafpv_2400_tx_micro/variant.h +++ b/variants/betafpv_2400_tx_micro/variant.h @@ -1,5 +1,4 @@ // https://betafpv.com/products/elrs-micro-tx-module -#include // 0.96" OLED #define I2C_SDA 22 @@ -15,7 +14,11 @@ #define LORA_CS 5 #define RF95_FAN_EN 17 -#define LED_PIN 16 // This is a LED_WS2812 not a standard LED +// #define LED_PIN 16 // This is a LED_WS2812 not a standard LED +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 16 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use #define BUTTON_PIN 25 #define BUTTON_NEED_PULLUP @@ -31,4 +34,4 @@ #define SX128X_TXEN 26 #define SX128X_RXEN 27 #define SX128X_RESET LORA_RESET -#define SX128X_MAX_POWER 13 +#define SX128X_MAX_POWER 13 \ No newline at end of file diff --git a/variants/esp32-s3-pico/platformio.ini b/variants/esp32-s3-pico/platformio.ini index ef737d98a..ff77c30e0 100644 --- a/variants/esp32-s3-pico/platformio.ini +++ b/variants/esp32-s3-pico/platformio.ini @@ -22,4 +22,4 @@ build_flags = ${esp32_base.build_flags} lib_deps = ${esp32s3_base.lib_deps} zinggjm/GxEPD2@^1.5.3 - ;adafruit/Adafruit NeoPixel@^1.10.7 + adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file diff --git a/variants/esp32-s3-pico/variant.h b/variants/esp32-s3-pico/variant.h index 87378d378..bfcb6059d 100644 --- a/variants/esp32-s3-pico/variant.h +++ b/variants/esp32-s3-pico/variant.h @@ -10,6 +10,10 @@ // #define LED_PIN PIN_LED // Board has RGB LED 21 +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 21 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use // The usbPower state is revered ? // DEBUG | ??:??:?? 365 [Power] Battery: usbPower=0, isCharging=0, batMv=4116, batPct=90 diff --git a/variants/lora_relay_v1/platformio.ini b/variants/lora_relay_v1/platformio.ini index 77402aadc..8660bf64a 100644 --- a/variants/lora_relay_v1/platformio.ini +++ b/variants/lora_relay_v1/platformio.ini @@ -20,4 +20,5 @@ build_src_filter = ${nrf52_base.build_src_filter} +<../variants/lora_relay_v1> lib_deps = ${nrf52840_base.lib_deps} sparkfun/SparkFun BQ27441 LiPo Fuel Gauge Arduino Library@^1.1.0 - bodmer/TFT_eSPI@^2.4.76 \ No newline at end of file + bodmer/TFT_eSPI@^2.4.76 + adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file diff --git a/variants/lora_relay_v1/variant.h b/variants/lora_relay_v1/variant.h index 9cfb69337..29fb4cb84 100644 --- a/variants/lora_relay_v1/variant.h +++ b/variants/lora_relay_v1/variant.h @@ -44,15 +44,19 @@ extern "C" { // LEDs #define PIN_LED1 (3) #define PIN_LED2 (4) -#define PIN_NEOPIXEL (8) +// #define PIN_NEOPIXEL (8) +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 8 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use #define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 +#define PIN_LED2 #define LED_RED PIN_LED1 #define LED_BLUE PIN_LED2 -#define LED_STATE_ON 1 // State when LED is litted +#define 1 // State when LED is litted /* * Buttons @@ -154,4 +158,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif +#endif \ No newline at end of file diff --git a/variants/lora_relay_v2/platformio.ini b/variants/lora_relay_v2/platformio.ini index 4439d8a46..cd2109f00 100644 --- a/variants/lora_relay_v2/platformio.ini +++ b/variants/lora_relay_v2/platformio.ini @@ -23,3 +23,4 @@ lib_deps = ${nrf52840_base.lib_deps} sparkfun/SparkFun BQ27441 LiPo Fuel Gauge Arduino Library@^1.1.0 bodmer/TFT_eSPI@^2.4.76 + adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file diff --git a/variants/lora_relay_v2/variant.h b/variants/lora_relay_v2/variant.h index 3afe8620e..98881a496 100644 --- a/variants/lora_relay_v2/variant.h +++ b/variants/lora_relay_v2/variant.h @@ -61,16 +61,21 @@ extern "C" { // LEDs #define PIN_LED1 (3) #define PIN_LED2 (4) -#define PIN_NEOPIXEL (8) +// #define PIN_NEOPIXEL (8) +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 8 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use + #define PIN_BUZZER (40) #define LED_BUILTIN PIN_LED1 -#define LED_CONN PIN_LED2 +#define PIN_LED2 #define LED_RED PIN_LED1 #define LED_BLUE PIN_LED2 -#define LED_STATE_ON 1 // State when LED is litted +#define 1 // State when LED is litted /* * Buttons @@ -180,4 +185,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif +#endif \ No newline at end of file diff --git a/variants/my_esp32s3_diy_eink/platformio.ini b/variants/my_esp32s3_diy_eink/platformio.ini index 966bc580e..e81f2c1ab 100644 --- a/variants/my_esp32s3_diy_eink/platformio.ini +++ b/variants/my_esp32s3_diy_eink/platformio.ini @@ -13,7 +13,7 @@ platform_packages = lib_deps = ${esp32_base.lib_deps} zinggjm/GxEPD2@^1.5.1 - adafruit/Adafruit NeoPixel@^1.10.7 + adafruit/Adafruit NeoPixel @ ^1.12.0 build_unflags = -DARDUINO_USB_MODE=1 build_flags = ;${esp32_base.build_flags} -D MY_ESP32S3_DIY -I variants/my_esp32s3_diy_eink @@ -24,4 +24,4 @@ build_flags = -DEINK_HEIGHT=128 -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue - -DARDUINO_USB_MODE=0 + -DARDUINO_USB_MODE=0 \ No newline at end of file diff --git a/variants/my_esp32s3_diy_eink/variant.h b/variants/my_esp32s3_diy_eink/variant.h index 516fa7f34..024f912dd 100644 --- a/variants/my_esp32s3_diy_eink/variant.h +++ b/variants/my_esp32s3_diy_eink/variant.h @@ -12,6 +12,10 @@ #define I2C_SCL 17 // 2 // #define LED_PIN 38 // This is a RGB LED not a standard LED +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 38 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use #define BUTTON_PIN 0 // This is the BOOT button #define BUTTON_NEED_PULLUP diff --git a/variants/my_esp32s3_diy_oled/platformio.ini b/variants/my_esp32s3_diy_oled/platformio.ini index 9b8b09f7f..2d7a5cd91 100644 --- a/variants/my_esp32s3_diy_oled/platformio.ini +++ b/variants/my_esp32s3_diy_oled/platformio.ini @@ -12,11 +12,11 @@ platform_packages = tool-esptoolpy@^1.40500.0 lib_deps = ${esp32_base.lib_deps} - adafruit/Adafruit NeoPixel@^1.10.7 + adafruit/Adafruit NeoPixel @ ^1.12.0 build_unflags = -DARDUINO_USB_MODE=1 build_flags = ;${esp32_base.build_flags} -D MY_ESP32S3_DIY -I variants/my_esp32s3_diy_oled ${esp32_base.build_flags} -D PRIVATE_HW -I variants/my_esp32s3_diy_oled -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue - -DARDUINO_USB_MODE=0 + -DARDUINO_USB_MODE=0 \ No newline at end of file diff --git a/variants/my_esp32s3_diy_oled/variant.h b/variants/my_esp32s3_diy_oled/variant.h index 6dd18c236..8a3a39003 100644 --- a/variants/my_esp32s3_diy_oled/variant.h +++ b/variants/my_esp32s3_diy_oled/variant.h @@ -12,6 +12,10 @@ #define I2C_SCL 17 // 2 // #define LED_PIN 38 // This is a RGB LED not a standard LED +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA 38 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use #define BUTTON_PIN 0 // This is the BOOT button #define BUTTON_NEED_PULLUP @@ -53,4 +57,4 @@ // #define PIN_EINK_DC 1 // #define PIN_EINK_RES (-1) // #define PIN_EINK_SCLK 5 -// #define PIN_EINK_MOSI 6 +// #define PIN_EINK_MOSI 6 \ No newline at end of file diff --git a/variants/unphone/platformio.ini b/variants/unphone/platformio.ini index dad9a7177..407976c48 100644 --- a/variants/unphone/platformio.ini +++ b/variants/unphone/platformio.ini @@ -13,6 +13,7 @@ build_unflags = -D ARDUINO_USB_MODE build_flags = ${esp32_base.build_flags} + -D BOARD_HAS_PSRAM -D UNPHONE -I variants/unphone -D ARDUINO_USB_MODE=0 @@ -27,4 +28,5 @@ build_src_filter = ${esp32_base.build_src_filter} +<../variants/unphone> lib_deps = ${esp32s3_base.lib_deps} lovyan03/LovyanGFX @ ^1.1.8 - https://gitlab.com/hamishcunningham/unphonelibrary#meshtastic @ ^9.0.0 \ No newline at end of file + https://gitlab.com/hamishcunningham/unphonelibrary#meshtastic @ ^9.0.0 + adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file diff --git a/variants/unphone/variant.cpp b/variants/unphone/variant.cpp index 3f6d1c54d..7884f82e3 100644 --- a/variants/unphone/variant.cpp +++ b/variants/unphone/variant.cpp @@ -10,6 +10,7 @@ void initVariant() unphone.printWakeupReason(); // what woke us up? (stored, not printed :|) unphone.checkPowerSwitch(); // if power switch is off, shutdown unphone.backlight(false); // setup backlight and make sure its off + unphone.expanderPower(true); // enable power to expander / hat / sheild for (int i = 0; i < 3; i++) { // buzz a bit unphone.vibe(true); diff --git a/variants/unphone/variant.h b/variants/unphone/variant.h index 180fdfe2c..a3f2fce8c 100644 --- a/variants/unphone/variant.h +++ b/variants/unphone/variant.h @@ -1,7 +1,16 @@ // meshtastic/firmware/variants/unphone/variant.h #pragma once - +// RGB LED configuration +#define HAS_NEOPIXEL // Enable the use of neopixels +#define NEOPIXEL_COUNT 1 // How many neopixels are connected +#define NEOPIXEL_DATA A0 // gpio pin used to send data to the neopixels +#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) #define SPI_SCK 39 #define SPI_MOSI 40 #define SPI_MISO 41 @@ -38,7 +47,7 @@ #define SCREEN_TRANSITION_FRAMERATE 5 #define HAS_TOUCHSCREEN 1 -#define USE_XPT2046 1 +#define USE_XPT2046 #define TOUCH_CS 38 #define HAS_GPS \ From ccbf635eef944d7d3fea9a9bb19440b94bafbfed Mon Sep 17 00:00:00 2001 From: Gareth Coleman Date: Mon, 22 Apr 2024 17:21:41 +0100 Subject: [PATCH 19/19] corrected a bit of overzealous tidying --- variants/Dongle_nRF52840-pca10059-v1/variant.h | 9 ++++++++- variants/lora_relay_v1/variant.h | 6 +++--- variants/lora_relay_v2/variant.h | 6 +++--- variants/unphone/platformio.ini | 2 +- variants/unphone/variant.h | 13 ++----------- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/variants/Dongle_nRF52840-pca10059-v1/variant.h b/variants/Dongle_nRF52840-pca10059-v1/variant.h index aef702c7c..2318450eb 100644 --- a/variants/Dongle_nRF52840-pca10059-v1/variant.h +++ b/variants/Dongle_nRF52840-pca10059-v1/variant.h @@ -44,12 +44,19 @@ extern "C" { // LEDs #define PIN_LED1 (0 + 6) // Built in Green P0.06 +#define PIN_LED2 (0 + 6) // Just here for completeness #define RGBLED_RED (0 + 8) // Red of RGB P0.08 #define RGBLED_GREEN (32 + 9) // Green of RGB P1.09 #define RGBLED_BLUE (0 + 12) // Blue of RGB P0.12 #define RGBLED_CA // comment out this line if you have a common cathode type, as defined use common anode logic #define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_GREEN PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 0 // State when LED is litted /* * Buttons @@ -157,4 +164,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif \ No newline at end of file +#endif diff --git a/variants/lora_relay_v1/variant.h b/variants/lora_relay_v1/variant.h index 29fb4cb84..54bc87b68 100644 --- a/variants/lora_relay_v1/variant.h +++ b/variants/lora_relay_v1/variant.h @@ -51,12 +51,12 @@ extern "C" { #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use #define LED_BUILTIN PIN_LED1 -#define PIN_LED2 +#define LED_CONN PIN_LED2 #define LED_RED PIN_LED1 #define LED_BLUE PIN_LED2 -#define 1 // State when LED is litted +#define LED_STATE_ON 1 // State when LED is litted /* * Buttons @@ -158,4 +158,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif \ No newline at end of file +#endif diff --git a/variants/lora_relay_v2/variant.h b/variants/lora_relay_v2/variant.h index 98881a496..6ef7ad7d6 100644 --- a/variants/lora_relay_v2/variant.h +++ b/variants/lora_relay_v2/variant.h @@ -70,12 +70,12 @@ extern "C" { #define PIN_BUZZER (40) #define LED_BUILTIN PIN_LED1 -#define PIN_LED2 +#define LED_CONN PIN_LED2 #define LED_RED PIN_LED1 #define LED_BLUE PIN_LED2 -#define 1 // State when LED is litted +#define LED_STATE_ON 1 // State when LED is litted /* * Buttons @@ -185,4 +185,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif \ No newline at end of file +#endif diff --git a/variants/unphone/platformio.ini b/variants/unphone/platformio.ini index 407976c48..e4a92fe4c 100644 --- a/variants/unphone/platformio.ini +++ b/variants/unphone/platformio.ini @@ -13,7 +13,7 @@ build_unflags = -D ARDUINO_USB_MODE build_flags = ${esp32_base.build_flags} - -D BOARD_HAS_PSRAM + ;-D BOARD_HAS_PSRAM // what's up with this - doesn't seem to be recognised at boot -D UNPHONE -I variants/unphone -D ARDUINO_USB_MODE=0 diff --git a/variants/unphone/variant.h b/variants/unphone/variant.h index a3f2fce8c..180fdfe2c 100644 --- a/variants/unphone/variant.h +++ b/variants/unphone/variant.h @@ -1,16 +1,7 @@ // meshtastic/firmware/variants/unphone/variant.h #pragma once -// RGB LED configuration -#define HAS_NEOPIXEL // Enable the use of neopixels -#define NEOPIXEL_COUNT 1 // How many neopixels are connected -#define NEOPIXEL_DATA A0 // gpio pin used to send data to the neopixels -#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use -// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) + #define SPI_SCK 39 #define SPI_MOSI 40 #define SPI_MISO 41 @@ -47,7 +38,7 @@ #define SCREEN_TRANSITION_FRAMERATE 5 #define HAS_TOUCHSCREEN 1 -#define USE_XPT2046 +#define USE_XPT2046 1 #define TOUCH_CS 38 #define HAS_GPS \