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

    Super simple RGB mixer

    Scheduled Pinned Locked Moved PROJECTS
    2 Posts 2 Posters 5.2k Views
    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
      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 Offline
        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

        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