Repository navigation
tdui: canvas pages, big characters, more cells with PSRAM - #16
Merged
Merged
Conversation
Python screens built from many put()/fill() calls cost Python time and appeared piece by piece, since the desktop draws what has arrived every 10 ms. Measured on an ESP32-S3 with a full-screen 100x30 HMI: a screen switch took 60-310 ms of Python time, with 31-224 drawing requests, while the link carried only 1-9 KB. - Canvas pages: w.canvas(..., pages=n) keeps up to 16 pictures (TD_PYUI_MAX_PAGES) on the desktop. draw_to(n) draws into a page while the window shows another, show(n) shows a page whole in one step, copy_page(src, dst) copies a picture; resize keeps every page. New requests TD_PYUI_PAGE and TD_PYUI_PAGE_COPY; drawing into a hidden page does not redraw the window. - canvas.big(x, y, text, fg, bg, scale, width): big characters (digits, A-Z, - + % / . : and space; 3x5 pixels, two to a cell with the half blocks, scale 1-4) drawn by the desktop in one request (TD_PYUI_BIG); width right-aligns and blanks the rest. tdui.big_size() gives the size. - put() and fill() call _tdui.send directly, two Python calls fewer each. - tdui.MAX_CELLS, all canvases of a script with every page counted, is 32000 on boards with PSRAM and on the PC (192 KB at most, while a script runs), 2000 without PSRAM as before; tdui reads it from _tdui, and the error message gives the real number. With a page per screen and big(), the same HMI switches in 33-82 ms and each screen appears at once. Existing scripts are unchanged. Tests: test_pyui (pages, copy, resize, big characters, the page and cell limits). third_party/micropython regenerated for the new tdui.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Python screens built from many
put()/fill()calls cost Python time andappeared piece by piece, because the desktop draws whatever has arrived every
10 ms. Measured on an ESP32-S3 with a full-screen 100x30 HMI (six screens):
a screen switch took 60–310 ms of Python time and 31–224 drawing requests,
while the serial link carried only 1–9 KB. The script was the bottleneck,
not the link or the desktop.
Changes
w.canvas(..., pages=n)keeps up to 16 pictures(
tdui.MAX_PAGES) on the desktop.draw_to(n)draws into a page while the window shows another.show(n)shows a page whole, in one step.copy_page(src, dst)copies a picture.resize()keeps every page.canvas.big(x, y, text, fg, bg, scale, width)drawsdigits, A–Z and
- + % / . :with half blocks, in one request (scale 1–4).widthright-aligns the text and blanks the rest.tdui.big_size()givesthe size.
put()andfill()call_tdui.senddirectly,two Python calls fewer each.
tdui.MAX_CELLScounts every page. It's 32000 onboards with PSRAM and in the PC programs (192 KB at most, only while a
script runs), and 2000 without PSRAM as before.
tduireads it from_tdui, and the error message gives the real number.TD_PYUI_PAGE,TD_PYUI_PAGE_COPYandTD_PYUI_BIG, added after the existing ones, so existing scripts areunchanged.
third_party/micropythonis regenerated forthe new
tdui.py(MicroPython v1.29.0).Result
With a page per screen and
big(), the same HMI switches in 33–82 ms, andeach screen appears at once:
Testing
tests/test_pyui.c(pages, copy, resize, big characters, the page and cell limits).
Docs: tinydesk-project.github.io, branch
tdui-cells.