Giter VIP home page Giter VIP logo

gc9a01_mpy's Introduction

GC9A01 Display Driver for MicroPython

GC9A01 display photo

This driver is based on devbis' st7789_mpy driver. I modified the original driver for one of my projects to add:

  • Display Rotation.
  • Scrolling
  • Writing text using bitmaps converted from True Type fonts
  • Drawing text using 8 and 16 bit wide bitmap fonts
  • Drawing text using Hershey vector fonts
  • Drawing JPG's, including a SLOW mode to draw jpg's larger than available ram using the TJpgDec - Tiny JPEG Decompressor R0.01d. from http://elm-chan.org/fsw/tjpgd/00index.html

Included are 12 bitmap fonts derived from classic pc text mode fonts, 26 Hershey vector fonts and several example programs for different devices. The driver supports 240x240 displays.

Documentation

Documentation can be found in the docs directory and at https://russhughes.github.io/gc9a01_mpy/

Pre-compiled firmware files

The firmware directory contains pre-compiled firmware for various devices with the gc9a01 C driver and frozen python font files. See the README.md file in the fonts folder for more information on the font files.

ESP32 BOARDS firmware

  • ARDUINO_NANO_ESP32
  • ESP32_GENERIC with 4, 8, 16, or 32MB flash
  • ESP32_GENERIC_C3 with 4, 8, 16, or 32MB flash
  • ESP32_GENERIC_S2 with 4, 8, 16, or 32MB flash
  • ESP32_GENERIC_S3 with 4, 8, 16, or 32MB flash
  • LILYGO_TTGO_LORA32
  • LOLIN_C3_MINI
  • LOLIN_S2_MINI
  • LOLIN_S2_PICO
  • M5STACK_ATOM
  • OLIMEX_ESP32_POE
  • SIL_WESP32
  • UM_FEATHERS2
  • UM_FEATHERS2NEO
  • UM_FEATHERS3
  • UM_NANOS3
  • UM_PROS3
  • UM_TINYPICO
  • UM_TINYS2
  • UM_TINYS3
  • UM_TINYWATCHS3

RP2040 BOARDS firmware

  • ADAFRUIT_ITSYBITSY_RP2040
  • ADAFRUIT_QTPY_RP2040
  • ARDUINO_NANO_RP2040_CONNECT
  • ADAFRUIT_FEATHER_RP2040
  • GARATRONIC_PYBSTICK26_RP2040
  • NULLBITS_BIT_C_PRO
  • PIMORONI_PICOLIPO_16MB
  • PIMORONI_PICOLIPO_4MB
  • PIMORONI_TINY2040
  • RPI_PICO
  • RPI_PICO_W
  • SPARKFUN_PROMICRO
  • SPARKFUN_THINGPLUS
  • W5100S_EVB_PICO
  • W5500_EVB_PICO
  • WAVESHARE_RP2040_LCD_1.28
  • WEACTSTUDIO

This is a work in progress.

-- Russ

gc9a01_mpy's People

Contributors

russhughes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gc9a01_mpy's Issues

Help wanted: Showing RPI OS GUI on 240x240 GC9A01 lcd screen ⌚

Any idea how to do it?

I just want to play a video on the small round screen.
I am connected via SPI, rpi 3 b, and managed to show an image, that's it.

Showing the GUI and running omxplayer sounded like a good idea.
But also, showing the video via a python script sounds great.

tft_config.py for M5Dial?

Hi,
I tried to create the tft_config.py for M5Dial, but failed.

according to this link .https://github.com/Gitshaoxiang/M5Dial-Gui-Demo/blob/40357725d0c812131e28543a6e4f23a7981d6282/components/esp_lvgl_port/examples/touchscreen/main/main.c#L37

/* LCD settings */
#define EXAMPLE_LCD_SPI_NUM (SPI3_HOST)
#define EXAMPLE_LCD_PIXEL_CLK_HZ (40 * 1000 * 1000)
#define EXAMPLE_LCD_CMD_BITS (8)
#define EXAMPLE_LCD_PARAM_BITS (8)
#define EXAMPLE_LCD_COLOR_SPACE (ESP_LCD_COLOR_SPACE_BGR)
#define EXAMPLE_LCD_BITS_PER_PIXEL (16)
#define EXAMPLE_LCD_DRAW_BUFF_DOUBLE (1)
#define EXAMPLE_LCD_DRAW_BUFF_HEIGHT (50)
#define EXAMPLE_LCD_BL_ON_LEVEL (1)

