How to set data type and intial values.
-
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 -
the bug seem like from micropython. so , maybe you could use other way to change variable.
eg:
-
Ewentually add 1 instead 0.1 and the end of your calculations divide a value by 10.
-

Converts to;if bRunFan and bRunFan != bRunFanOld: fPvHrs = 0.01 if bTm6min and bRunFan: fPvHrs = fPvHrs + 0.01 bRunFanOld = bRunFanThanks 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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login