mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
just working adddress led
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -135,7 +135,7 @@ void Item::Parse() {
|
||||
{
|
||||
case CH_SPILED:
|
||||
driver = new out_SPILed (this);
|
||||
debugSerial<<F("SPILED driver created")<<endl;
|
||||
// debugSerial<<F("SPILED driver created")<<endl;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ Item::~Item()
|
||||
if (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;
|
||||
|
||||
if (driver) return driver->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<<F("XOFF skipped. Prev cmd:")<<t<<endl;
|
||||
return -3;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (driver) return driver->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<<itemArr->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) {
|
||||
|
||||
@@ -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<TM1809, DATA_PIN, BRG>(leds, NUM_LEDS);
|
||||
//FastLED.addLeds<TM1809, DATA_PIN, BRG>(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<<from<<F("-")<<to<<F(" cmd=")<<cmd<<endl;
|
||||
for (n=from;n<=to;n++)
|
||||
for (int i=from;i<=to;i++)
|
||||
{
|
||||
|
||||
// debugSerial<<F(".");
|
||||
switch(cmd)
|
||||
{
|
||||
CMD_ON:
|
||||
leds[n] = CRGB::White;
|
||||
case CMD_ON:
|
||||
debugSerial<<F("Ch: ")<<i<<F(" White")<<endl;
|
||||
leds[i] = CRGB::White;
|
||||
break;
|
||||
CMD_OFF:
|
||||
leds[n] = CRGB::Black;
|
||||
case CMD_OFF:
|
||||
debugSerial<<F("Ch: ")<<i<<F(" Black")<<endl;
|
||||
leds[i] = CRGB::Black;
|
||||
break;
|
||||
CMD_NUM:
|
||||
case CMD_NUM:
|
||||
switch (suffixCode)
|
||||
{
|
||||
|
||||
S_POWER:
|
||||
S_VOL:
|
||||
case S_POWER:
|
||||
case S_VOL:
|
||||
//leds[n].setBrightness(Parameters[0]);
|
||||
break;
|
||||
S_SET:
|
||||
S_HSV:
|
||||
leds[n] = CHSV(Parameters[0],Parameters[1],Parameters[2]);
|
||||
case S_SET:
|
||||
case S_HSV:
|
||||
debugSerial<<F("HSV: ")<<i<<F(" :")<<Parameters[0]<<Parameters[1]<<Parameters[2]<<endl;
|
||||
leds[i] = CHSV(Parameters[0],Parameters[1],Parameters[2]);
|
||||
break;
|
||||
S_RGB:
|
||||
leds[n] = CRGB(Parameters[0],Parameters[1],Parameters[2]);
|
||||
case S_RGB:
|
||||
debugSerial<<F("RGB: ")<<i<<F(" :")<<Parameters[0]<<Parameters[1]<<Parameters[2]<<endl;
|
||||
leds[i] = CRGB(Parameters[0],Parameters[1],Parameters[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
FastLED.show();
|
||||
debugSerial<<F("Show ")<<endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ public:
|
||||
int Poll() override;
|
||||
int Stop() 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;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user