<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to set data type and intial values.]]></title><description><![CDATA[<p dir="auto">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.<br />
This is what blockly automaticaly generates;</p>
<pre><code>if bTm6min and bRunFan:
    fPvHrs = (fPvHrs if isinstance(fPvHrs, Number) else 0) + 0.1
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1592806689600-e35ec1e8-1252-4746-a254-da89f9c85bbc-image.png" alt="0_1592806677383_e35ec1e8-1252-4746-a254-da89f9c85bbc-image.png" class=" img-fluid img-markdown" /><br />
When i manually change the code the problem goes away until blockly reverts back to the old code again.</p>
<pre><code>fPvHrs = fPvHrs + 0.1</code></pre>
]]></description><link>https://community.m5stack.com/topic/2062/how-to-set-data-type-and-intial-values</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 10:03:57 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/2062.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 Jun 2020 06:18:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to set data type and intial values. on Mon, 22 Jun 2020 21:28:42 GMT]]></title><description><![CDATA[<p dir="auto"><img src="/assets/uploads/files/1592860979153-40e7c48f-ca80-431d-82c3-efcb57ba89cd-image.png" alt="0_1592860978166_40e7c48f-ca80-431d-82c3-efcb57ba89cd-image.png" class=" img-fluid img-markdown" /><br />
Converts to;</p>
<pre><code>  if bRunFan and bRunFan != bRunFanOld:
    fPvHrs = 0.01
  if bTm6min and bRunFan:
    fPvHrs = fPvHrs + 0.01
  bRunFanOld = bRunFan
</code></pre>
<p dir="auto">Thanks M5stack, this worked.<br />
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.</p>
]]></description><link>https://community.m5stack.com/post/9102</link><guid isPermaLink="true">https://community.m5stack.com/post/9102</guid><dc:creator><![CDATA[birdsong]]></dc:creator><pubDate>Mon, 22 Jun 2020 21:28:42 GMT</pubDate></item><item><title><![CDATA[Reply to How to set data type and intial values. on Mon, 22 Jun 2020 10:02:27 GMT]]></title><description><![CDATA[<p dir="auto">Ewentually add 1 instead 0.1 and the end of your calculations divide a value by 10.</p>
]]></description><link>https://community.m5stack.com/post/9096</link><guid isPermaLink="true">https://community.m5stack.com/post/9096</guid><dc:creator><![CDATA[robalstona]]></dc:creator><pubDate>Mon, 22 Jun 2020 10:02:27 GMT</pubDate></item><item><title><![CDATA[Reply to How to set data type and intial values. on Mon, 22 Jun 2020 07:57:25 GMT]]></title><description><![CDATA[<p dir="auto">the bug seem like from micropython. so , maybe you could use other way to change variable.<br />
eg:</p>
<p dir="auto"><img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/image/Forum_reply/variable.png" alt="替代文字" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/9095</link><guid isPermaLink="true">https://community.m5stack.com/post/9095</guid><dc:creator><![CDATA[m5stack]]></dc:creator><pubDate>Mon, 22 Jun 2020 07:57:25 GMT</pubDate></item></channel></rss>