Skip to content

Commit abf8005

Browse files
Increase display and camera FPS
1 parent 9740cbb commit abf8005

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

internal_filesystem/boot.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,22 @@
4242
dc=LCD_DC,
4343
cs=LCD_CS,
4444
)
45+
46+
# lv.color_format_get_size(lv.COLOR_FORMAT.RGB565) = 2 bytes per pixel * 320 * 240 px = 153600 bytes
47+
# The default was /10 so 15360 bytes.
48+
# /2 = 76800 shows something on display and then hangs the board
49+
# /2 = 38400 works and pretty high framerate but camera gets ESP_FAIL
50+
# /2 = 19200 works, including camera at 9FPS
51+
# 28800 is between the two and still works with camera!
52+
# 30720 is /5 and is already too much
53+
BUFFER_SIZE = const(28800)
54+
fb1 = display_bus.allocate_framebuffer(_BUFFER_SIZE, lcd_bus.MEMORY_INTERNAL | lcd_bus.MEMORY_DMA)
55+
fb2 = display_bus.allocate_framebuffer(_BUFFER_SIZE, lcd_bus.MEMORY_INTERNAL | lcd_bus.MEMORY_DMA)
56+
4557
display = st7789.ST7789(
4658
data_bus=display_bus,
59+
frame_buffer1=fb1,
60+
frame_buffer2=fb2,
4761
display_width=TFT_VER_RES,
4862
display_height=TFT_HOR_RES,
4963
backlight_pin=LCD_BL,
@@ -62,7 +76,7 @@
6276
indev=cst816s.CST816S(touch_dev,startup_rotation=lv.DISPLAY_ROTATION._180) # button in top left, good
6377

6478
lv.init()
65-
display.set_rotation(lv.DISPLAY_ROTATION._90)
79+
display.set_rotation(lv.DISPLAY_ROTATION._90) # must be done after initializing display and creating the touch drivers, to ensure proper handling
6680

6781
# Gesture IDs:
6882
# 0: press

internal_filesystem/main.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import machine
44

55
# Constants
6-
CURRENT_OS_VERSION = "0.0.3"
6+
CURRENT_OS_VERSION = "0.0.4"
77
TFT_HOR_RES=320
88
TFT_VER_RES=240
99
NOTIFICATION_BAR_HEIGHT=24
@@ -18,7 +18,7 @@
1818
SLIDER_MAX_VALUE=100
1919
SLIDER_DEFAULT_VALUE=100
2020

21-
CLOCK_UPDATE_INTERVAL = 100 # 10 or even 1 ms doesn't seem to change the framerate but 100ms is enough
21+
CLOCK_UPDATE_INTERVAL = 1000 # 10 or even 1 ms doesn't seem to change the framerate but 100ms is enough
2222
WIFI_ICON_UPDATE_INTERVAL = 1500
2323
TEMPERATURE_UPDATE_INTERVAL = 2000
2424
MEMFREE_UPDATE_INTERVAL = 5000 # not too frequent because there's a forced gc.collect() to give it a reliable value
@@ -29,7 +29,10 @@
2929
drawer_open=False
3030
bar_open=True
3131

32-
th = task_handler.TaskHandler(duration=6)
32+
# lowering the duration from default 33 to 6 seems to increase the camera framerate from 5.5 to 9 and the UI framerate from 15 to 20fps
33+
# lowering to 1 doesn't seem to help out the camera framerate (so it's maxed out) but the UI goes to 26 FPS with it!
34+
#th = task_handler.TaskHandler()
35+
th = task_handler.TaskHandler(duration=1)
3336

3437
rootscreen = lv.screen_active()
3538
rootlabel = lv.label(rootscreen)

scripts/build_lvgl_micropython.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ fi
2222

2323
python3 make.py --ota --partition-size=4194304 --flash-size=16 esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT DISPLAY=st7789 INDEV=cst816s USER_C_MODULE="/home/user/sources/micropython-camera-API/src/micropython.cmake" "$manifest"
2424

25+
# build for unix:
26+
#python3 make.py unix DISPLAY=sdl_display INDEV=sdl_pointer
27+
2528
popd

0 commit comments

Comments
 (0)