Dimmer 9x WLED

User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

To jest Supla + FastLED innych bibliotek nie było potrzeby dodawać, ogólnie obsługa samych pasków jest to przykład z biblioteki, jedyne co to zrobiłem klasę dziedziczącą po kanale RGB i kolory które ustawiam kanałem RGB są przepisywane
Wygląda to następująco:

Code: Select all

    for (int i = 0; i < ilosc_diod; i ++){
      if (selectMode == 1){
        leds[i].r = redWSLED;
        leds[i].g = greenWSLED;
        leds[i].b = blueWSLED;
        FastLED.show();
      }else{
        leds[i].g = redWSLED;
        leds[i].r = greenWSLED;
        leds[i].b = blueWSLED;
        FastLED.show();
      }
    }
Gdzie selectMode jest to typ taśmy RGB lub GRB

Sama klasa wygląda tak:

Code: Select all

class RgbLeds : public Supla::Control::RGBBase {
  public:
    RgbLeds(int Channel)
      : Channel(Channel) {
    }
    void setRGBWValueOnDevice( uint32_t  red,
                               uint32_t  green,
                               uint32_t  blue,
                               uint32_t  colorBrightness,
                               uint32_t  brightness) {



        redWSLED2             = red;
        greenWSLED2           = green;
        blueWSLED2            = blue;
        redWSLED1             = map(red,             0, 1023, 0, 255);
        greenWSLED1           = map(green,           0, 1023, 0, 255);
        blueWSLED1            = map(blue,            0, 1023, 0, 255);
        colorBrightnessWSLED1 = map(colorBrightness, 0, 1023, 0, 100);
        jasnosc = colorBrightnessWSLED1;


        redWSLED             = (redWSLED1 * colorBrightnessWSLED1 ) / 100;
        greenWSLED           = (greenWSLED1 * colorBrightnessWSLED1) / 100;
        blueWSLED            = (blueWSLED1 * colorBrightnessWSLED1) / 100;

    }
  protected:
    uint32_t redWSLED1;
    uint32_t greenWSLED1;
    uint32_t blueWSLED1;
    uint32_t colorBrightnessWSLED1;
    uint32_t brightnessWSLED;
    int Channel;
};
To jest akurat przykład z innego programu, bo na telefonie mam tylko dostęp do części programów, bo zacząłem urlop i nie będę miał dostępu przez 2 tygodnie do kompa (detox od komputera 😂😂😂😂), ale jako Channel jest wpisywany numer kanalu. Powinieneś dla tego programu zadeklarować coś takiego:

Code: Select all

uint32_t redWSLED[9] = {};
uint32_t greenWSLED[9] = {};
uint32_t blueWSLED[9] = {};
W klasie przypisywać Channel pod każdy kolor, żeby było wiadomo którego paska to dotyczy.
Deklaracja dla biblioteki też

Code: Select all

CRGB leds[9][NUM_LEDS];
Poskladaj to razem i masz program gotowy
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005

Return to “Projekty użytkowników”