/* LCD pins */
#define EXAMPLE_LCD_GPIO_SCLK (GPIO_NUM_7)
#define EXAMPLE_LCD_GPIO_MOSI (GPIO_NUM_6)
#define EXAMPLE_LCD_GPIO_RST (GPIO_NUM_48)
#define EXAMPLE_LCD_GPIO_DC (GPIO_NUM_4)
#define EXAMPLE_LCD_GPIO_CS (GPIO_NUM_5)
#define EXAMPLE_LCD_GPIO_BL (GPIO_NUM_45)

I created this , but not working, can someone helps, TIA.

`
spi = SPI(1, baudrate=40000000, sck=Pin(7), mosi=Pin(6))
return gc9a01.GC9A01(
spi,
240,
240,
reset=Pin(48, Pin.OUT),
cs=Pin(5, Pin.OUT),
dc=Pin(4, Pin.OUT),
backlight=Pin(45, Pin.OUT),
rotation=rotation,
options=options,
buffer_size=buffer_size
)

`

Request GC9A01 for Waveshare ESP32-S3 Round 1.28"

Russ,

I want you to know I am a huge fan of your work and have already done extensive projects using your GC9AO1 Waveshare Round Display Driver for RP2040.

Right now, I am pushing the envelope and would love to leverage the ESP32-S3 wireless capabilities that are now tied into the Round Waveshare display. This could be a gamechanger. If you are willing, would appreciate a Waveshare round display driver for this, similar to the one you did for the RP2040.

https://www.waveshare.com/esp32-s3-lcd-1.28.htm

Thank you so much for all you do, you have made a big difference for me! Thank you!

draw_arc is missing

Flashed new firmware this morning, fill_arc works fine, draw_arc appears to be missing.

>>> dir(GC9A01)
['__class__', '__name__', 'write', '__bases__', '__dict__', 'arc', 'bitmap', 'blit_buffer', 'bounding', 'circle', 'draw', 'draw_len', 'fill', 'fill_arc', 'fill_circle', 'fill_polygon', 'fill_rect', 'hard_reset', 'height', 'hline', 'init', 'inversion_mode', 'jpg', 'line', 'map_bitarray_to_rgb565', 'off', 'offset', 'on', 'pbitmap', 'pixel', 'polygon', 'polygon_center', 'rect', 'rotation', 'set_window', 'sleep_mode', 'soft_reset', 'text', 'vline', 'vscrdef', 'vscsad', 'width', 'write_len']

Accessing the fonts of the pre-build Firmwares

The readme states: The firmware directory contains pre-compiled firmware ... with ...frozen python font files.

Now, how do you access them?
I tried - import NotoSans_32 as font0 but get an import error : ImportError: no module named 'NotoSans_32'
I'm using the RP2 Firmware.

Btw: the example images in the readme of the vector fonts are broken

convert image to python module

I want to realize the project about convert image to python module ,but when I use the command python ./imgtobitmap.py t1.png 3 >test.py
an error message:

img = img.convert("P", palette=Image.ADAPTIVE, colors=2**bits)
Traceback (most recent call last):

File "./imgtobitmap.py", line 101, in
main()
File "./imgtobitmap.py", line 43, in main
((palette[color*3] & 0xF8) << 8)
IndexError: list index out of range

so I change the parameter (bits) to 2 . Luckily, it succeed ,but I execute the project code a new error coming:

Traceback (most recent call last):
File "", line 60, in
File "", line 59, in main
TypeError: can't convert str to int

Maybe the error caused by the parameter(bits)

Here are my codes:

from machine import Pin, SPI
import gc9a01
import test


