sinricpro / esp8266-esp32-sdk

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
https://sinric.pro
227 stars 121 forks source link

Sin ric pro How do I "mirror" WS2812b led strips with ESP32 #374

Closed kanomexico closed 2 months ago

kanomexico commented 2 months ago

Hellos im from México and i got a problem i had 2 led strip in my rom of 300 leds each one, so the problem is that i search by internet about hoy i can control 2 led strips in mirror with sinric pro i dont know much about program in arduino only had this program and wokrs but only for one strip so u can help me with this program to chance to 2 strip in mirror form?? and how about effects of lights any program that share me plis thax a lot

ifdef ENABLE_DEBUG

define DEBUG_ESP_PORT Serial

define NODEBUG_WEBSOCKETS

define NDEBUG

endif

include

if defined(ESP8266)

include

elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040)

include

endif

define FASTLED_ESP8266_DMA

define FASTLED_ESP8266_RAW_PIN_ORDER

include

include "SinricPro.h"

include "SinricProLight.h"

define WIFI_SSID "___"

define WIFIPASS "-____"

define APP_KEY "-------___" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"

define APP_SECRET "-----____" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"

define LIGHTID "------" // Should look like "5dc1564130xxxxxxxxxxxxxx"

define BAUD_RATE 115200 // Change baudrate to your need

define NUM_LEDS 20 // how much LEDs are on the stripe

define LED_PIN 13 // LED stripe is connected to PIN 13

bool powerState;
int globalBrightness = 100; CRGB leds[NUM_LEDS];

bool onPowerState(const String &deviceId, bool &state) { powerState = state; if (state) { FastLED.setBrightness(map(globalBrightness, 0, 100, 0, 255)); } else { FastLED.setBrightness(0); } FastLED.show(); return true; // request handled properly }

bool onBrightness(const String &deviceId, int &brightness) { globalBrightness = brightness; FastLED.setBrightness(map(brightness, 0, 100, 0, 255)); FastLED.show(); return true; }

bool onAdjustBrightness(const String &deviceId, int brightnessDelta) { globalBrightness += brightnessDelta; brightnessDelta = globalBrightness; FastLED.setBrightness(map(globalBrightness, 0, 100, 0, 255)); FastLED.show(); return true; }

bool onColor(const String &deviceId, byte &r, byte &g, byte &b) { fill_solid(leds, NUM_LEDS, CRGB(r, g, b)); FastLED.show(); return true; }

void setupFastLED() { FastLED.addLeds<WS2812B, LED_PIN, RGB>(leds, NUM_LEDS); FastLED.setBrightness(map(globalBrightness, 0, 100, 0, 255)); fill_solid(leds, NUM_LEDS, CRGB::White); FastLED.show(); }

void setupWiFi() { Serial.printf("\r\n[Wifi]: Connecting");

if defined(ESP8266)

WiFi.setSleepMode(WIFI_NONE_SLEEP); 
WiFi.setAutoReconnect(true);

elif defined(ESP32)

WiFi.setSleep(false); 
WiFi.setAutoReconnect(true);

endif

WiFi.begin(WIFI_SSID, WIFI_PASS);

while (WiFi.status() != WL_CONNECTED) { Serial.printf("."); delay(250); } IPAddress localIP = WiFi.localIP(); Serial.printf("connected!\r\n[WiFi]: IP-Address is %s\r\n", localIP.toString().c_str()); }

void setupSinricPro() { // get a new Light device from SinricPro SinricProLight &myLight = SinricPro[LIGHT_ID];

// set callback function to device myLight.onPowerState(onPowerState); myLight.onBrightness(onBrightness); myLight.onAdjustBrightness(onAdjustBrightness); myLight.onColor(onColor);

// setup SinricPro SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); }); //SinricPro.restoreDeviceStates(true); // Uncomment to restore the last known state from the server. SinricPro.begin(APP_KEY, APP_SECRET); }

// main setup function void setup() { Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n"); setupFastLED(); setupWiFi(); setupSinricPro(); }

void loop() { SinricPro.handle(); }

github-actions[bot] commented 2 months ago

This issue has gone quiet. Spooky quiet. We currently close issues after 14 days of inactivity. It’s been at least 7 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder, the best way to fix this or any other problem is to provide a detailed error description including a serial log. Thanks for being a part of the SinricPro community!

github-actions[bot] commented 2 months ago

Hey again! It’s been 14 days since anything happened on this issue, so our friendly robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on this issue or create a new one if you need anything else. As a friendly reminder, the best way to fix this or any other problem is to provide a detailed error description including a serial log. Thanks again for being a part of the SinricPro community!