Refactoring #4 (untested)

This commit is contained in:
2020-11-17 20:13:06 +03:00
parent 963a934f51
commit 14ff55fd59
15 changed files with 311 additions and 211 deletions

View File

@@ -45,27 +45,44 @@ return 0;
int out_dmx::getChanType()
{
if (item) return item->itemType;
if (item)
{
switch (numArgs)
{
case 3:
return CH_RGB;
case 4:
return CH_RGBW;
default:
return item->itemType;
}
return 0;
}
}
int out_dmx::PixelCtrl(itemCmd cmd)
int out_dmx::PixelCtrl(itemCmd cmd, char* subItem, bool show)
//int out_dmx::PixelCtrl(itemCmd cmd)
{
if (!item) return 0;
int iaddr = item->getArg(0);
itemCmd st(ST_RGB);
if (!item || !show) return 0;
short cType=getChanType();
if (cType==CH_DIMMER) //Single channel
{
DmxWrite(iaddr, cmd.getPercents255());
return 1;
}
itemCmd st(ST_RGB,CMD_VOID);
st.assignFrom(cmd);
switch (getChanType())
{ case CH_DIMMER:
DmxWrite(iaddr + 3, cmd.getPercents255());
break;
switch (cType)
{
case CH_RGBW:
DmxWrite(iaddr + 3, st.param.w);
DmxWrite(getChannelAddr(3), st.param.w);
case CH_RGB:
DmxWrite(iaddr, st.param.r);
DmxWrite(iaddr + 1, st.param.g);
DmxWrite(iaddr + 2, st.param.b);
DmxWrite(getChannelAddr(1), st.param.g);
DmxWrite(getChannelAddr(2), st.param.b);
break;
default: ;
}