micropython
micropython copied to clipboard
extmod/modframebuf: FrameBuffer text scaling
This adds the ability to scale-up the standard 8x8 font when drawing text. This is useful with tiny OLED screens (such as on the Heltec WiFi Kit 32) where you need to display something important a bit more clearly. This does not provide any new, larger fonts so the text will look increasingly blocky as it is scaled.
I'm not wedded to the additional positional argument here – it was just simplest and matched the way color is provided. I'm happy to go back and switch this to being a keyword optional argument instead.
(Fixes #7384)
Ugh. qemu-arm port build and tests failing:
CC test_main.c
CC ../../lib/tinytest/tinytest.c
In file included from test_main.c:20:0:
build/genhdr/tests.h: In function 'test_extmod_framebuf1_py_fn':
build/genhdr/tests.h:45181:50: error: trigraph ??' ignored, use -trigraphs to enable [-Werror=trigraphs]
"bytearray(b'\\x00\\x00\\xff\\xff\\xff\\x00\\x00???')\n"
CC build/frozen_content.c
cc1: all warnings being treated as errors
../../py/mkrules.mk:63: recipe for target 'build/test_main.o' failed
make: *** [build/test_main.o] Error 1
make: Leaving directory '/home/travis/build/micropython/micropython/ports/qemu-arm'
The command "make ${MAKEOPTS} -C ports/qemu-arm -f Makefile.test test" exited with 2.
Trigraphs? Seriously? The 1970s are calling and they want to force us to accommodate their crazy keyboards.
Will alter test to not generate output that contains repeated question marks...
If anyone wants to know what the result of this is. It looks like this:
This screen is seriously tiny, so doubled-up text allows it to be read from a distance instead of having to squint at it up close.
Made this patch more flexible by switching to specifying the font size (in pixels) instead of an integer scaling factor. This both allows for drawing text at effective non-integer scales, but also means that a future version could select an alternative built-in font for drawing larger text. Drawing text will be slightly slower with this version due to increased bit twiddling and less scope for short-cutting out of the Y loop.
Related PR: https://github.com/micropython/micropython/pull/3583 Simple font size scaling for framebuf
How is this PR coming along? We love the idea of increasing accessibility and usability for small displays. If we're taking votes, I'd vote for a keyword size
argument.
As an aside, we've received interest in our forums (thread) at Core Electronics for variable font sizes.
At the moment this PR doesn't seem to have generated sufficient interest to get mainline attention.
Since I always build my own MicroPython these days, I just roll this patch into my production branch; so I'm committed to continuing to support it for the foreseeable future.
+1 to see this implemented. Great work @jonathanhogg and hopefully @dpgeorge can assist,
Codecov Report
Merging #6263 (993b6b9) into master (91674c4) will increase coverage by
0.11%
. Report is 21 commits behind head on master. The diff coverage is100.00%
.
:exclamation: Current head 993b6b9 differs from pull request most recent head 98d5e68. Consider uploading reports for the commit 98d5e68 to get more accurate results
@@ Coverage Diff @@
## master #6263 +/- ##
==========================================
+ Coverage 98.38% 98.50% +0.11%
==========================================
Files 158 155 -3
Lines 20900 20544 -356
==========================================
- Hits 20563 20236 -327
+ Misses 337 308 -29
Files Changed | Coverage Δ | |
---|---|---|
extmod/modframebuf.c | 100.00% <100.00%> (ø) |
See also https://github.com/micropython/micropython/pull/8987. It would be good to see some updates to framebuf
.
Rebased to 4903e48e340bd9741577f30cacb31605cc70cf20 and fixed for renamed function argument.
This is a "Good Idea". +1 from me :)
Code size report:
bare-arm: +0 +0.000%
minimal x86: +0 +0.000%
unix x64: +112 +0.014% standard
stm32: +48 +0.012% PYBV10
mimxrt: +48 +0.013% TEENSY40
rp2: +48 +0.015% PICO
samd: +48 +0.018% ADAFRUIT_ITSYBITSY_M4_EXPRESS
Any news on whether the sizing feature is going to be present in the upcoming micropython version?
This is an automated heads-up that we've just merged a Pull Request that removes the STATIC macro from MicroPython's C API.
See https://github.com/micropython/micropython/pull/13763
A search suggests this PR might apply the STATIC macro to some C code. If it
does, then next time you rebase the PR (or merge from master) then you should
please replace all the STATIC
keywords with static
.
Although this is an automated message, feel free to @-reply to me directly if you have any questions about this.