UNTESTED interim commit with refactoring

This commit is contained in:
2020-11-13 14:19:30 +03:00
parent 544252fb14
commit 118fd25186
24 changed files with 1373 additions and 592 deletions

View File

@@ -129,7 +129,7 @@ void out_AC::InsertData(byte data[], size_t size){
/////////////////////////////////
publishTopic(item->itemArr->name,(long)set_tmp,"/set");
publishTopic(item->itemArr->name, (long)cur_tmp, "/temp");
if (cur_tmp!=255) publishTopic(item->itemArr->name, (long)cur_tmp, "/temp");
////////////////////////////////////
s_mode[0]='\0';
@@ -148,6 +148,9 @@ void out_AC::InsertData(byte data[], size_t size){
else if (mode == 0x04){
strcpy_P(s_mode,DRY_P);
}
else if (mode == 109){
strcpy_P(s_mode,ERROR_P);
}
publishTopic(item->itemArr->name, (long) mode, "/mode");
@@ -259,7 +262,8 @@ delay(100);
return INTERVAL_POLLING;
};
int out_AC::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* subItem)
//int out_AC::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* subItem)
int out_AC::Ctrl(itemCmd cmd, int suffixCode, char* subItem)
{char s_mode[10];
// Some additional Subitems
if (strcmp_P(subItem, LOCK_P) == 0) suffixCode = S_LOCK;
@@ -267,12 +271,14 @@ int out_AC::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* su
else if (strcmp_P(subItem, QUIET_P) == 0) suffixCode = S_QUIET;
else if (strcmp_P(subItem, RAW_P) == 0) suffixCode = S_RAW;
if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
//data[B_POWER] = power;
// debugSerial<<F(".");
switch(suffixCode)
{
case S_SET:
set_tmp = Parameters[0];
set_tmp = cmd.getInt();
if (set_tmp >= 10 && set_tmp <= 30)
{
data[B_SET_TMP] = set_tmp -16;
@@ -282,7 +288,7 @@ int out_AC::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* su
case S_CMD:
s_mode[0]='\0';
switch (cmd)
switch (cmd.getCmd())
{
case CMD_ON:
case CMD_XON:
@@ -340,7 +346,7 @@ int out_AC::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* su
case S_FAN:
s_mode[0]='\0';
switch (cmd)
switch (cmd.getCmd())
{
case CMD_AUTO:
data[B_FAN_SPD] = 3;
@@ -359,18 +365,20 @@ int out_AC::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* su
strcpy_P(s_mode,LOW_P);
break;
default:
if (n) data[B_FAN_SPD] = Parameters[0];
//if (n) data[B_FAN_SPD] = Parameters[0];
data[B_FAN_SPD] = cmd.getInt();
//TODO - mapping digits to speed
}
publishTopic(item->itemArr->name,s_mode,"/fan");
break;
case S_MODE:
data[B_MODE] = Parameters[0];
//data[B_MODE] = Parameters[0];
data[B_MODE] = cmd.getInt();
break;
case S_LOCK:
switch (cmd)
switch (cmd.getCmd())
{
case CMD_ON:
data[B_LOCK_REM] = 80;
@@ -382,7 +390,7 @@ int out_AC::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* su
break;
case S_SWING:
switch (cmd)
switch (cmd.getCmd())
{
case CMD_ON:
data[B_LOCK_REM] = 3;
@@ -391,12 +399,13 @@ int out_AC::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* su
data[B_LOCK_REM] = 0;
break;
default:
if (n) data[B_SWING] = Parameters[0];
//if (n) data[B_SWING] = Parameters[0];
data[B_SWING] = cmd.getInt();
}
break;
case S_QUIET:
switch (cmd)
switch (cmd.getCmd())
{
case CMD_ON:
data[B_POWER] |= 8;

View File

@@ -29,7 +29,8 @@ public:
int Stop() override;
int Status() override;
int isActive() override;
int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
int Ctrl(itemCmd cmd, int suffixCode=0, char* subItem=NULL) override;
protected:
void InsertData(byte data[], size_t size);

View File

@@ -0,0 +1,226 @@
//#ifndef DMX_DISABLE
#ifdef XXXX
#include "modules/out_dmx.h"
#include "Arduino.h"
#include "options.h"
#include "Streaming.h"
#include "item.h"
#include "main.h"
static int driverStatus = CST_UNKNOWN;
int out_dmx::Setup()
{
debugSerial<<F("DMX-Out Init")<<endl;
driverStatus = CST_INITIALIZED;
return 1;
}
int out_SPILed::Stop()
{
debugSerial<<F("DMX-Out stop")<<endl;
driverStatus = CST_UNKNOWN;
return 1;
}
int out_SPILed::Status()
{
return driverStatus;
}
int out_SPILed::isActive()
{
itemStore st;
st.aslong = item->getVal(); //Restore old params
debugSerial<< F(" val:")<<st.v<<endl;
return st.v;
}
int out_SPILed::Poll(short cause)
{
return 0;
};
int out_SPILed::getChanType()
{
if ((ledsType>>4) == (ledsType>>6))
return CH_RGB;
else
return CH_RGBW;
}
int out_SPILed::PixelCtrl(itemCmd cmd, int from, int to, bool show)
{
itemCmd st(ST_RGB);
#ifdef ADAFRUIT_LED
uint32_t pixel;
#else
CRGB pixel;
#endif
if (to>numLeds-1) to=numLeds-1;
if (from<0) from=0;
for (int i=from;i<=to;i++)
{
switch (cmd.getCmd()) {
case CMD_ON:
#ifdef ADAFRUIT_LED
if (!leds->getPixelColor(i)) leds->setPixelColor(i, leds->Color(255, 255, 255));
#else
if (!leds[i].r && !leds[i].g &&!leds[i].b) leds[i] = CRGB::White;
#endif
break;
case CMD_OFF:
#ifdef ADAFRUIT_LED
leds->setPixelColor(i, leds->Color(0, 0, 0));
#else
leds[i] = CRGB::Black;
#endif
break;
default:
st.assignFrom(cmd);
#ifdef ADAFRUIT_LED
leds->setPixelColor(i, leds->Color(st.param.r,st.param.g,st.param.b));
#else
leds[i] = CRGB(st.param.r,st.param.g,st.param.b);
#endif
}
} //for
if (show)
{
#ifdef ADAFRUIT_LED
leds->show();
#else
FastLED.show();
#endif
debugSerial<<F("Show")<<endl;
}
return 1;
}
int out_SPILed::Ctrl(itemCmd cmd, int suffixCode, char* subItem)
{
int chActive = item->isActive();
bool toExecute = (chActive>0);
itemCmd st(ST_HSV);
if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
int from=0, to=numLeds-1; //All LEDs on the strip by default
// retrive LEDs range from suffix
if (subItem)
{ //Just single LED to control todo - range
// debugSerial<<F("Range:")<<subItem<<endl;
if (sscanf(subItem,"%d-%d",&from,&to) == 1) to=from;
}
debugSerial<<from<<F("-")<<to<<F(" cmd=")<<cmd.getCmd()<<endl;
switch(suffixCode)
{
case S_NOTFOUND:
// turn on and set
toExecute = true;
case S_SET:
case S_HSV:
//st.Int(item->getVal()); //Restore old params
st.loadItem(item);
st.assignFrom(cmd);
PixelCtrl(st,from,to,toExecute);
if (!subItem) //Whole strip
{
//item->setVal(st.getInt()); //Store
st.saveItem(item);
if (!suffixCode)
{
if (chActive>0 && !st.getPercents()) item->setCmd(CMD_OFF);
if (chActive==0 && st.getPercents()) item->setCmd(CMD_ON);
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED);
}
else item->SendStatus(SEND_PARAMETERS | SEND_DEFFERED);
}
return 1;
//break;
case S_HUE:
st.setH(uint16_t);
break;
case S_SAT:
st.setS(uint8_t);
break;
case S_CMD:
item->setCmd(cmd.getCmd());
switch (cmd.getCmd())
{
case CMD_ON:
//retrive stored values
st.loadItem(item);
if (subItem) // LED range, not whole strip
PixelCtrl(st.Cmd(CMD_ON),from,to);
else //whole strip
{
if (st.param.aslong && (st.param.v<MIN_VOLUME) /* && send */) st.Percents(INIT_VOLUME);
//item->setVal(st.getInt());
st.saveItem(item);
if (st.getInt() ) //Stored smthng
{
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS);
debugSerial<<F("Restored: ")<<st.param.h<<F(",")<<st.param.s<<F(",")<<st.param.v<<endl;
}
else
{
debugSerial<<st.param.aslong<<F(": No stored values - default\n");
st.setDefault();
//st.param.hsv_flag=1; ///tyta
// Store
//item->setVal(st.getInt());
st.saveItem(item);
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS );
}
PixelCtrl(st,from,to);
}
return 1;
case CMD_OFF:
if (subItem) // LED range, not whole strip
PixelCtrl(st.Cmd(CMD_OFF));
else
{
st.Percents(0);
PixelCtrl(st,from,to);
item->SendStatus(SEND_COMMAND);
// if (send) item->publishTopic(item->itemArr->name,"OFF","/cmd");
}
return 1;
} //switch cmd
break;
} //switch suffix
debugSerial<<F("Unknown cmd")<<endl;
return 0;
}
#endif

View File

@@ -0,0 +1,34 @@
#pragma once
#include "options.h"
//#ifndef DMX_DISABLE
#ifdef XXXX
#include <abstractout.h>
#include <item.h>
#ifdef ADAFRUIT_LED
#include <Adafruit_NeoPixel.h>
#else
#include "FastLED.h"
#endif
class out_dmx : public abstractOut {
public:
out_dmx(Item * _item):abstractOut(_item){getConfig();};
int Setup() override;
int Poll(short cause) override;
int Stop() override;
int Status() override;
int isActive() override;
int getChanType() override;
int Ctrl(itemCmd cmd, int suffixCode=0, char* subItem=NULL) override;
int PixelCtrl(itemCmd cmd, int from =0 , int to = 1024, bool show = 1);
int numLeds;
int8_t pin;
int ledsType;
protected:
void getConfig();
};
#endif

View File

@@ -338,14 +338,12 @@ int out_Modbus::getChanType()
int out_Modbus::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* subItem)
int out_Modbus::Ctrl(itemCmd cmd, int suffixCode, char* subItem)
{
int chActive = item->isActive();
bool toExecute = (chActive>0);
long st;
if (cmd>0 && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
//item->setFlag(ACTION_NEEDED);
itemCmd st(ST_UINT32);
if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
switch(suffixCode)
{
@@ -354,12 +352,12 @@ case S_NOTFOUND:
toExecute = true;
debugSerial<<F("Forced execution");
case S_SET:
if (!Parameters || n==0) return 0;
item->setVal(st=Parameters[0]); //Store
if (!cmd.isValue()) return 0;
//////item->setVal(st=Parameters[0]); //Store
if (!suffixCode)
{
if (chActive>0 && !st) item->setCmd(CMD_OFF);
if (chActive==0 && st) item->setCmd(CMD_ON);
if (chActive>0 && !st.getInt()) item->setCmd(CMD_OFF);
if (chActive==0 && st.getInt()) item->setCmd(CMD_ON);
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED);
// if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time
}
@@ -369,28 +367,29 @@ case S_SET:
//break;
case S_CMD:
item->setCmd(cmd);
switch (cmd)
//item->setCmd(cmd.getCmd());
st.loadItem(item);
switch (cmd.getCmd())
{
case CMD_ON:
//retrive stored values
st = item->getVal();
st.loadItem(item);
if (st && (st<MIN_VOLUME) /* && send */) st=INIT_VOLUME;
item->setVal(st);
if (st.getPercents() && (st.getPercents()<MIN_VOLUME) /* && send */) st.Percents(INIT_VOLUME);
st.saveItem(item);
if (st) //Stored smthng
if (st.getPercents()) //Stored smthng
{
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS);
debugSerial<<F("Restored: ")<<st<<endl;
debugSerial<<F("Restored: ")<<st.getPercents()<<endl;
}
else
{
debugSerial<<st<<F(": No stored values - default\n");
debugSerial<<F(": No stored values - default\n");
// Store
st=100;
item->setVal(st);
st.setDefault();
st.saveItem(item);
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS );
}
// if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time

View File

@@ -31,8 +31,8 @@ public:
int Status() override;
int isActive() override;
int getChanType() override;
int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
int Ctrl(itemCmd cmd, int suffixCode=0, char* subItem=NULL) override;
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
protected:
mbPersistent * store;

View File

@@ -211,12 +211,12 @@ int out_Motor::getChanType()
int out_Motor::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* subItem)
int out_Motor::Ctrl(itemCmd cmd, int suffixCode, char* subItem)
{
int chActive = item->isActive();
bool toExecute = (chActive>0);
long st;
if (cmd>0 && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
itemCmd st(ST_PERCENTS);
if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
item->setFlag(ACTION_NEEDED);
@@ -227,12 +227,14 @@ case S_NOTFOUND:
toExecute = true;
debugSerial<<F("Forced execution");
case S_SET:
if (!Parameters || n==0) return 0;
item->setVal(st=Parameters[0]); //Store
if (!cmd.isValue()) return 0;
st.assignFrom(cmd);
//Store
st.saveItem(item);
if (!suffixCode)
{
if (chActive>0 && !st) item->setCmd(CMD_OFF);
if (chActive==0 && st) item->setCmd(CMD_ON);
if (chActive>0 && !st.getPercents()) item->setCmd(CMD_OFF);
if (chActive==0 && st.getPercents()) item->setCmd(CMD_ON);
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED);
if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time
}
@@ -242,30 +244,32 @@ case S_SET:
//break;
case S_CMD:
item->setCmd(cmd);
switch (cmd)
item->setCmd(cmd.getCmd());
switch (cmd.getCmd())
{
case CMD_ON:
//retrive stored values
st = item->getVal();
if (st && (st<MIN_VOLUME) /* && send */) st=INIT_VOLUME;
item->setVal(st);
if (st) //Stored smthng
if (st.loadItem(item))
{
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS);
debugSerial<<F("Restored: ")<<st<<endl;
if (st.getPercents() && (st.getPercents()<MIN_VOLUME) /* && send */)
{ //Volume too low
st.Percents(INIT_VOLUME);
st.saveItem(item);
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS);
}
debugSerial<<F("Restored: ")<<st.getPercents()<<endl;
}
else
{
debugSerial<<st<<F(": No stored values - default\n");
debugSerial<<F(": No stored values - default\n");
// Store
st=100;
item->setVal(st);
st.setDefault();
st.saveItem(item);
//st=100;
//item->setVal(st);
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS );
}
if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time
return 1;

View File

@@ -25,7 +25,8 @@ public:
int Status() override;
int isActive() override;
int getChanType() override;
int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
int Ctrl(itemCmd cmd, int suffixCode=0, char* subItem=NULL) override;
int8_t pinUp;
int8_t pinDown;

View File

@@ -108,35 +108,22 @@ int out_SPILed::getChanType()
return CH_RGBW;
}
int out_SPILed::PixelCtrl(itemStore *st, short cmd, int from, int to, bool show, bool rgb)
int out_SPILed::PixelCtrl(itemCmd cmd, int from, int to, bool show)
{
//debugSerial<<F("cmd: ")<<cmd<<endl;
itemCmd st(ST_RGB);
#ifdef ADAFRUIT_LED
uint32_t pixel;
#else
CRGB pixel;
#endif
if (!rgb)
{
int Saturation = map(st->s, 0, 100, 0, 255);
int Value = map(st->v, 0, 100, 0, 255);
#ifdef ADAFRUIT_LED
uint16_t Hue = map(st->h, 0, 365, 0, 65535);
pixel = leds->ColorHSV(Hue, Saturation, Value);
#else
int Hue = map(st->h, 0, 365, 0, 255);
pixel = CHSV(Hue, Saturation, Value);
#endif
debugSerial<<F("hsv: ")<<st->h<<F(",")<<st->s<<F(",")<<st->v<<endl;
}
if (to>numLeds-1) to=numLeds-1;
if (from<0) from=0;
for (int i=from;i<=to;i++)
{
switch (cmd) {
switch (cmd.getCmd()) {
case CMD_ON:
#ifdef ADAFRUIT_LED
@@ -144,9 +131,8 @@ CRGB pixel;
#else
if (!leds[i].r && !leds[i].g &&!leds[i].b) leds[i] = CRGB::White;
#endif
break;
case CMD_OFF:
#ifdef ADAFRUIT_LED
leds->setPixelColor(i, leds->Color(0, 0, 0));
@@ -156,26 +142,18 @@ CRGB pixel;
break;
default:
if (rgb)
{
#ifdef ADAFRUIT_LED
leds->setPixelColor(i, leds->Color(st->r,st->g,st->b));
#else
leds[i] = CRGB(st->r,st->g,st->b);
#endif
}
else
{
#ifdef ADAFRUIT_LED
leds->setPixelColor(i, pixel);
#else
leds[i] = pixel;
#endif
}
st.assignFrom(cmd);
#ifdef ADAFRUIT_LED
leds->setPixelColor(i, leds->Color(st.param.r,st.param.g,st.param.b));
#else
leds[i] = CRGB(st.param.r,st.param.g,st.param.b);
#endif
}
} //for
if (show)
{
#ifdef ADAFRUIT_LED
@@ -189,12 +167,12 @@ CRGB pixel;
return 1;
}
int out_SPILed::Ctrl(short cmd, short n, int * Parameters, int suffixCode, char* subItem)
int out_SPILed::Ctrl(itemCmd cmd, int suffixCode, char* subItem)
{
int chActive = item->isActive();
bool toExecute = (chActive>0);
itemStore st;
if (cmd>0 && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
itemCmd st(ST_HSV);
if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
int from=0, to=numLeds-1; //All LEDs on the strip by default
// retrive LEDs range from suffix
@@ -203,7 +181,7 @@ if (subItem)
// debugSerial<<F("Range:")<<subItem<<endl;
if (sscanf(subItem,"%d-%d",&from,&to) == 1) to=from;
}
debugSerial<<from<<F("-")<<to<<F(" cmd=")<<cmd<<endl;
debugSerial<<from<<F("-")<<to<<F(" cmd=")<<cmd.getCmd()<<endl;
switch(suffixCode)
@@ -213,7 +191,10 @@ case S_NOTFOUND:
toExecute = true;
case S_SET:
case S_HSV:
st.aslong = item->getVal(); //Restore old params
//st.Int(item->getVal()); //Restore old params
st.loadItem(item);
st.assignFrom(cmd);
/*
switch (n) //How many parameters are passed?
{
case 1:
@@ -236,21 +217,26 @@ case S_HSV:
st.v = Parameters[2];
st.hsv_flag = 1;
}
PixelCtrl(&st,0,from,to,toExecute);
*/
PixelCtrl(st,from,to,toExecute);
if (!subItem) //Whole strip
{
item->setVal(st.aslong); //Store
//item->setVal(st.getInt()); //Store
st.saveItem(item);
if (!suffixCode)
{
if (chActive>0 && !st.v) item->setCmd(CMD_OFF);
if (chActive==0 && st.v) item->setCmd(CMD_ON);
if (chActive>0 && !st.getPercents()) item->setCmd(CMD_OFF);
if (chActive==0 && st.getPercents()) item->setCmd(CMD_ON);
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED);
}
else item->SendStatus(SEND_PARAMETERS | SEND_DEFFERED);
}
return 1;
//break;
/*
case S_RGB:
st.r = Parameters[0];
st.g = Parameters[1];
@@ -267,59 +253,51 @@ if (!suffixCode)
}
else item->SendStatus(SEND_PARAMETERS | SEND_DEFFERED);
return 1;
//break;
//break; */
case S_CMD:
item->setCmd(cmd);
switch (cmd)
item->setCmd(cmd.getCmd());
switch (cmd.getCmd())
{
case CMD_ON:
/*
if (chActive>0 && send)
{
SendStatus(SEND_COMMAND);
return 1;
}
*/
//retrive stored values
st.aslong = item->getVal();
st.loadItem(item);
if (subItem) // LED range, not whole strip
PixelCtrl(&st,CMD_ON,from,to);
PixelCtrl(st.Cmd(CMD_ON),from,to);
else //whole strip
{
if (st.aslong && (st.v<MIN_VOLUME) /* && send */) st.v=INIT_VOLUME;
item->setVal(st.aslong);
if (st.param.aslong && (st.param.v<MIN_VOLUME) /* && send */) st.Percents(INIT_VOLUME);
//item->setVal(st.getInt());
st.saveItem(item);
if (st.aslong ) //Stored smthng
if (st.getInt() ) //Stored smthng
{
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS);
debugSerial<<F("Restored: ")<<st.h<<F(",")<<st.s<<F(",")<<st.v<<endl;
debugSerial<<F("Restored: ")<<st.param.h<<F(",")<<st.param.s<<F(",")<<st.param.v<<endl;
}
else
{
debugSerial<<st.aslong<<F(": No stored values - default\n");
st.h = 100;
st.s = 0;
st.v = 100;
st.hsv_flag=1;
debugSerial<<st.param.aslong<<F(": No stored values - default\n");
st.setDefault();
//st.param.hsv_flag=1; ///tyta
// Store
item->setVal(st.aslong);
//item->setVal(st.getInt());
st.saveItem(item);
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS );
}
PixelCtrl(&st,0,from,to);
PixelCtrl(st,from,to);
}
return 1;
case CMD_OFF:
if (subItem) // LED range, not whole strip
PixelCtrl(&st,CMD_OFF,from,to);
PixelCtrl(st.Cmd(CMD_OFF),from,to);
else
{
st.v=0;
PixelCtrl(&st,0,from,to);
st.Percents(0);
PixelCtrl(st,from,to);
item->SendStatus(SEND_COMMAND);
// if (send) item->publishTopic(item->itemArr->name,"OFF","/cmd");
}

View File

@@ -21,8 +21,9 @@ public:
int Status() override;
int isActive() override;
int getChanType() override;
int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
int PixelCtrl(itemStore *st, short cmd, int from =0 , int to = 1024, bool show = 1, bool rgb = 0);
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
int Ctrl(itemCmd cmd, int suffixCode=0, char* subItem=NULL) override;
int PixelCtrl(itemCmd cmd, int from =0 , int to = 1024, bool show = 1);
int numLeds;
int8_t pin;
int ledsType;