diff --git a/README.md b/README.md index 126b03563..836846fc9 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ Also, [read our FAQ](https://github.com/pr3y/Bruce/wiki/FAQ) | Core2 | :x: | :x: | :x: | :x: | :x: | :ok: | :ok:¹ | :x: | :x: | :x: | | CoreSe/SE | :x: | :x: | :ok: | :x: | :x: | :x: | :ok: | :x: | :x: | :x: | | CYD-2432S028 | :ok: | :ok: | :ok: | :x: | :ok: | :x: | :ok:¹ | :x: | :x: | :x:² | -| Lilygo T-Embed CC1101 | :ok: | :x: | :ok: | :x: | :ok: | :ok: | :ok: | :x: | :x: | :x: | +| Lilygo T-Embed CC1101 | :ok: | :x: | :ok: | :x: | :ok: | :ok: | :ok: | :ok: | :x: | :x: | | Lilygo T-Embed | :x: | :x: | :ok: | :x: | :ok: | :ok: | :ok: | :x: | :x: | :x: | | Lilygo T-Deck (and pro) | :x: | :x: | :ok: | :x: | :x: | :x: | :ok: | :x: | :x: | :x: | diff --git a/ports/lilygo-t-embed-cc1101/platformio.ini b/ports/lilygo-t-embed-cc1101/platformio.ini index 3b4ff79e0..ceb638965 100644 --- a/ports/lilygo-t-embed-cc1101/platformio.ini +++ b/ports/lilygo-t-embed-cc1101/platformio.ini @@ -51,25 +51,25 @@ build_flags = -DPIN_DATA=42 ;RGB LED runned by xylopyrographer/LiteLED@^1.2.0 library - ;-DHAS_RGB_LED=1 ;uncomment to enable - -DRGB_LED=21 + -DHAS_RGB_LED=1 + -DRGB_LED=14 ;Have RTC Chip ;-DHAS_RTC=1 ; SERIAL (GPS) dedicated pins - -DSERIAL_TX=43 ;may be wrong + -DSERIAL_TX=43 -DSERIAL_RX=44 ;Speaker to run music, compatible with NS4168 - -DHAS_NS4168_SPKR=1 ;uncomment to enable + -DHAS_NS4168_SPKR=1 -DBCLK=46 -DWCLK=40 -DDOUT=7 -DMCLK=39 # Microphone CLK ;Can run USB as HID - -DUSB_as_HID=1 ;uncomment to enable + -DUSB_as_HID=1 ;-DBAD_TX=GROVE_SDA ;-DBAD_RX=GROVE_SCL @@ -179,8 +179,11 @@ lib_deps = ${env.lib_deps} lewisxhe/XPowersLib @0.2.6 mathertel/RotaryEncoder @1.5.3 + fastled/FastLED @3.9.4 - +###################################################################################################### +###################################################################################################### +###################################################################################################### [env:lilygo-t-embed] platform = https://github.com/bmorcelli/platform-espressif32/releases/download/0.0.4/platform-espressif32.zip board = lilygo-t-display-s3 diff --git a/ports/m5stack-cardputer/platformio.ini b/ports/m5stack-cardputer/platformio.ini index 8a6dad60c..5ef7a6661 100644 --- a/ports/m5stack-cardputer/platformio.ini +++ b/ports/m5stack-cardputer/platformio.ini @@ -135,4 +135,4 @@ build_flags = lib_deps = ${env.lib_deps} - xylopyrographer/LiteLED@^1.2.0 + fastled/FastLED @3.9.4 diff --git a/src/core/menu_items/OthersMenu.cpp b/src/core/menu_items/OthersMenu.cpp index 50cff0e67..537371ac2 100644 --- a/src/core/menu_items/OthersMenu.cpp +++ b/src/core/menu_items/OthersMenu.cpp @@ -29,8 +29,8 @@ void OthersMenu::optionsMenu() { {"USB Keyboard", [=]() { usb_keyboard(); }}, #endif #ifdef HAS_RGB_LED - {"LED Control", [=]() { ledrgb_setup(); }}, // IncursioHack - {"LED FLash", [=]() { ledrgb_flash(); }}, // IncursioHack + {"LED Control", [=]() { ledColorConfig(); }}, + {"LED Brightness", [=]() { ledBrightnessConfig(); }}, #endif #ifndef LITE_VERSION {"Openhaystack", [=]() { openhaystack_setup(); }}, diff --git a/src/modules/others/led.cpp b/src/modules/others/led.cpp index 2c8db1755..644df5cbc 100644 --- a/src/modules/others/led.cpp +++ b/src/modules/others/led.cpp @@ -1,56 +1,110 @@ #ifdef HAS_RGB_LED -// By @IncursioHack - github.com/IncursioHack -#include +#include #include "core/display.h" #include "core/globals.h" #include "led_control.h" -// Escolha o tipo de LED na lista abaixo. -// Comente todos menos um LED_TYPE. -// #define LED_TYPE LED_STRIP_WS2812 -#define LED_TYPE LED_STRIP_SK6812 -// #define LED_STRIP_APA106 -// #define LED_STRIP_SM16703 +#ifdef T_EMBED_1101 +#define LED_TYPE WS2812B +#define LED_ORDER GRB +#define LED_TYPE_IS_RGBW 0 +#define LED_COUNT 8 +#else +#define LED_TYPE SK6812 +#define LED_ORDER RGB +#define LED_TYPE_IS_RGBW 1 +#define LED_COUNT 1 +#endif -#define LED_TYPE_IS_RGBW 1 // Se o LED for do tipo RGBW, altere o 0 para 1 -#define LED_BRIGHT 245 // Define o brilho do LED. "0" está desligado; 255 pode queimar seus olhos (não recomendado) +#define LED_BRIGHT_DEFAULT 245 -LiteLED myLED( LED_TYPE, LED_TYPE_IS_RGBW ); // Cria o objeto LiteLED com o nome "myLED" +int brightness = 75; -void ledrgb_setup() { - myLED.begin( RGB_LED, 1 ); // Inicialize o objeto myLED. Aqui temos 1 LED conectado ao pino RGB_LED - myLED.brightness( LED_BRIGHT, 1 ); // Ligue o LED +CRGB leds[LED_COUNT]; +CRGB color = CRGB::Red; + +CRGB hsvToRgb(uint16_t h, uint8_t s, uint8_t v) +{ + uint8_t f = (h % 60) * 255 / 60; + uint8_t p = (255 - s) * (uint16_t)v / 255; + uint8_t q = (255 - f * (uint16_t)s / 255) * (uint16_t)v / 255; + uint8_t t = (255 - (255 - f) * (uint16_t)s / 255) * (uint16_t)v / 255; + uint8_t r = 0, g = 0, b = 0; + switch ((h / 60) % 6) { + case 0: r = v; g = t; b = p; break; + case 1: r = q; g = v; b = p; break; + case 2: r = p; g = v; b = t; break; + case 3: r = p; g = q; b = v; break; + case 4: r = t; g = p; b = v; break; + case 5: r = v; g = p; b = q; break; + } + + CRGB c; + c.red = r; + c.green = g; + c.blue = b; + return c; +} + +void setColor(CRGB c) +{ + color = c; + for(int i = 0; i < LED_COUNT; i++){ + leds[i] = color; + } + FastLED.show(); +} + +void setBrightness(int b) +{ + brightness = b; + FastLED.setBrightness(brightness); + FastLED.show(); +} + + +void ledColorConfig() +{ + FastLED.addLeds(leds, LED_COUNT); // Initialize the LED Object. Only 1 LED. + setBrightness(brightness); // Set LED Brightness options = { - {"OFF", [=]() { myLED.brightness( 0, 1 ); }}, - {"PURPLE", [=]() { myLED.setPixel( 0, L_PURPLE, 1 ); }}, - {"WHITE", [=]() { myLED.setPixel( 0, L_WHITE, 1 ); }}, - {"RED", [=]() { myLED.setPixel( 0, L_RED, 1 ); }}, - {"GREEN", [=]() { myLED.setPixel( 0, L_GREEN, 1 ); }}, - {"BLUE", [=]() { myLED.setPixel( 0, L_BLUE, 1 ); }}, + {"OFF", [=]() + { setBrightness(0); }}, + {"PURPLE", [=]() + { setColor(CRGB::Purple); }}, + {"WHITE", [=]() + { setColor(CRGB::White); }}, + {"RED", [=]() + { setColor(CRGB::Red); }}, + {"GREEN", [=]() + { setColor(CRGB::Green); }}, + {"BLUE", [=]() + { setColor(CRGB::Blue); }}, }; delay(200); loopOptions(options); delay(200); } -void ledrgb_flash() { - myLED.begin( RGB_LED, 1 ); // Inicialize o objeto myLED. Aqui temos 1 LED conectado ao pino RGB_LED - myLED.brightness( LED_BRIGHT_DEFAULT, 1 ); // Ligue o LED - myLED.setPixel( 0, L_PURPLE, 1 ); - delay(1000); - myLED.brightness( 0, 1 ); - delay(1000); - myLED.brightness( LED_BRIGHT_DEFAULT, 1 ); - delay(1000); - myLED.brightness( 0, 1 ); - delay(1000); - myLED.brightness( LED_BRIGHT_DEFAULT, 1 ); - delay(1000); - myLED.brightness( 0, 1 ); - delay(1000); - myLED.brightness( LED_BRIGHT_DEFAULT, 1 ); - delay(1000); - myLED.brightness( 0, 1 ); +void ledBrightnessConfig() +{ + + options = { + {"10", [=]() + { setBrightness(10); }}, + {"25", [=]() + { setBrightness(20); }}, + {"50", [=]() + { setBrightness(50); }}, + {"75", [=]() + { setBrightness(75); }}, + {"100", [=]() + { setBrightness(100); }}, + }; + + delay(200); + loopOptions(options); + delay(200); } #endif \ No newline at end of file diff --git a/src/modules/others/led_control.h b/src/modules/others/led_control.h index 98d285a3c..d8ca5d969 100644 --- a/src/modules/others/led_control.h +++ b/src/modules/others/led_control.h @@ -1,31 +1,14 @@ +#ifndef __LED_CONTROL_H__ +#define __LED_CONTROL_H__ #ifdef HAS_RGB_LED -// By IncursioHack @github.com/IncursioHack #include -#include +#include -// Escolha o tipo de LED na lista abaixo. Comente todos, exceto o que você está usando. -#define LED_TYPE LED_STRIP_SK6812 -// #define LED_STRIP_WS2812 -// #define LED_STRIP_APA106 -// #define LED_STRIP_SM16703 - -#define LED_TYPE_IS_RGBW 1 // Se o LED for do tipo RGBW, altere o 0 para 1 - -// Definição de intensidade de brilho -#define LED_BRIGHT_DEFAULT 245 // Define o brilho padrão do LED. "0" é desligado; 255 pode ser muito brilhante. - -// Cores predefinidas para o LED -static const crgb_t L_RED = 0xff0000; -static const crgb_t L_GREEN = 0x00ff00; -static const crgb_t L_BLUE = 0x0000ff; -static const crgb_t L_WHITE = 0xe0e0e0; -static const crgb_t L_PURPLE = 0xff00ff; - -// Declaração do objeto LiteLED -extern LiteLED myLED; - -// Declarações de funções para controle do LED RGB -void ledrgb_setup(); -void ledrgb_flash(); +CRGB hsvToRgb(uint16_t h, uint8_t s, uint8_t v); +void setColor(CRGB c); +void setBrightness(int b); +void ledColorConfig(); +void ledBrightnessConfig(); +#endif #endif \ No newline at end of file