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

    Error in comparison

    M5 Stick/StickC
    1
    1
    334
    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
      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
      • First post
        Last post