def main():
    '''
    Draw and move sprite
    '''
    spi = SPI(2, baudrate=60000000, sck=Pin(18), mosi=Pin(23))
    tft = gc9a01.GC9A01(
        spi,
        240,
        240,
        reset=Pin(26, Pin.OUT),
        cs=Pin(5, Pin.OUT),
        dc=Pin(27, Pin.OUT),
        backlight=Pin(2, Pin.OUT),
        rotation=0)

    # enable display and clear screen
    tft.init()
    tft.fill(gc9a01.BLACK)

  
    tft.bitmap(test,50,50)
main() 

Convert result Test.py

HEIGHT = 64
WIDTH = 64
COLORS = 4
BITS = 8192
BPP = 2
PALETTE = [0x0000,0x4049,0x609b,0x4082]

image

Display only working when code is executed from Thonny or run manually from REPL via serial.

Hello,

sorry to bother you with another "issue".
As the title says, I've successfully integrated with your library, and all seemed to work just fine, and was able to progress with my project.

I wanted it to run from autostart, via main.py. I reboot the board, and surprise and shock ensued. The backlight is on, the display flickers for a split second or so (probably because of tft.init() and `tft.fill()) than nothing else is displayed.

Do you have any experience with this kind of issue, or behaviour? Do I need to add something extra, or add more sleeps in?

I read some topics on the internet, where people have added a time.sleep(1.5) before initializing the OLED displays. I tried that too, in hope that it'll allow me to stop pulling my hair out.

I'm not sure what else to try out.

thank you kindly for any information or suggestion you might have!

Backlight control

A suggestion:

Can you expose Backlight control

Found a work around:

    tft.init()
    blPWM = PWM(Pin(BL))
    blPWM.freq(5000)
    blPWM.duty_u16(100) 

Problem compiling.

I am sure I am doing something wrong, but I am trying to compile the for an RP2040 board, and getting very strange results.

I was using you 7789 instructions, and tried to use for this was well.

I get the following issues::

/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c:121:6: error: 'mp_obj_type_t' {aka 'const struct _mp_obj_type_t'} has no member named 'print'
121 | .print = mp_file_print,
| ^~~~~
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c:121:14: error: initialization of 'unsigned char' from 'void (*)(const mp_print_t *, void , mp_print_kind_t)' {aka 'void ()(const struct _mp_print_t *, void *, mp_print_kind_t)'} makes integer from pointer without a cast [-Werror=int-conversion]
121 | .print = mp_file_print,
| ^~~~~~~~~~~~~
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c:121:14: note: (near initialization for 'mp_file_type.slot_index_make_new')
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c:121:14: error: initializer element is not computable at load time
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c:121:14: note: (near initialization for 'mp_file_type.slot_index_make_new')
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c:122:6: error: 'mp_obj_type_t' {aka 'const struct _mp_obj_type_t'} has no member named 'locals_dict'
122 | .locals_dict = (mp_obj_dict_t *)&mp_file_locals_dict,
| ^~~~~~~~~~~
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c:122:20: error: initialization of 'unsigned char' from 'mp_obj_dict_t *' {aka 'struct _mp_obj_dict_t *'} makes integer from pointer without a cast [-Werror=int-conversion]
122 | .locals_dict = (mp_obj_dict_t )&mp_file_locals_dict,
| ^
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c:122:20: note: (near initialization for 'mp_file_type.slot_index_print')
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c:122:20: error: initializer element is not computable at load time
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c:122:20: note: (near initialization for 'mp_file_type.slot_index_print')
cc1: all warnings being treated as errors
make[3]: *** [CMakeFiles/firmware.dir/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/mpfile.c.obj] Error 1
make[3]: *** Waiting for unfinished jobs....
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c: In function 'write_spi':
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:59:67: error: 'mp_obj_type_t' {aka 'const struct _mp_obj_type_t'} has no member named 'protocol'
59 | mp_machine_spi_p_t spi_p = (mp_machine_spi_p_t)spi_obj->type->protocol;
| ^~
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c: At top level:
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1483:6: error: 'mp_obj_type_t' {aka 'const struct _mp_obj_type_t'} has no member named 'print'
1483 | .print = gc9a01_GC9A01_print,
| ^~~~~
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1483:14: error: initialization of 'unsigned char' from 'void (
)(const mp_print_t , void , mp_print_kind_t)' {aka 'void ()(const struct _mp_print_t , void , mp_print_kind_t)'} makes integer from pointer without a cast [-Werror=int-conversion]
1483 | .print = gc9a01_GC9A01_print,
| ^~~~~~~~~~~~~~~~~~~
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1483:14: note: (near initialization for 'gc9a01_GC9A01_type.slot_index_make_new')
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1483:14: error: initializer element is not computable at load time
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1483:14: note: (near initialization for 'gc9a01_GC9A01_type.slot_index_make_new')
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1484:6: error: 'mp_obj_type_t' {aka 'const struct _mp_obj_type_t'} has no member named 'make_new'
1484 | .make_new = gc9a01_GC9A01_make_new,
| ^~~~~~~~
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1484:17: error: initialization of 'unsigned char' from 'void * (
)(const mp_obj_type_t , size_t, size_t, void * const)' {aka 'void * (
)(const struct _mp_obj_type_t , unsigned int, unsigned int, void * const)'} makes integer from pointer without a cast [-Werror=int-conversion]
1484 | .make_new = gc9a01_GC9A01_make_new,
| ^~~~~~~~~~~~~~~~~~~~~~
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1484:17: note: (near initialization for 'gc9a01_GC9A01_type.slot_index_print')
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1484:17: error: initializer element is not computable at load time
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1484:17: note: (near initialization for 'gc9a01_GC9A01_type.slot_index_print')
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1485:6: error: 'mp_obj_type_t' {aka 'const struct _mp_obj_type_t'} has no member named 'locals_dict'
1485 | .locals_dict = (mp_obj_dict_t
)&gc9a01_GC9A01_locals_dict,
| ^~~~~~~~~~~
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1485:20: error: initialization of 'unsigned char' from 'mp_obj_dict_t *' {aka 'struct _mp_obj_dict_t '} makes integer from pointer without a cast [-Werror=int-conversion]
1485 | .locals_dict = (mp_obj_dict_t
)&gc9a01_GC9A01_locals_dict,
| ^
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1485:20: note: (near initialization for 'gc9a01_GC9A01_type.slot_index_call')
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1485:20: error: initializer element is not computable at load time
/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c:1485:20: note: (near initialization for 'gc9a01_GC9A01_type.slot_index_call')
cc1: all warnings being treated as errors
make[3]: *** [CMakeFiles/firmware.dir/Users/bhrobinson/git/Pico/usermodules/gc9a01_mpy/src/gc9a01.c.obj] Error 1
make[2]: *** [CMakeFiles/firmware.dir/all] Error 2
make[1]: *** [all] Error 2
-e See https://github.com/micropython/micropython/wiki/Build-Troubleshooting
make: *** [all] Error 1

Build against Pimoroni Micropython

Space permitting, it would be nice to have this driver also built against the Pimoroni version of Micropython, as that includes a lot of useful features.

compile error

Looking for some help with a compiling error for not liking STATIC. I'm going to be verbose just to see where I may have gone wrong.

I'm compiling using Windows 11 Pro using the following installation:

repos pulled to C:\Repos\gc9a01_mpy, C:\Repos\micropython, C:\Repos\btstack

wsl install
sudo apt update
sudo apt install gcc g++ make cmake
sudo apt-get install gcc-arm-none-eabi

vi ~/.bashrc
add line: export PICO_BTSTACK_PATH=/mnt/c/Repos/btstack

cd /mnt/c/Repos/micropython
make -C micropython/mpy-cross

cd micropython/ports/rp2

make
BOARD=RPI_PICO
FROZEN_MANIFEST=../../../../gc9a01_mpy/manifest.py
USER_C_MODULES=../../../gc9a01_mpy/src/micropython.cmake
submodules clean all

Clean build gets to about 74% and then we see a few different errors starting with not liking the STATIC keyword.

Error:

STATIC mp_obj_t gc9a01_GC9A01_init(mp_obj_t self_in); this line is causeing /mnt/c/Repos/gc9a01_mpy/src/gc9a01.c:173:1: error: unknown type name 'STATIC' 173 | STATIC mp_obj_t gc9a01_GC9A01_init(mp_obj_t self_in);

Without cleaning we see:

[ 5%] Building C object CMakeFiles/firmware.dir/mnt/c/Repos/gc9a01_mpy/src/gc9a01.c.obj
/mnt/c/Repos/gc9a01_mpy/src/gc9a01.c:176:7: error: expected ';' before 'void'
176 | STATIC void gc9a01_GC9A01_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
| ^~~~~
| ;

/mnt/c/Repos/gc9a01_mpy/src/gc9a01.c:402:1: error: unknown type name 'STATIC'
402 | STATIC mp_obj_t gc9a01_GC9A01_hard_reset(mp_obj_t self_in) {
| ^~~~~~

UnicodeError

I am getting a UnicodeError when trying to open this as a bytes file. I am trying to convert these to .py files. Here is the related issue which routes me back here as a bug.

BUG

with open("dc540_logo.jpg", "rb") as f:
    b = f.read()  # Image as an array of bytes
    display.jpg(b, 0, 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "main.py", line 109, in <module>
UnicodeError: 
>>> 

Can't compile firmware for ESP8266

Hello there,
first of all thanks a lot for the provided code, I really appreciate your effort!

Since I am a noob when it comes to compiling in general and I am merely able to write a simple script in Python, I'd like to reach out to you. I am using a Wemos D1 mini ESP8266 board. I have put your library inside the ~/micropython/drivers folder. I am using the micropython 1.20 branch. I also tried it with the 1.19.1 branch.

I got the compiling the firmware running with the docker container using the following input and I was able to add the cexample code from micropython and successfully tested the cexample class:
docker run --rm -v $HOME:$HOME -u $UID -w $PWD larsks/esp-open-sdk make -j 4 V=1 USER_C_MODULES=/home/richy/micropython/examples/usercmodule/

When I use the input provided in your README.MD, the gc9a01-code will not be put inside the firmware binary:
docker run --rm -v $HOME:$HOME -u $UID -w $PWD larsks/esp-open-sdk make V=1 USER_C_MODULES=/home/richy/micropython/drivers/gc9a01_mpy-main/src/micropython.cmake all

I can compile a binary file but when I flash it to the ESP8266 I get "no module named 'gc9a01'"

>>> import gc9a01
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'gc9a01'

So I tried adding your gc9a01 library using the following input:
docker run --rm -v $HOME:$HOME -u $UID -w $PWD larsks/esp-open-sdk make V=1 USER_C_MODULES=/home/richy/micropython/drivers/gc9a01_mpy-main

I get the following error message (see the full output in the file attached):

xtensa-lx106-elf-ld: region 'iram1_0_seg' overflowed by 15976 bytes
build-GENERIC/src/gc9a01.o:(.text.gc9a01_GC9A01_draw+0x1c): undefined reference to 'lround'
build-GENERIC/src/gc9a01.o: In function 'gc9a01_GC9A01_draw':
/home/richy/micropython/drivers/gc9a01_mpy-main/src/gc9a01.c:474: undefined reference to 'lround'
/home/richy/micropython/drivers/gc9a01_mpy-main/src/gc9a01.c:476: undefined reference to 'lround'
/home/richy/micropython/drivers/gc9a01_mpy-main/src/gc9a01.c:478: undefined reference to 'lround'
/home/richy/micropython/drivers/gc9a01_mpy-main/src/gc9a01.c:489: undefined reference to 'lround'
make: *** [Makefile:231: build-GENERIC/firmware.elf] Error 1

Please advise.

Thanks a lot in advance,
Richard

compile_output.txt

Wiring Diagram

Hello,

Thank you for making this possible!

Do you happen to have a wiring diagram? the picture provided is a bit blurry in the background, and cannot distinguish which wire goes where.
Thank you kindly.

Stay safe,
Adrian

own jpgs

Sorry, another question: Can display example jpgs, but no own with error: RuntimeError: jpg prepare failed.
I prepare the jpg with: magick tt6.jpg -resize 40x40 -sampling-factor 4:2:0 -strip -quality 85 -interlace none -colorspace RGB tt7.jpg
I also tried differnt buffersizes.
Thanks.

`'''
jpg.py

Draw a full screen jpg using the slower but less memory intensive method
of blitting each Minimum Coded Unit (MCU) block. Usually 8×8 pixels but can
be other multiples of 8.

GC9A01 display connected to a Raspberry Pi Pico.

Pico Pin   Display
=========  =======
14 (GP10)  BL
15 (GP11)  RST
16 (GP12)  DC
17 (GP13)  CS
18 (GND)   GND
19 (GP14)  CLK
20 (GP15)  DIN

bigbuckbunny.jpg (c) copyright 2008, Blender Foundation / www.bigbuckbunny.org

'''

import gc
import time
from machine import Pin, SPI
import gc9a01

gc.enable()
gc.collect()

def main():
'''
Decode and draw jpg on display
'''
spi = SPI(1, baudrate=60000000, sck=Pin(10), mosi=Pin(11))
tft = gc9a01.GC9A01(
spi,
240,
240,
reset=Pin(12, Pin.OUT),
cs=Pin(9, Pin.OUT),
dc=Pin(8, Pin.OUT),
backlight=Pin(25, Pin.OUT),
rotation=1,
buffer_size=0)

# enable display and clear screen
tft.init()

# cycle thru jpg's
while True:
    for image in ["tt7.jpg"]:
        tft.jpg(image, 0, 0, gc9a01.SLOW)
        time.sleep(5)

main()

`

Fonts not available in self-build firmware

I build the esp32 firmware port including this framework according to your guide. The module for the screen is available, but non of the fonts show up available for import. Did i miss anything in the guide or did someone forget to put it in? I'd like to have at least 1 font available to display text.

Little mistake in documentation chapter 'working example'

Tested (success) with micropython >V1.20 (idf 5.02), there is little mistake in the chapter : "working example"

The polarity is setted to '1', it's wrong : polarity=0 (sclk = 0 in idle state) for CG9a01 driver.

ESP32

import machine
import gc9a01
spi = machine.SPI(2, baudrate=40000000, polarity=1, sck=machine.Pin(18), mosi=machine.Pin(23))

Pure C version for Pico

HI @russhughes currently working on another project this one using the C sdk without MicroPython. Do you have a version of the gc9a01 to work in C as the one you have here is technically C but with all of the MicroPython functions to port to a MicroPython environment.

Thanks as always!

How to Build RPi Pico Firmware for MicroPython v1.20 / latest?

Hey,

thank you for the library, and support.
Can you please tell me what is the command to / parameters to build this with the latest MicroPython version v1.20 for RPi Pico W?

More specifically, I'm struggling to understand the 2 following instructions:

*Where is this from, how do I get the micropython/ports/esp32?

$ cd micropython/ports/esp32

And then compile the module with specified USER_C_MODULES dir

$ make USER_C_MODULES=../../../../gc9a01_mpy/src/micropython.cmake all

There are some new changes in that, that I really need, and not sure how to do this.

Thank you.

Please may I ask a question?

I am writing a MicroPython driver for this display. The aim is compatibility with my GUI's e.g. nano-gui. My initialisation is based on yours. It works, but I would like to know how it works. Your initialisation writes to a number of registers that don't appear in the datasheet. I have commented out the code for most of these registers with no ill effect, but I am left with registers 66h and 67h which are necessary.

Where can I find documentation on these registers - and other missing registers? Is there a source for the data values written?

No Pico W support

Your RP2040 firmware is based on the plain Raspberry Pico and so does not include modules needed for full Pico W functionality.

Any plans to create a Pico W version?

Help

Hi,

I'm trying this on a pi Pico connected to a waveshare display, but I can't get anything to work except the backlight. I uploaded the firmware and saved an example to the pi, and I get no errors, but nothing happens. I tried setting a background colour and a few other functions, but the only ones that seem to work are on and off for the backlight.

This is on a fresh Pico pi, using thonny.

Anyone got any idea?

Support for ellipse() and poly()

Hi Russ, thank you for working on the cg9a01 MicroPython drivers, firmware, and examples. Our students have used your code to draw clocks and watch faces.

I do have one question for you. Many other MicroPython display drivers use the framebuf object my students use to draw things. They find that the ellipse() and poly() functions are very useful.

https://docs.micropython.org/en/latest/library/framebuf.html

Do you have any plans to support these functions in the future?

Need to modify to supporting for gc9107.

Lilygo and m5stack has boards use gc9107 128x128 screen
I read to datasheet and found that gc9107 is very similar to gc9a01
So can you modify this repo to supporting for gc9107? Thanks.

Unable to display two screens at once

import _thread
from machine import Pin, SPI
from utime import sleep
from gc9a01 import GC9A01, YELLOW

import NotoSansMono_32 as font
import dc540_logo

semaphore_lock = _thread.allocate_lock()

# display config
spi0 = SPI(0, baudrate=4000000, polarity=0, sck=Pin(6), mosi=Pin(7))
display0 = GC9A01(spi0, 240, 240, backlight=Pin(2, Pin.OUT), reset=Pin(14, Pin.OUT), dc=Pin(15, Pin.OUT))
display0.init()

spi1 = SPI(1, baudrate=4000000, polarity=0, sck=Pin(10), mosi=Pin(11))
display1 = GC9A01(spi1, 240, 240, backlight=Pin(3, Pin.OUT), reset=Pin(0, Pin.OUT), dc=Pin(1, Pin.OUT))
display1.init()


# button config
left_button = Pin(19, Pin.IN, Pin.PULL_UP)
right_button = Pin(18, Pin.IN, Pin.PULL_UP)
up_button = Pin(17, Pin.IN, Pin.PULL_UP)
down_button = Pin(16, Pin.IN, Pin.PULL_UP)

# clear screen
display0.fill_rect(0, 0, 240, 240, 0)
display1.fill_rect(0, 0, 240, 240, 0)


# display logo
display0.pbitmap(dc540_logo, 0, 0, 0)
display1.pbitmap(dc540_logo, 0, 0, 0)

# sleep
sleep(2)

# clear screen
display0.fill_rect(0, 0, 240, 240, 0)
display1.fill_rect(0, 0, 240, 240, 0)

# display text
display0.write(font, 'main menu', 35, 60, YELLOW)
display1.write(font, 'hello', 10, 100, YELLOW)


class Button:
        def __init__(self):
                self.left_pressed_state = False
                self.right_pressed_state = False
                self.core1_in_use = False

        def left_pressed(self, pin):
                print('state: ' + str(self.core1_in_use))
                if self.core1_in_use:
                        left_button.irq(handler=None)
                        semaphore_lock.acquire()
                        if left_button.value() and not self.left_pressed_state:
                                self.left_pressed_state = True
                                print('breaky')
                                _thread.exit()
                                self.core1_in_use = False
                        elif not left_button.value() and self.left_pressed_state:
                                self.left_pressed_state = False
                        left_button.irq(handler=self.left_pressed)
                        semaphore_lock.release()

        def right_pressed(self, pin):
                print('state: ' + str(self.core1_in_use))
                if not self.core1_in_use:
                        right_button.irq(handler=None)
#                       semaphore_lock.acquire()
                        if right_button.value() and not self.right_pressed_state:
                                self.right_pressed_state = True
                                Flag.clear_run_flag()
                                print('start thread')
                                self.core1_in_use = True
                                _thread.start_new_thread(demo.play, ())
                        elif not right_button.value() and self.right_pressed_state:
                                self.right_pressed_state = False
                        right_button.irq(handler=self.right_pressed)
#                       semaphore_lock.release()

def up_button_pressed(pin):
        print('up')


class Demo:
        def play(self):
                while True:
                        semaphore_lock.acquire()
                        print('demo')
                        sleep(1)
                        print('1st')
                        sleep(1)
                        print('2nd')
                        sleep(1)
                        print('3rd')
                        sleep(1)
                        print('4th')
                        sleep(1)
                        semaphore_lock.release()


button = Button()
demo = Demo()

left_button.irq(trigger=Pin.IRQ_FALLING, handler=button.left_pressed)
right_button.irq(trigger=Pin.IRQ_FALLING, handler=button.right_pressed)
up_button.irq(trigger=Pin.IRQ_FALLING, handler=up_button_pressed)

while True:
        print('main')
        sleep(1)

The left screen illuminates and the right screen does not. I switched the wires and the screens however spi1 does not work.

issue with drawing lines : GC9A01.line(x0, y0, x1, y1, color)

thank you very much for this great code and project,
which im trying to adapt to my pi pico with a round display (waveshare),
however, lately i ran in to some issues using the draw-line command.
i created a function for drawing lines as markers for a gauge:

#draw scala
def scala():
    r1=100
    r2=120
    for alpha in range (0,360,2):
        x1=int((r1*(math.cos((alpha-90)/180*math.pi))))
        y1=int((r1*(math.sin((alpha-90)/180*math.pi))))
        x1=x1+120
        y1=y1+120
        x2=int((r2*(math.cos((alpha-90)/180*math.pi))))
        y2=int((r2*(math.sin((alpha-90)/180*math.pi))))
        x2=x2+120
        y2=y2+120
        print ("alpha:",alpha,"x1:",x1,"y1:",y1,"x2:",x2,"y2:",y2)
        tft.line(x1,y1,x2,y2,0xFFFF)

scala()

but the area around 180 degree stays empty,
so i tried a single command:
tft.line(120,220,120,240,0xFFFF)
but had no result either ... is there maybe something wrong in the way i handle your routine ?

Support for muliple GC9A01 display

GC9A01 display(round display): Its not supoorting for multiple display. We are using esp32. Code format:
spi =SPI(1, baudrate=60000000, sck=Pin(11), mosi=Pin(12))
for first display
tft = gc9a01.GC9A01(spi,240,240,reset=Pin(9, Pin.OUT),cs=Pin(3, Pin.OUT),dc=Pin(46, Pin.OUT)backlight=Pin(5, Pin.OUT),rotation=2)
tft.init()
for second display
tft1 = gc9a01.GC9A01(spi,240,240,reset=Pin(9, Pin.OUT),cs=Pin(10, Pin.OUT),dc=Pin(46, Pin.OUT)backlight=Pin(5, Pin.OUT),rotation=2)
tft1.init()
after doing this process only second dispaly is turning on. Is there any method to use more than one display.

Help: Image Drawing Not Working

Attempting to do a simple jpg draw on a WaveShare 240x240 round display and it doesn't draw the image.

I am using PyCharm CE with mico pi support.
Pins are as followed:

Pico Pin Display
14 (GP10) BL
15 (GP11) RST
16 (GP12) DC
17 (GP13) CS
18 (GND) GND
19 (GP14) CLK
20 (GP15) DIN
05 (3v3) VCC

I can get other display drawing to work just not images, im wondering if pycharm is not sending the resource as part of the flash or not.
IMG_2251

'''
    Pico Pin   Display
    =========  =======
    14 (GP10)  BL
    15 (GP11)  RST
    16 (GP12)  DC
    17 (GP13)  CS
    18 (GND)   GND
    19 (GP14)  CLK
    20 (GP15)  DIN
'''

import gc
import random
import time
from machine import Pin, SPI
import gc9a01
import vga1_bold_16x32 as font

gc.enable()
gc.collect()

def main():
    spi = SPI(1, baudrate=60000000, sck=Pin(14), mosi=Pin(15))
    tft = gc9a01.GC9A01(
        spi,
        240,
        240,
        reset=Pin(11, Pin.OUT),
        cs=Pin(13, Pin.OUT),
        dc=Pin(12, Pin.OUT),
        backlight=Pin(10, Pin.OUT),
        rotation=0)

    # enable display and clear screen
    tft.init()

    tft.fill_rect(0, 0, tft.width(), tft.height(),  gc9a01.color565(
                  random.getrandbits(8),
                  random.getrandbits(8),
                  random.getrandbits(8)))

    col_max = tft.width() - font.WIDTH*6
    row_max = tft.height() - font.HEIGHT

    tft.text(
        font,
        "Eric!",
        random.randint(0, col_max),
        random.randint(0, row_max),
        gc9a01.color565(
            random.getrandbits(8),
            random.getrandbits(8),
            random.getrandbits(8)),
        gc9a01.color565(
            random.getrandbits(8),
            random.getrandbits(8),
            random.getrandbits(8))
    )

    tft.jpg("bluemarble.jpg",
            0,
            0,
            gc9a01.SLOW)
main()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.