micropython-nano-gui with m5stickc.

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
benalb
Posts: 24
Joined: Fri May 19, 2017 1:23 pm

micropython-nano-gui with m5stickc.

Post by benalb » Wed Apr 21, 2021 12:59 pm

I'v managed to run nano-gui in the m5stickc with pure micropython, no uiflow firmware. I've copypasted the rgb function

Code: Select all

def rgb(r, g, b): 
        return (r & 0xe0) | ((g >> 3) & 0x1c) | (b >> 6)
from drivers/st7735r.py to https://github.com/lukasmaximus89/M5Sti ... ckc_lcd.py
and changed color_setup.py to

Code: Select all

from m5stickc_lcd import ST7735 as SSD 
ssd = SSD()
So far, so good, it works, kinda. The colors are odd, the white appears as yellow, grey as green, in fact everything seems a little greenish.

Any suggestion about where should I look to show the right colors?

User avatar
pythoncoder
Posts: 5144
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: micropython-nano-gui with m5stickc.

Post by pythoncoder » Wed Apr 21, 2021 5:25 pm

The rgb() function you copied converts 24-bit rgb color values to an 8-bit result, for use with a bytearray buffer. This is a RAM saving device: I use GS8 mode for the underlying framebuf, with values being expanded to 12-bit at runtime. I'm surprised the result looks remotely correct!

Given that you are using RGB565 with 16 bit color values I think you want something like this:

Code: Select all

def rgb(r, g, b):
    return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3)
Peter Hinch

User avatar
benalb
Posts: 24
Joined: Fri May 19, 2017 1:23 pm

Re: micropython-nano-gui with m5stickc.

Post by benalb » Thu Apr 22, 2021 4:12 pm

pythoncoder wrote:
Wed Apr 21, 2021 5:25 pm
Given that you are using RGB565 with 16 bit color values I think you want something like this:
Thank you very much, Peter. It almost worked, but I have to change the function to:

Code: Select all

    def rgb(g, b, r):
        return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3)
Note the different order of params, gbr, not rgb.

With the logical order, the colors are swapped, Image
but with the gbr options, the colors are right. Image

By the way, it is really hard to take a photo of that litle screen. Anyways, thank you very much for your help and for nano-gui.

Edit: it seems I am not able to show the images, the urls are: https://imgur.com/RAqfZwN for the wrong colors and https://imgur.com/TEqZlJV for the right ones.

Post Reply