russhughes / gc9a01_mpy

Fast MicroPython driver for GC9A01 display modules written in C
Other
153 stars 31 forks source link

own jpgs #27

Closed jajawunderbar closed 1 year ago

jajawunderbar commented 1 year ago

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()

`

russhughes commented 1 year ago

Use ImageMagick's convert with ‘-type TrueColor’.

See: https://github.com/russhughes/gc9a01_mpy/blob/main/utils/howto-convert-to-jpg

jajawunderbar commented 1 year ago

Thanks. Now it runs. I thought it was only necessary for svg.