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

    Super simple RGB mixer

    PROJECTS
    2
    2
    4.3k
    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
      ehm.education
      last edited by ehm.education

      0_1612452214674_IMG_20210204_162014.jpg

      My first time working with this hardware and UIflow / uPython I made a super simple RGB mixer.

      (ty felmue for teaching me how to format code)

      from m5stack import 
      from m5ui import 
      from uiflow import 
      
      setScreenColor(0x222222)
      
      varBarFactor = None
      varR = None
      varG = None
      varB = None
      varHexR = None
      varHexG = None
      varHexB = None
      
      lb_RGBval = M5TextBox(26, 8, RGB, lcd.FONT_UNICODE, 0xFFFFFF, rotate=90)
      rec_R = M5Rect(44, 240, 50, 0, 0xff0000, 0xff0000)
      rec_G = M5Rect(133, 240, 50, 0, 0x00ff00, 0x00ff00)
      rec_B = M5Rect(224, 240, 50, 0, 0x0000ff, 0x0000ff)
      
      def workR()
        global varBarFactor, varR, varG, varB, varHexR, varHexG, varHexB
        if btnA.isPressed()
          varR = varR + 1
          if varR  255
            varR = 0
          rec_R.setSize(height=int((varR  varBarFactor)))
          rec_R.setPosition(y=(240 - int((varR  varBarFactor))))
          varHexR = str(hex(varR))[2]
          if len(varHexR)  2
            varHexR = (str('0') + str(varHexR))
      
      def workG()
        global varBarFactor, varR, varG, varB, varHexR, varHexG, varHexB
        if btnB.isPressed()
          varG = varG + 1
          if varG  255
            varG = 0
          rec_G.setSize(height=int((varG  varBarFactor)))
          rec_G.setPosition(y=(240 - int((varG  varBarFactor))))
          varHexG = str(hex(varG))[2]
          if len(varHexG)  2
            varHexG = (str('0') + str(varHexG))
      
      def workB()
        global varBarFactor, varR, varG, varB, varHexR, varHexG, varHexB
        if btnC.isPressed()
          varB = varB + 1
          if varB  255
            varB = 0
          rec_B.setSize(height=int((varB  varBarFactor)))
          rec_B.setPosition(y=(240 - int((varB  varBarFactor))))
          varHexB = str(hex(varB))[2]
          if len(varHexB)  2
            varHexB = (str('0') + str(varHexB))
      
      lcd.setBrightness(10)
      varBarFactor = 0.95
      varHexR = '00'
      varHexG = '00'
      varHexB = '00'
      varR = 0
      varG = 0
      varB = 0
      while True
        workR()
        workG()
        workB()
        rgb.setColorAll((varR  16)  (varG  8)  varB)
        lb_RGBval.setText(str((str('RGB #') + str(((str(varHexR) + str(((str(varHexG) + str(varHexB))))))))))
        wait_ms(2)
      
      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by

        Hello @LasNiko

        nice project!

        You can use three backticks before and after the code. Full description here.

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

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