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

    Convert ASCII to character on UiFlow 2.0

    Scheduled Pinned Locked Moved UiFlow 2.0
    2 Posts 1 Posters 1.7k 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.
    • nmstackN Offline
      nmstack
      last edited by

      Prova_basica_1:
      Captura de pantalla 2025-04-30 a las 14.49.52.png

      Prova_basica_2

      Captura de pantalla 2025-04-30 a las 14.52.25.png

      Hello there,

      I've almost arrived at my goal!

      I've almost arrived at my goal! But; I don't know how I should continue. I will send you two files. They're created with Uiflow 2.0. The first version, named Prova_basica_1 is absolutely functional, and the second one, named Prova_basica_2, is my nightmare!

      The trouble finds in the conversion from ASCII code to character, I can't do it

      Please, may you aid me?

      Thank you, and excuse me for the inconveniences.

      Best regards!

      P.S. In this message I send you two images from UiFlow 2.0 program and I've just attached below the code from two programs

      Code Prova_basica_1:

      import os, sys, io
      import M5
      from M5 import *
      from unit import CardKBUnit
      from hardware import I2C
      from hardware import Pin

      label0 = None
      i2c0 = None
      cardkb_0 = None

      text = None

      def cardkb_0_pressed_event(kb):
      global label0, i2c0, cardkb_0, text
      text = cardkb_0.get_string()
      M5.Lcd.printf(text)

      def setup():
      global label0, i2c0, cardkb_0, text

      M5.begin()
      Widgets.fillScreen(0x222222)
      label0 = Widgets.Label("label0", 105, 143, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)

      i2c0 = I2C(0, scl=Pin(33), sda=Pin(32), freq=100000)
      cardkb_0 = CardKBUnit(i2c0)
      cardkb_0.set_callback(cardkb_0_pressed_event)
      Widgets.fillScreen(0xffffff)
      M5.Lcd.startWrite()
      M5.Lcd.setCursor(10, 40)
      M5.Lcd.setTextSize(2)
      M5.Lcd.print('>>', 0x000000)

      def loop():
      global label0, i2c0, cardkb_0, text
      M5.update()
      cardkb_0.tick()

      if name == 'main':
      try:
      setup()
      while True:
      loop()
      except (Exception, KeyboardInterrupt) as e:
      try:
      from utility import print_error_msg
      print_error_msg(e)
      except ImportError:
      print("please update to latest firmware")

      Code Prova_basica_2:

      import os, sys, io
      import M5
      from M5 import *
      from unit import CardKBUnit
      from hardware import I2C
      from hardware import Pin

      label0 = None
      i2c0 = None
      cardkb_0 = None

      text = None
      text2 = None

      def cardkb_0_pressed_event(kb):
      global label0, i2c0, cardkb_0, text, text2
      text = cardkb_0.get_string()
      M5.Lcd.printf(text)
      text2 = str((chr(text)))
      label0.setText(str(text2))

      def setup():
      global label0, i2c0, cardkb_0, text, text2

      M5.begin()
      Widgets.fillScreen(0x222222)
      label0 = Widgets.Label("label0", 105, 143, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)

      i2c0 = I2C(0, scl=Pin(33), sda=Pin(32), freq=100000)
      cardkb_0 = CardKBUnit(i2c0)
      cardkb_0.set_callback(cardkb_0_pressed_event)
      Widgets.fillScreen(0xffffff)
      M5.Lcd.startWrite()
      M5.Lcd.setCursor(10, 40)
      M5.Lcd.setTextSize(2)
      M5.Lcd.print('>>', 0x000000)

      def loop():
      global label0, i2c0, cardkb_0, text, text2
      M5.update()
      cardkb_0.tick()

      if name == 'main':
      try:
      setup()
      while True:
      loop()
      except (Exception, KeyboardInterrupt) as e:
      try:
      from utility import print_error_msg
      print_error_msg(e)
      except ImportError:
      print("please update to latest firmware")

      Neus Morlà

      1 Reply Last reply Reply Quote 0
      • nmstackN Offline
        nmstack
        last edited by

        I got it!!

        Sorry, the trouble was very simple!... If you want, the solution is below:

        Captura de pantalla 2025-05-01 a las 1.37.42.png

        Neus Morlà

        1 Reply Last reply Reply Quote 1

        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