🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Error in comparison

    Scheduled Pinned Locked Moved M5 Stick/StickC
    1 Posts 1 Posters 1.1k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E Offline
      etolocka
      last edited by

      I'm trying to make a program to read the speed data from the Mini GPS/BDS module in UIFlow1 but I'm getting a confusing error.
      The code can be seen attached. The error occurs when I add the IF block and the comparison is something other than EQUAL. If the question is whether the first variable is greater than the second, on the M5Stick you briefly see the label with the speed value (0) but then a red circle with a cross inside appears, which I assume is an error signal.
      I find no problems in the Python code. The two variables are numerical and the comparison should not generate an error.
      What could be wrong?

      --Python code
      from m5stack import *
      from m5ui import *
      from uiflow import *
      import time
      import unit

      setScreenColor(0x111111)
      gps_0 = unit.get(unit.GPS, unit.PORTA)

      Velocidad = None

      label0 = M5TextBox(96, 23, "000", lcd.FONT_DejaVu72, 0xFFFFFF, rotate=90)
      label1 = M5TextBox(125, 32, "Velocidad", lcd.FONT_Default, 0xFFFFFF, rotate=90)
      label2 = M5TextBox(60, 169, "Km/h", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=90)

      gps_0.uart_port_id(1)
      gps_0.set_time_zone((-3))
      while True:
      Velocidad = gps_0.speed_kph
      label0.setText(str(Velocidad))
      if Velocidad > 110:
      label0.setColor(0xffffff)
      else:
      label0.setColor(0xff0000)
      wait(2)
      wait_ms(2)
      0_1714939873125_uiflow_block_1714939860442.png

      1 Reply Last reply Reply Quote 0

      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
      • First post
        Last post