<?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[isPressed? wasPressed? What&#x27;s the difference?]]></title><description><![CDATA[<p dir="auto">My impression was that <code>isPressed</code> reads the immediate state of the button, but <code>wasPressed</code>indicates that the button was pressed at some point. But trying it out, that doesn't seem to be the case:</p>
<pre><code>for count in range(10000):
  wait_ms(1)
label0.setText(str(btnA.wasPressed()))
</code></pre>
<p dir="auto">Displays <code>False</code>, as does putting <code>isPressed()</code> in there, no matter how many times I press the button.</p>
<p dir="auto">So, what is the difference?</p>
]]></description><link>https://community.m5stack.com/topic/1914/ispressed-waspressed-what-s-the-difference</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 15:45:44 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/1914.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Apr 2020 02:28:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to isPressed? wasPressed? What&#x27;s the difference? on Sat, 13 Jun 2020 03:52:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dclaar" aria-label="Profile: dclaar">@<bdi>dclaar</bdi></a> isPressed() reflects current state of the button (is it pressed?), and returns a Boolean. wasPressed() is an event trigger you use to execute code when the button is pressed.</p>
<p dir="auto">Sample code below (generated from uiflow) to illustrate.</p>
<pre><code class="language-py">from m5stack import *
from m5ui import *
from uiflow import *
lcd.setRotation(1)

setScreenColor(0x111111)

isExit = None

def buttonB_wasPressed():
  global isExit
  isExit = True
  pass
btnB.wasPressed(buttonB_wasPressed)

setScreenColor(0x000000)
axp.setLcdBrightness(40)
isExit = False
while isExit == False:
  lcd.print((btnA.isPressed()), 3, 0, 0xffffff)

</code></pre>
]]></description><link>https://community.m5stack.com/post/8974</link><guid isPermaLink="true">https://community.m5stack.com/post/8974</guid><dc:creator><![CDATA[jhfoo]]></dc:creator><pubDate>Sat, 13 Jun 2020 03:52:09 GMT</pubDate></item><item><title><![CDATA[Reply to isPressed? wasPressed? What&#x27;s the difference? on Thu, 30 Apr 2020 08:26:13 GMT]]></title><description><![CDATA[<p dir="auto"><strong>Ispressed</strong> is used to preform an action when a button is pressed.<br />
<strong>Waspressed</strong> is used when you want an action dependent on how long the button was held down for.</p>
<p dir="auto"><strong>Ispressed</strong> is a command block and requires other blocks and commands for use whereas,<br />
<strong>Waspressed</strong> is a loop function that is used to control other blocks/commands.</p>
]]></description><link>https://community.m5stack.com/post/8447</link><guid isPermaLink="true">https://community.m5stack.com/post/8447</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Thu, 30 Apr 2020 08:26:13 GMT</pubDate></item></channel></rss>