How to set data type and intial values.
birdsong last edited by birdsong
How can a make blockly keep a data type? this Function doesnt work, because 0.1 rounds down to 0 every time the code is executed. It is for an hour meter, I want to add 0.1 every 6mins.
This is what blockly automaticaly generates;
if bTm6min and bRunFan: fPvHrs = (fPvHrs if isinstance(fPvHrs, Number) else 0) + 0.1
When i manually change the code the problem goes away until blockly reverts back to the old code again.
fPvHrs = fPvHrs + 0.1
m5stack last edited by
the bug seem like from micropython. so , maybe you could use other way to change variable.
robalstona last edited by
Ewentually add 1 instead 0.1 and the end of your calculations divide a value by 10.
birdsong last edited by
if bRunFan and bRunFan != bRunFanOld: fPvHrs = 0.01 if bTm6min and bRunFan: fPvHrs = fPvHrs + 0.01 bRunFanOld = bRunFan
Thanks M5stack, this worked.
I didn't want to divide by 10 because I would have to do that everywhere, slow the execution speed, its a slippery slope. The esp32 has very long divide instruction time compared to addition and multiplication.