From f2a9f4c03a86a4b31070dbee65b5d41f31c7cb7b Mon Sep 17 00:00:00 2001 From: Peter Hinch Date: Fri, 19 Feb 2021 17:26:13 +0000 Subject: [PATCH] writer: framebuf_utils is now Pyboard-only. Matches reality :) --- writer/WRITER.md | 18 ++++++++++-------- writer/writer.py | 8 ++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/writer/WRITER.md b/writer/WRITER.md index 5cdcb68..40d8c30 100644 --- a/writer/WRITER.md +++ b/writer/WRITER.md @@ -271,19 +271,21 @@ the `framebuf.blit` method the class renders glyphs one pixel at a time. There is a way to improve performance. It was developed by Jim Mussared (@jimmo) and consists of a native C module. +This works well on Pyboards (1.x and D) but I have had no success on other +platforms including the Raspberry Pi Pico. The code will silently ignore this +module on other platforms. The following applies only when run on a Pyboard. + On import, `writer.py` attempts to import a module `framebuf_utils`. If this succeeds, glyph rendering will be substantially faster. If the file is not -present the class will work using normal rendering. If the file exists but was -compiled for a different architecture a warning message will be printed. This -is a harmless advisory - the code will run using normal rendering. +present the class will work using normal rendering. If the file is missing or +invalid a harmless advisory note is printed and the code will run using normal +rendering. The directory `framebuf_utils` contains the source file, the makefile and a version of `framebuf_utils.mpy` for `armv7m` architecture (e.g. Pyboards). -ESP32 users with access to the development toolchain should change `Makefile` -to specify the `xtensawin` arch and rebuild. - -It is suggested that moving the appropriate `framebuf_utils.mpy` to the target -is only done once the basic operation of an application has been verified. +This allows for recompiling for other architectures if anyone feels like +experimenting. However the fact that it crashes the Pico suggests that the code +is highly specific to the Pybaord. The module has a `fast_mode` variable which is set `True` on import if the mode was successfully engaged. User code should treat this as read-only. diff --git a/writer/writer.py b/writer/writer.py index 0f02c39..3430924 100644 --- a/writer/writer.py +++ b/writer/writer.py @@ -25,9 +25,9 @@ import framebuf from uctypes import bytearray_at, addressof from sys import platform -__version__ = (0, 4, 1) +__version__ = (0, 4, 2) -fast_mode = platform != 'rp2' # framebuf_utils crashes RP2 +fast_mode = platform == 'pyboard' if fast_mode: try: try: @@ -39,8 +39,8 @@ if fast_mode: fast_mode = False except ValueError: fast_mode = False -if not fast_mode: - print('Ignoring framebuf_utils.mpy: compiled for incorrect architecture.') + if not fast_mode: + print('Ignoring missing or invalid framebuf_utils.mpy.') class DisplayState():