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

    How can i save my own code to the apps section?

    General
    2
    3
    3.2k
    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.
    • K
      Klingelfon
      last edited by Klingelfon

      I am very new to all this so i don´t really know much about it all. Altough i managed to program some code so that the Display turns when pressing button A, but as i am using USB Mode i cannot really save my code. It is only working aslong as i leave the M5Stack plugged in. When i plug it out i can´t acces the litlle programm.

      Sorry for the noob question and thanks in advance.

      My piece of code

      from m5ui import *
      from uiflow import *
      
      import imu
      
      
      setScreenColor(0x000000)
      
      lcd.setRotation(3)
      
      imu0 = imu.IMU()
      label0 = M5TextBox(133, 6, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0)
      label1 = M5TextBox(135, 107, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0)
      label2 = M5TextBox(131, 182, "Text", lcd.FONT_Default,0xFFFFFF, rotate=0)
      
      R = None
      b = None
      a = None
      
      
      def buttonA_wasPressed():
        global R, b, a
        if (-0.5 < imu0.acceleration[0] < 0.5):
          if (0.5 < imu0.acceleration[1] < 1.5):
            lcd.setRotation(1)
        if (-0.5 > imu0.acceleration[0] > -1.5):
          if (0.5 > imu0.acceleration[1] > -0.5):
            lcd.setRotation(2)
        if (-0.5 < imu0.acceleration[0] < 0.5):
          if (-0.5 > imu0.acceleration[1] > -1.5):
            lcd.setRotation(3)
        if (1.5 > imu0.acceleration[0] > 0.5):
          if (-0.5 < imu0.acceleration[1] < 0.5):
            lcd.setRotation(0)
      btnA.wasPressed(buttonA_wasPressed)
      
      
      while True:
        R = imu0.acceleration[0]
        label0.setText(str(R))
        b = imu0.acceleration[1]
        label1.setText(str(b))
        a = imu0.acceleration[2]
        label2.setText(str(a))
        wait(1)
        wait_ms(2)
      
      1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3
        last edited by

        If using uiflow, there is an option in settings to permanitly download programs written in micropython to the MStack or Stick

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • K
          Klingelfon
          last edited by

          Wow no Idea how i couldn´t find that. Thank you very much

          1 Reply Last reply Reply Quote 0
          • First post
            Last post