just working adddress led

This commit is contained in:
2019-08-01 20:03:37 +03:00
parent fb64394571
commit fa1127190c
4 changed files with 41 additions and 23 deletions

View File

@@ -7,6 +7,7 @@ class abstractOut : public abstractCh{
public: public:
abstractOut(Item * _item):abstractCh(){item=_item;}; 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 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: protected:
Item * item; Item * item;
}; };

View File

@@ -135,7 +135,7 @@ void Item::Parse() {
{ {
case CH_SPILED: case CH_SPILED:
driver = new out_SPILed (this); driver = new out_SPILed (this);
debugSerial<<F("SPILED driver created")<<endl; // debugSerial<<F("SPILED driver created")<<endl;
break; break;
} }
@@ -160,7 +160,7 @@ Item::~Item()
if (driver) if (driver)
{ {
delete driver; delete driver;
debugSerial<<F("Driver destroyed")<<endl; // debugSerial<<F("Driver destroyed")<<endl;
} }
} }
@@ -377,8 +377,6 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
} }
debugSerial<<endl; debugSerial<<endl;
if (driver) return driver->Ctrl(cmd, n, Parameters, send, suffixCode, subItem);
int iaddr = getArg(); int iaddr = getArg();
HSVstore st; HSVstore st;
switch (cmd) { switch (cmd) {
@@ -409,10 +407,15 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
default: default:
debugSerial<<F("XOFF skipped. Prev cmd:")<<t<<endl; debugSerial<<F("XOFF skipped. Prev cmd:")<<t<<endl;
return -3; return -3;
} }
break; break;
} }
if (driver) return driver->Ctrl(cmd, n, Parameters, send, suffixCode, subItem);
// Legacy code
switch (cmd) { switch (cmd) {
case 0: //no command case 0: //no command
@@ -790,6 +793,7 @@ int Item::isActive() {
if (!isValid()) return -1; if (!isValid()) return -1;
//debugSerial<<itemArr->name); //debugSerial<<itemArr->name);
int cmd = getCmd(); int cmd = getCmd();
@@ -808,6 +812,7 @@ int Item::isActive() {
} }
// Last time was not a command but parameters set. Looking inside // Last time was not a command but parameters set. Looking inside
if (driver) return driver->isActive();
st.aslong = getVal(); st.aslong = getVal();
switch (itemType) { switch (itemType) {

View File

@@ -5,11 +5,12 @@
#include "options.h" #include "options.h"
#include "Streaming.h" #include "Streaming.h"
#include "FastLED.h" #include "FastLED.h"
#include "item.h"
#define NUM_LEDS 60 #define NUM_LEDS 150
#define DATA_PIN 4 #define DATA_PIN 4
CRGB leds[NUM_LEDS]; static CRGB leds[NUM_LEDS];
static int driverStatus = CST_UNKNOWN; static int driverStatus = CST_UNKNOWN;
int out_SPILed::Setup() int out_SPILed::Setup()
@@ -23,7 +24,8 @@ return 1;
int out_SPILed::Stop() int out_SPILed::Stop()
{ {
Serial.println("SPI-LED De-Init"); Serial.println("SPI-LED De-Init");
FastLED.addLeds<TM1809, DATA_PIN, BRG>(leds, NUM_LEDS); //FastLED.addLeds<TM1809, DATA_PIN, BRG>(leds, NUM_LEDS);
FastLED.clear(true);
driverStatus = CST_UNKNOWN; driverStatus = CST_UNKNOWN;
return 1; return 1;
} }
@@ -33,10 +35,14 @@ int out_SPILed::Status()
return driverStatus; return driverStatus;
} }
int out_SPILed::isActive()
{
}
int out_SPILed::Poll() int out_SPILed::Poll()
{ {
FastLED.show(); //FastLED.show();
return 1; return 1;
}; };
@@ -50,36 +56,41 @@ if (subItem)
to=from; to=from;
} }
debugSerial<<from<<F("-")<<to<<F(" cmd=")<<cmd<<endl; debugSerial<<from<<F("-")<<to<<F(" cmd=")<<cmd<<endl;
for (n=from;n<=to;n++) for (int i=from;i<=to;i++)
{ {
// debugSerial<<F(".");
switch(cmd) switch(cmd)
{ {
CMD_ON: case CMD_ON:
leds[n] = CRGB::White; debugSerial<<F("Ch: ")<<i<<F(" White")<<endl;
leds[i] = CRGB::White;
break; break;
CMD_OFF: case CMD_OFF:
leds[n] = CRGB::Black; debugSerial<<F("Ch: ")<<i<<F(" Black")<<endl;
leds[i] = CRGB::Black;
break; break;
CMD_NUM: case CMD_NUM:
switch (suffixCode) switch (suffixCode)
{ {
S_POWER: case S_POWER:
S_VOL: case S_VOL:
//leds[n].setBrightness(Parameters[0]); //leds[n].setBrightness(Parameters[0]);
break; break;
S_SET: case S_SET:
S_HSV: case S_HSV:
leds[n] = CHSV(Parameters[0],Parameters[1],Parameters[2]); debugSerial<<F("HSV: ")<<i<<F(" :")<<Parameters[0]<<Parameters[1]<<Parameters[2]<<endl;
leds[i] = CHSV(Parameters[0],Parameters[1],Parameters[2]);
break; break;
S_RGB: case S_RGB:
leds[n] = CRGB(Parameters[0],Parameters[1],Parameters[2]); debugSerial<<F("RGB: ")<<i<<F(" :")<<Parameters[0]<<Parameters[1]<<Parameters[2]<<endl;
leds[i] = CRGB(Parameters[0],Parameters[1],Parameters[2]);
break; break;
} }
} }
} }
FastLED.show(); FastLED.show();
debugSerial<<F("Show ")<<endl;
return 1; return 1;
} }

View File

@@ -11,6 +11,7 @@ public:
int Poll() override; int Poll() override;
int Stop() override; int Stop() override;
int Status() override; int Status() override;
int isActive() override;
int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true, int suffixCode=0, char* subItem=NULL) override; int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true, int suffixCode=0, char* subItem=NULL) override;
protected: protected: