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

    Display.drawRawBuf example in UIFlow docs doesn't work on M5StickC Plus2

    Lessons and Guides
    1
    1
    12
    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.
    • A
      AyreGuitar
      last edited by

      Hi, I'm a new user of M5stack products, having got an M5StickC Plus2 recently. It's a nice device, but the documentation isn't always accurate which makes learning how to use it a slow process.
      I tried to use the example for drawing a raw buffer to the screen here
      But it resulted in different garbled output each time and not a green rectangle.
      It seems that the len parameter is expecting 16-bit entries in the buffer so needs to be halved.
      Here's the code that works on my device (note the //2 for len parameter):

      width, height = 40, 30
      green565 = 0x07E0
      raw_buf = bytearray(width * height * 2)
      for i in range(width * height):
          raw_buf[2*i]   = (green565 >> 8) & 0xFF
          raw_buf[2*i+1] = green565 & 0xFF
      Display.drawRawBuf(raw_buf, 100, 100, width, height, len(raw_buf)//2, swap=False)
      

      Hopefully this will help others and eventually get changed in the docs - assuming it's the same for all UIFlow2 supported devices?

      If anybody knows a fix to make it work properly for lower than 16bit depth screens so I can draw a raw buffer to a 1-bit canvas properly, please let me know!

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