From fa1127190cdec97ae85cf90736fbc4a9a9a271c2 Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Thu, 1 Aug 2019 20:03:37 +0300 Subject: [PATCH] just working adddress led --- lighthub/abstractout.h | 1 + lighthub/item.cpp | 15 +++++++---- lighthub/modules/out_spiled.cpp | 47 ++++++++++++++++++++------------- lighthub/modules/out_spiled.h | 1 + 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/lighthub/abstractout.h b/lighthub/abstractout.h index 0e441d6..b3db579 100644 --- a/lighthub/abstractout.h +++ b/lighthub/abstractout.h @@ -7,6 +7,7 @@ class abstractOut : public abstractCh{ public: abstractOut(Item * _item):abstractCh(){item=_item;}; virtual int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true, int suffixCode=0, char* subItem=NULL) =0; + virtual int isActive(){return 0;}; protected: Item * item; }; diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 7302998..2f60362 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -135,7 +135,7 @@ void Item::Parse() { { case CH_SPILED: driver = new out_SPILed (this); - debugSerial<Ctrl(cmd, n, Parameters, send, suffixCode, subItem); - int iaddr = getArg(); HSVstore st; switch (cmd) { @@ -409,10 +407,15 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode default: debugSerial<Ctrl(cmd, n, Parameters, send, suffixCode, subItem); + // Legacy code + switch (cmd) { case 0: //no command @@ -790,6 +793,7 @@ int Item::isActive() { if (!isValid()) return -1; //debugSerial<name); + int cmd = getCmd(); @@ -808,6 +812,7 @@ int Item::isActive() { } // Last time was not a command but parameters set. Looking inside + if (driver) return driver->isActive(); st.aslong = getVal(); switch (itemType) { @@ -1244,7 +1249,7 @@ int Item::Poll() { if (driver && driver->Status()) { driver->Poll(); - return INTERVAL_POLLING; //TODO refactoring + return INTERVAL_POLLING; //TODO refactoring } // Legacy polling switch (itemType) { diff --git a/lighthub/modules/out_spiled.cpp b/lighthub/modules/out_spiled.cpp index 850bb45..fbae644 100644 --- a/lighthub/modules/out_spiled.cpp +++ b/lighthub/modules/out_spiled.cpp @@ -5,11 +5,12 @@ #include "options.h" #include "Streaming.h" #include "FastLED.h" +#include "item.h" -#define NUM_LEDS 60 +#define NUM_LEDS 150 #define DATA_PIN 4 -CRGB leds[NUM_LEDS]; +static CRGB leds[NUM_LEDS]; static int driverStatus = CST_UNKNOWN; int out_SPILed::Setup() @@ -23,7 +24,8 @@ return 1; int out_SPILed::Stop() { Serial.println("SPI-LED De-Init"); -FastLED.addLeds(leds, NUM_LEDS); +//FastLED.addLeds(leds, NUM_LEDS); +FastLED.clear(true); driverStatus = CST_UNKNOWN; return 1; } @@ -33,10 +35,14 @@ int out_SPILed::Status() return driverStatus; } +int out_SPILed::isActive() +{ + +} int out_SPILed::Poll() { - FastLED.show(); + //FastLED.show(); return 1; }; @@ -50,36 +56,41 @@ if (subItem) to=from; } debugSerial<