From 88d9c262af35333683def7d0b56640a16c7725c8 Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Sun, 22 Sep 2019 02:13:59 +0300 Subject: [PATCH] HALT, REST, XON, XOFF for drivers --- lighthub/item.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/lighthub/item.cpp b/lighthub/item.cpp index f7ba6e0..1fc962a 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -496,13 +496,56 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode } - if (driver) + if (driver) //New style modular code { - int res = driver->Ctrl(cmd, n, Parameters, send, suffixCode, subItem); - setCmd(cmd); + int res = -1; + switch (cmd) + { + case CMD_XON: + if (!chActive>0) //if channel was'nt active before CMD_XON + { + debugSerial<Ctrl(CMD_ON, n, Parameters, send, suffixCode, subItem); + setCmd(CMD_XON); + } + else + { //cmd = CMD_ON; + debugSerial<0) //if channel was active before CMD_HALT + { + res = driver->Ctrl(CMD_OFF, n, Parameters, send, suffixCode, subItem); + setCmd(CMD_HALT); + return res; + } + else + { + debugSerial<Ctrl(cmd, n, Parameters, send, suffixCode, subItem); + setCmd(CMD_OFF); + } + else + { + debugSerial<Ctrl(cmd, n, Parameters, send, suffixCode, subItem); + setCmd(cmd); + } return res; } - // Legacy code + // Legacy monolite core code bool toExecute = (chActive>0); //if channel is already active - unconditionally propogate changes switch (cmd) { case 0: // old style SET - with turning ON