counter fix

This commit is contained in:
Климов Андрей Николаевич
2023-04-10 00:01:20 +03:00
parent bab472d2d1
commit 927272824c
2 changed files with 9 additions and 5 deletions

View File

@@ -13,7 +13,8 @@ static int driverStatus = CST_UNKNOWN;
void out_counter::getConfig() void out_counter::getConfig()
{ {
if (!item) return; if (!item) return;
impulse = item->getFloatArg(0); impulse = item->getFloatArg(0)*TENS_BASE;
period = item->getFloatArg(1)*1000.0; period = item->getFloatArg(1)*1000.0;
//debugSerial<<"CTR: imp:"<<impulse<<" period:"<<period<<endl; //debugSerial<<"CTR: imp:"<<impulse<<" period:"<<period<<endl;
} }
@@ -51,12 +52,14 @@ uint32_t timer = item->getExt();
itemCmd st; itemCmd st;
st.loadItem(item,FLAG_PARAMETERS|FLAG_COMMAND); st.loadItem(item,FLAG_PARAMETERS|FLAG_COMMAND);
float val = st.getFloat(); //float val = st.getFloat();
uint32_t val = st.getTens_raw();
//short cmd = st.getCmd(); //short cmd = st.getCmd();
debugSerial<<"CTR: tick val:"<<val<<endl; debugSerial<<"CTR: tick val:"<<val<< " + "<< impulse << endl;
val+=impulse; val+=impulse;
st.Float(val); //st.Float(val);
st.Tens_raw(val);
st.saveItem(item); st.saveItem(item);
debugSerial<<"CTR: tick saved val:"<<val<<endl; debugSerial<<"CTR: tick saved val:"<<val<<endl;
item->SendStatus(FLAG_PARAMETERS); item->SendStatus(FLAG_PARAMETERS);

View File

@@ -20,7 +20,8 @@ public:
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override; int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
protected: protected:
float impulse; //float impulse;
uint32_t impulse;
uint32_t period; uint32_t period;
}; };
#endif #endif