diff --git a/docs/_modules/index.html b/docs/_modules/index.html index 5047934..a22a7e1 100644 --- a/docs/_modules/index.html +++ b/docs/_modules/index.html @@ -92,7 +92,8 @@
Flying toasters sprite demo using bitmaps created from spritesheet using -ImageMagick’s convert and imgtobitmap.py utility. See the maketoast script in -the utils directory for details.
+ImageMagick’s convert and imgtobitmap.py utility. See the maketoast script in the utils directory for details.1 2 3 @@ -964,8 +964,8 @@ the utils directory for details. |
Test for font2bitmap converter for the GC9A01 display. +
Test for font2bitmap converter for the driver. See the font2bitmap program in the utils directory.
1 2 @@ -1020,7 +1020,7 @@ See the font2bitmap program in the utils directory. 51 | """
chango.py
- Test for font2bitmap converter for the st7789 display.
+ Test for font2bitmap converter for the driver.
See the font2bitmap program in the utils directory.
"""
@@ -1067,6 +1067,150 @@ See the font2bitmap program in the utils directory.
row += font_64.HEIGHT
+main()
+ |
Test for font2bitmap converter for the driver. +See the font2bitmap program in the utils directory.
+1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 | """
+noto_fonts Writes the names of three Noto fonts centered on the display
+ using the font. The fonts were converted from True Type fonts using
+ the font2bitmap utility.
+"""
+
+from machine import SoftSPI, Pin
+import st7789py as st7789
+
+from truetype import NotoSans_32 as noto_sans
+from truetype import NotoSerif_32 as noto_serif
+from truetype import NotoSansMono_32 as noto_mono
+
+
+def main():
+
+ def center(font, string, row, color=st7789.WHITE):
+ screen = tft.width # get screen width
+ width = tft.write_width(font, string) # get the width of the string
+ if width and width < screen: # if the string < display
+ col = tft.width // 2 - width // 2 # find the column to center
+ else: # otherwise
+ col = 0 # left justify
+
+ tft.write(font, string, col, row, color) # and write the string
+
+ try:
+ spi = SoftSPI(
+ baudrate=20000000,
+ polarity=1,
+ phase=0,
+ sck=Pin(18),
+ mosi=Pin(19),
+ miso=Pin(13))
+
+ tft = st7789.ST7789(
+ spi,
+ 135,
+ 240,
+ reset=Pin(23, Pin.OUT),
+ cs=Pin(5, Pin.OUT),
+ dc=Pin(16, Pin.OUT),
+ backlight=Pin(4, Pin.OUT),
+ rotation=1)
+
+ # enable display and clear screen
+ tft.fill(st7789.BLACK)
+
+ row = 16
+
+ # center the name of the first font, using the font
+ center(noto_sans, "NotoSans", row, st7789.RED)
+ row += noto_sans.HEIGHT
+
+ # center the name of the second font, using the font
+ center(noto_serif, "NotoSerif", row, st7789.GREEN)
+ row += noto_serif.HEIGHT
+
+ # center the name of the third font, using the font
+ center(noto_mono, "NotoSansMono", row, st7789.BLUE)
+ row += noto_mono.HEIGHT
+
+ finally:
+ # shutdown spi
+ if 'spi' in locals():
+ spi.deinit()
+
+
main()
|
font_from_romfont -i font-bin -o fonts -f 32 -l 127
1 2 3 @@ -208,11 +209,31 @@ character is 256 pixels or less. They are written using the write method. 14 15 16 -17 | """converted from vga_8x8.bin """
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27 | """converted from vga_8x8.bin """
+
+# font width
WIDTH = 8
+
+# font height
HEIGHT = 8
+
+# first character in front
FIRST = 0x20
+
+# last character in font
LAST = 0x7f
+
+# bitmap of each character from FIRST to LAST
_FONT =\
b'\x00\x00\x00\x00\x00\x00\x00\x00'\
b'\x18\x3c\x3c\x18\x18\x00\x18\x00'\
@@ -241,19 +262,117 @@ the negative glyph.left fix from peterhinch’s font conversion program
./font2bitmap NotoSans-Regular.ttf 32 -s “0123456789ABCEDF” ./font2bitmap.py Chango-Regular.ttf 16 -c 0x20-0x7f
+
Sample converted TrueType font module.¶
+
8x8 Fonts¶-
+
+
8x16 Fonts¶-
+
+
16x16 Fonts¶-
-
-![]() vga1_16x16.py: 128 Character 16x16 Thin Font¶ -
-
-
![]() vga1_bold_16x16.py: 128 Character 16x16 Bold Font¶ +![]() vga1_16x16.py: 128 Character 16x16 Thin Font¶
-
![]() vga2_16x16.py: 256 Character 16x16 Thin Font¶ +![]() vga1_bold_16x16.py: 128 Character 16x16 Bold Font¶
+
+![]() vga2_16x16.py: 256 Character 16x16 Thin Font¶ +
+
+![]() vga2_bold_16x16.py: 256 Character 16x16 Bold Font¶ +vga2_bold_16x16.py: 256 Character 16x16 Bold Font¶ 16x32 Fonts¶-
-
-![]() vga1_16x32.py: 128 Character 16x32 Thin Font¶ -
-
-
![]() vga1_bold_16x32.py: 128 Character 16x32 Bold Font¶ +![]() vga1_16x32.py: 128 Character 16x32 Thin Font¶
-
![]() vga2_16x32.py: 256 Character 16x32 Thin Font¶ +![]() vga1_bold_16x32.py: 128 Character 16x32 Bold Font¶
+
+![]() vga2_16x32.py: 256 Character 16x32 Thin Font¶ +
+
+![]() vga2_bold_16x32.py: 256 Character 16x32 Bold Font¶ +vga2_bold_16x32.py: 256 Character 16x32 Bold Font¶
st7789 tft driver in MicroPython based on devbis’ st7789py_mpy module from + The driver is based on devbis’ st7789py_mpy module from https://github.com/devbis/st7789py_mpy. -I added support for display rotation, scrolling and drawing text using 8 and 16 -bit wide bitmap fonts with heights that are multiples of 8. Included are 12 -bitmap fonts derived from classic pc text mode fonts. +This driver adds support for: +
st7789py. ST7789 (spi, width, height, reset, dc, cs=None, backlight=None, rotation=0)[source]¶
|