<?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[DO-UNTIL loop]]></title><description><![CDATA[<p dir="auto">Hi there,</p>
<p dir="auto">what am I doing wrong? when I press button A the first time, the routine runs cleanly, i.e. I see the distance from the TOF unit, so we stay in the DO-UNTIL loop until the condition is met. If I then press the button A a second time, the routine will not run cleanly, i.e. we immediately break out of the DO-UNTIL loop. The next time I press button A the DO-UNTIL loop is correct again....etc.</p>
<p dir="auto">Thanks for the help.</p>
<p dir="auto">Regards,<br />
Mathias</p>
<p dir="auto">Translated with <a href="http://www.DeepL.com/Translator" target="_blank" rel="noopener noreferrer nofollow ugc">www.DeepL.com/Translator</a> (free version)</p>
<p dir="auto"><img src="/assets/uploads/files/1623015179422-bildschirmfoto-2021-06-06-um-23.31.02-resized.png" alt="0_1623015178487_Bildschirmfoto 2021-06-06 um 23.31.02.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/topic/3350/do-until-loop</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 06:42:29 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/3350.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 06 Jun 2021 21:39:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DO-UNTIL loop on Mon, 21 Jun 2021 08:42:19 GMT]]></title><description><![CDATA[<p dir="auto">Hey robalstona,</p>
<p dir="auto">Thanks for your answer. You are right this could be the problem. I will try it out in the near future.</p>
<p dir="auto">cheers,<br />
Mathias</p>
]]></description><link>https://community.m5stack.com/post/14161</link><guid isPermaLink="true">https://community.m5stack.com/post/14161</guid><dc:creator><![CDATA[mathias]]></dc:creator><pubDate>Mon, 21 Jun 2021 08:42:19 GMT</pubDate></item><item><title><![CDATA[Reply to DO-UNTIL loop on Mon, 07 Jun 2021 20:24:35 GMT]]></title><description><![CDATA[<p dir="auto">Hey, the problem of your button handler function is its duration (a good 6 seconds if not more).  The problem will be when you call that function again before it finishes its previous action. Uiflow is also a bit weird in automatically generating code based on blocks. And for example all variables declared in functions and callbacks are generated as global variables, not as local as it would look from block vizualization.</p>
<p dir="auto">And now your key handler function runs and sets a control variable (global) then conditions its further action on this variable.<br />
In the meantime you run a second instance of the "same" function which suspends the first one and now this second instance of the function changes the values of your variables (global) which after the end of this instance of the function will still be used by the previously called function. Alternatively, the action of this second function will be determined by what variables were changed by the first function call.</p>
<p dir="auto">You can check at the very beginning of the function if the variable is_running (example name) is True, if so, exit the function. Then you set is_running to true, then your code and at the very end of your code in the function you set is_running to false. Then next execution of this function during previous one will break it.</p>
<p dir="auto">Something like this</p>
<pre><code># initial value of semafor
# put below line at begining
# of your program
is_running = False


# put this inside your function
if is_running:
    return
else:
    is_running = True
    # insert
    # your code
    # here
    is running = False
</code></pre>
]]></description><link>https://community.m5stack.com/post/14025</link><guid isPermaLink="true">https://community.m5stack.com/post/14025</guid><dc:creator><![CDATA[robalstona]]></dc:creator><pubDate>Mon, 07 Jun 2021 20:24:35 GMT</pubDate></item></channel></rss>