Page 1 of 1
micropython-nano-gui with m5stickc.
Posted: Wed Apr 21, 2021 12:59 pm
by benalb
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?
Re: micropython-nano-gui with m5stickc.
Posted: Wed Apr 21, 2021 5:25 pm
by pythoncoder
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)
Re: micropython-nano-gui with m5stickc.
Posted: Thu Apr 22, 2021 4:12 pm
by benalb
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,

but with the gbr options, the colors are right.
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.