Skip to content

Commit

Permalink
Update ili9xxx, st77xx drivers and examples, remove lv.COLOR_DEPTH (#312
Browse files Browse the repository at this point in the history
)
  • Loading branch information
PGNetHun authored Jan 9, 2024
1 parent c17bcf3 commit 5cea992
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 120 deletions.
1 change: 0 additions & 1 deletion driver/esp32/espidf.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "freertos/task.h"
#include "esp_system.h"
#include "soc/cpu.h"
#include "lvgl/src/draw/sw/lv_draw_sw.h"


// ESP IDF has some functions that are declared but not implemented.
Expand Down
188 changes: 82 additions & 106 deletions driver/esp32/ili9XXX.py

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions driver/generic/ili9xxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@

class Ili9341_hw(st77xx.St77xx_hw):
def __init__(self, **kw):
"""ILI9341 TFT Display Driver.
Requires ``LV_COLOR_DEPTH=16`` when building lv_micropython to function.
"""
"""ILI9341 TFT Display Driver."""
super().__init__(
res=(240, 320),
suppRes=[
Expand Down
7 changes: 3 additions & 4 deletions driver/generic/st77xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,8 @@ def __init__(self,doublebuffer=True,factor=4):
import lvgl as lv
import lv_utils

if lv.COLOR_DEPTH!=16: raise RuntimeError(f'LVGL *must* be compiled with LV_COLOR_DEPTH=16 (currently LV_COLOR_DEPTH={lv.COLOR_DEPTH}.')

bufSize=(self.width * self.height * lv.COLOR_DEPTH // 8) // factor
color_format = lv.COLOR_FORMAT.RGB565
bufSize=(self.width * self.height * lv.color_format_get_size(color_format)) // factor

if not lv.is_initialized(): lv.init()
# create event loop if not yet present
Expand All @@ -458,7 +457,7 @@ def __init__(self,doublebuffer=True,factor=4):
self.disp_drv = lv.disp_create(self.width, self.height)
self.disp_drv.set_flush_cb(self.disp_drv_flush_cb)
self.disp_drv.set_draw_buffers(bytearray(bufSize), bytearray(bufSize) if doublebuffer else None, bufSize, lv.DISP_RENDER_MODE.PARTIAL)
self.disp_drv.set_color_format(lv.COLOR_FORMAT.NATIVE)
self.disp_drv.set_color_format(color_format)

class St7735(St7735_hw,St77xx_lvgl):
def __init__(self,res,doublebuffer=True,factor=4,**kw):
Expand Down
7 changes: 5 additions & 2 deletions examples/advanced_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,17 @@ def init_gui_stm32(self):

hres = 480
vres = 272
color_format = lv.COLOR_FORMAT.ARGB8888

# Register display driver
self.event_loop = event_loop()
lcd.init(w=hres, h=vres)
self.disp_drv = lv.display_create(hres, vres)
self.disp_drv.set_flush_cb(lcd.flush)
buf1_1 = bytearray(hres * 50 * lv.COLOR_DEPTH // 8)
buf1_2 = bytearray(hres * 50 * lv.COLOR_DEPTH // 8)
self.disp_drv.set_color_format(color_format)
buf_size = hres * 50 * lv.color_format_get_size(color_format)
buf1_1 = bytearray(buf_size)
buf1_2 = bytearray(buf_size)
self.disp_drv.set_draw_buffers(buf1_1, buf1_2, len(buf1_1), lv.DISPLAY_RENDER_MODE.PARTIAL)

# Register touch sensor
Expand Down
7 changes: 5 additions & 2 deletions examples/example3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@

hres = 480
vres = 272
color_format = lv.COLOR_FORMAT.ARGB8888

lv.init()
event_loop = lv_utils.event_loop()
lcd.init(w=hres, h=vres)
disp_drv = lv.disp_create(hres, vres)
disp_drv.set_flush_cb(lcd.flush)
buf1_1 = bytearray(hres * 10 * lv.COLOR_DEPTH // 8)
buf1_2 = bytearray(hres * 10 * lv.COLOR_DEPTH // 8)
buf_size = hres * 10 * lv.color_format_get_size(color_format)
buf1_1 = bytearray(buf_size)
buf1_2 = bytearray(buf_size)
disp_drv.set_draw_buffers(buf1_1, buf1_2, len(buf1_1), lv.DISP_RENDER_MODE.PARTIAL)

# disp_drv.gpu_blend_cb = lcd.gpu_blend
Expand Down
2 changes: 1 addition & 1 deletion examples/png_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##############################################################################
#
# Example of the PNG image decoder Usage.
# For dragging to work reasonable, make sure LV_image_CACHE_DEF_SIZE is not 0!
# For dragging to work reasonable, make sure LV_CACHE_DEF_SIZE is not 0!
#
##############################################################################

Expand Down

0 comments on commit 5cea992

Please sign in to comment.