From 0474c0ac48b464068fad1ab507895f4e62c958d0 Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Fri, 2 Apr 2021 02:37:35 +0300 Subject: [PATCH] compilation fix, motor driver fix --- lighthub/modules/out_modbus.cpp | 9 +++++++- lighthub/modules/out_motor.cpp | 38 +++++++++++---------------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/lighthub/modules/out_modbus.cpp b/lighthub/modules/out_modbus.cpp index 02ca5d8..486272b 100644 --- a/lighthub/modules/out_modbus.cpp +++ b/lighthub/modules/out_modbus.cpp @@ -127,7 +127,14 @@ bool out_Modbus::getConfig() if (baudObj && baudObj->type == aJson_Int && baudObj->valueint) store->baud = baudObj->valueint; else store->baud = 9600; - modbusSerial.begin(store->baud, store->serialParam); + #if defined (__SAM3X8E__) + modbusSerial.begin(store->baud, static_cast (store->serialParam)); + #elif defined (ARDUINO_ARCH_ESP8266) + modbusSerial.begin(store->baud, static_cast (store->serialParam)); + #else + modbusSerial.begin(store->baud, (store->serialParam)); + #endif + aJsonObject * pollObj=aJson.getObjectItem(templateObj, "poll"); if (pollObj && pollObj->type == aJson_Object) { diff --git a/lighthub/modules/out_motor.cpp b/lighthub/modules/out_motor.cpp index 98ce60c..f15f9bf 100644 --- a/lighthub/modules/out_motor.cpp +++ b/lighthub/modules/out_motor.cpp @@ -85,7 +85,17 @@ return driverStatus; int out_Motor::isActive() { -return item->getVal(); +itemCmd st; +switch (item->getCmd()) +{ + case CMD_OFF: + case CMD_HALT: + return 0; + break; + default: +st.loadItem(item); +return st.getPercents(); +} } int out_Motor::Poll(short cause) @@ -114,7 +124,7 @@ switch (item->getCmd()) { case CMD_ON: case CMD_XON: - if (targetPos<15) targetPos=100; + //if (targetPos<15) targetPos=100; break; @@ -292,30 +302,6 @@ case S_CMD: switch (cmd.getCmd()) { case CMD_ON: - - /* - //retrive stored values - if (st.loadItem(item)) - { - if (st.getPercents() && (st.getPercents()SendStatus(SEND_COMMAND | SEND_PARAMETERS); - } - debugSerial<setVal(st); - item->SendStatus(SEND_COMMAND | SEND_PARAMETERS ); - } - */ if (item->getExt()) item->setExt(millisNZ()); //Extend motor time return 1;