├── .gitignore ├── LICENSE ├── README.md ├── VERSION ├── docs ├── ST7789.jpg ├── astrol.svg ├── cyrilc.svg ├── gotheng.svg ├── gothger.svg ├── gothita.svg ├── greekc.svg ├── greekcs.svg ├── greekp.svg ├── greeks.svg ├── italicc.svg ├── italiccs.svg ├── italict.svg ├── japan.svg ├── lowmat.svg ├── madctl_0.png ├── madctl_v.png ├── madctl_vx.png ├── madctl_vxy.png ├── madctl_vy.png ├── madctl_x.png ├── madctl_xy.png ├── madctl_y.png ├── marker.svg ├── meteo.svg ├── misc.svg ├── music.svg ├── romanc.svg ├── romancs.svg ├── romand.svg ├── romanp.svg ├── romans.svg ├── romant.svg ├── scriptc.svg ├── scripts.svg ├── symbol.svg ├── uppmat.svg ├── vga1_16x16.png ├── vga1_16x32.png ├── vga1_8x16.png ├── vga1_8x8.png ├── vga1_bold_16x16.png ├── vga1_bold_16x32.png ├── vga2_16x16.png ├── vga2_16x32.png ├── vga2_8x16.png ├── vga2_8x8.png ├── vga2_bold_16x16.png └── vga2_bold_16x32.png ├── examples ├── README.md ├── bitarray.py ├── bitmap_fonts.py ├── cfg_helper.py ├── chango │ ├── chango.py │ ├── chango_16.py │ ├── chango_32.py │ ├── chango_64.py │ └── make_fonts_py.sh ├── clock │ ├── OFL.txt │ ├── Pacifico-Regular.ttf │ ├── clock.py │ ├── clock_128x128 │ │ ├── nasa01.jpg │ │ ├── nasa02.jpg │ │ ├── nasa03.jpg │ │ ├── nasa04.jpg │ │ ├── nasa05.jpg │ │ ├── nasa06.jpg │ │ ├── nasa07.jpg │ │ ├── nasa08.jpg │ │ ├── nasa09.jpg │ │ ├── nasa10.jpg │ │ ├── nasa11.jpg │ │ ├── nasa12.jpg │ │ ├── nasa13.jpg │ │ ├── nasa14.jpg │ │ ├── nasa15.jpg │ │ ├── nasa16.jpg │ │ ├── nasa17.jpg │ │ ├── nasa18.jpg │ │ ├── nasa19.jpg │ │ ├── nasa20.jpg │ │ ├── nasa21.jpg │ │ ├── nasa22.jpg │ │ ├── nasa23.jpg │ │ ├── nasa24.jpg │ │ └── nasa25.jpg │ ├── clock_160x128 │ │ ├── nasa01.jpg │ │ ├── nasa02.jpg │ │ ├── nasa03.jpg │ │ ├── nasa04.jpg │ │ ├── nasa05.jpg │ │ ├── nasa06.jpg │ │ ├── nasa07.jpg │ │ ├── nasa08.jpg │ │ ├── nasa09.jpg │ │ ├── nasa10.jpg │ │ ├── nasa11.jpg │ │ ├── nasa12.jpg │ │ ├── nasa13.jpg │ │ ├── nasa14.jpg │ │ ├── nasa15.jpg │ │ ├── nasa16.jpg │ │ ├── nasa17.jpg │ │ ├── nasa18.jpg │ │ ├── nasa19.jpg │ │ ├── nasa20.jpg │ │ ├── nasa21.jpg │ │ ├── nasa22.jpg │ │ ├── nasa23.jpg │ │ ├── nasa24.jpg │ │ └── nasa25.jpg │ ├── clock_240x135 │ │ ├── nasa01.jpg │ │ ├── nasa02.jpg │ │ ├── nasa03.jpg │ │ ├── nasa04.jpg │ │ ├── nasa05.jpg │ │ ├── nasa06.jpg │ │ ├── nasa07.jpg │ │ ├── nasa08.jpg │ │ ├── nasa09.jpg │ │ ├── nasa10.jpg │ │ ├── nasa11.jpg │ │ ├── nasa12.jpg │ │ ├── nasa13.jpg │ │ ├── nasa14.jpg │ │ ├── nasa15.jpg │ │ ├── nasa16.jpg │ │ ├── nasa17.jpg │ │ ├── nasa18.jpg │ │ ├── nasa19.jpg │ │ ├── nasa20.jpg │ │ ├── nasa21.jpg │ │ ├── nasa22.jpg │ │ ├── nasa23.jpg │ │ ├── nasa24.jpg │ │ └── nasa25.jpg │ ├── clock_240x240 │ │ ├── nasa01.jpg │ │ ├── nasa02.jpg │ │ ├── nasa03.jpg │ │ ├── nasa04.jpg │ │ ├── nasa05.jpg │ │ ├── nasa06.jpg │ │ ├── nasa07.jpg │ │ ├── nasa08.jpg │ │ ├── nasa09.jpg │ │ ├── nasa10.jpg │ │ ├── nasa11.jpg │ │ ├── nasa12.jpg │ │ ├── nasa13.jpg │ │ ├── nasa14.jpg │ │ ├── nasa15.jpg │ │ ├── nasa16.jpg │ │ ├── nasa17.jpg │ │ ├── nasa18.jpg │ │ ├── nasa19.jpg │ │ ├── nasa20.jpg │ │ ├── nasa21.jpg │ │ ├── nasa22.jpg │ │ ├── nasa23.jpg │ │ ├── nasa24.jpg │ │ └── nasa25.jpg │ ├── clock_320x240 │ │ ├── nasa01.jpg │ │ ├── nasa02.jpg │ │ ├── nasa03.jpg │ │ ├── nasa04.jpg │ │ ├── nasa05.jpg │ │ ├── nasa06.jpg │ │ ├── nasa07.jpg │ │ ├── nasa08.jpg │ │ ├── nasa09.jpg │ │ ├── nasa10.jpg │ │ ├── nasa11.jpg │ │ ├── nasa12.jpg │ │ ├── nasa13.jpg │ │ ├── nasa14.jpg │ │ ├── nasa15.jpg │ │ ├── nasa16.jpg │ │ ├── nasa17.jpg │ │ ├── nasa18.jpg │ │ ├── nasa19.jpg │ │ ├── nasa20.jpg │ │ ├── nasa21.jpg │ │ ├── nasa22.jpg │ │ ├── nasa23.jpg │ │ ├── nasa24.jpg │ │ └── nasa25.jpg │ ├── pacifico30.py │ ├── pacifico40.py │ └── pacifico60.py ├── configs │ ├── README.md │ ├── adafruit_320x172 │ │ └── tft_config.py │ ├── esp32_7735_128 │ │ └── tft_config.py │ ├── esp32_7735_160 │ │ └── tft_config.py │ ├── esp32_box_lite │ │ ├── tft_buttons.py │ │ └── tft_config.py │ ├── esp32_buttons │ │ └── tft_buttons.py │ ├── esp32_st7789 │ │ └── tft_config.py │ ├── esp32c3_st7789_240 │ │ └── tft_config.py │ ├── m5stack_core │ │ ├── tft_buttons.py │ │ └── tft_config.py │ ├── m5stack_core2 │ │ ├── tft_buttons.py │ │ └── tft_config.py │ ├── pybv11_st7789 │ │ └── tft_config.py │ ├── t-picoc3 │ │ └── tft_config.py │ ├── t_dongle_s3 │ │ ├── tft_buttons.py │ │ └── tft_config.py │ ├── tdisplay_esp32 │ │ ├── tft_buttons.py │ │ └── tft_config.py │ ├── tdisplay_rp2040 │ │ ├── tft_buttons.py │ │ └── tft_config.py │ ├── twatch_2020_v2 │ │ └── tft_config.py │ ├── wio_terminal │ │ ├── tft_buttons.py │ │ └── tft_config.py │ ├── ws_pico_114 │ │ ├── tft_buttons.py │ │ ├── tft_config.py │ │ └── tft_joystick.py │ ├── ws_pico_13 │ │ ├── tft_buttons.py │ │ └── tft_config.py │ └── ws_pico_2 │ │ ├── tft_buttons.py │ │ └── tft_config.py ├── feathers.py ├── font_decode.py ├── hello.py ├── hershey.py ├── hershey_to_poly.py ├── hola.py ├── jpg │ ├── alien.jpg │ ├── alien.py │ ├── bigbuckbunny-128x128.jpg │ ├── bigbuckbunny-160x128.jpg │ ├── bigbuckbunny-240x135.jpg │ ├── bigbuckbunny-240x240.jpg │ ├── bigbuckbunny-320x240.jpg │ └── jpg.py ├── mono_fonts │ ├── inconsolata_16.py │ ├── inconsolata_32.py │ ├── inconsolata_64.py │ └── mono_fonts.py ├── noto_fonts.py ├── paint.py ├── pinball.py ├── png │ ├── alien.png │ ├── alien.py │ ├── bigbuckbunny-128x128.png │ ├── bigbuckbunny-160x128.png │ ├── bigbuckbunny-240x135.png │ ├── bigbuckbunny-240x240.png │ ├── bigbuckbunny-240x320.png │ ├── bigbuckbunny-320x240.png │ ├── logo-128x128.png │ ├── logo-160x128.png │ ├── logo-160x80.png │ ├── logo-240x135.png │ ├── logo-240x240.png │ ├── logo-240x320.png │ ├── logo-320x170.png │ ├── logo-320x240.png │ ├── logo-480x320.png │ ├── logo-64x64.png │ ├── logo-80x160.png │ ├── logo.py │ ├── png.py │ └── png_bounce.py ├── proverbs │ ├── NotoSansSC-Regular.otf │ ├── makefont │ ├── proverbs.py │ └── proverbs_font.py ├── roids.py ├── scroll.py ├── st7789.pyi ├── tbbunny.py ├── tiny_hello.py ├── tiny_toasters │ ├── tiny_toasters.py │ ├── ttoast_bitmaps.py │ └── ttoasters.bmp ├── toasters │ ├── toast_bitmaps.py │ ├── toasters.bmp │ └── toasters.py ├── toasters_jpg │ ├── toaster.jpg │ └── toasters_jpg.py └── watch │ ├── LibreBaskerville-Regular.ttf │ ├── create_face_jpg.py │ ├── face_128x128.jpg │ ├── face_160x128.jpg │ ├── face_240x135.jpg │ ├── face_240x240.jpg │ ├── face_320x240.jpg │ └── watch.py ├── firmware ├── ESP32_BOX_LITE │ ├── firmware.bin │ └── flash_instructions.md ├── GENERIC-7789 │ └── firmware.bin ├── GENERIC_C3 │ └── firmware.bin ├── GENERIC_C3_USB │ └── firmware.bin ├── GENERIC_S2 │ └── firmware.bin ├── GENERIC_S3_7789 │ └── firmware.bin ├── GENERIC_S3_SPIRAM │ └── firmware.bin ├── GENERIC_S3_SPIRAM_OCT │ └── firmware.bin ├── GENERIC_SPIRAM-7789 │ └── firmware.bin ├── LICENSE ├── LOLIN_S2_MINI │ └── firmware.bin ├── M5CORE │ └── firmware.bin ├── M5CORE2 │ └── firmware.bin ├── PYBV11 │ └── firmware.dfu ├── RP2 │ └── firmware.uf2 ├── RP2W │ └── firmware.uf2 ├── T-DISPLAY-ESP32 │ └── firmware.bin ├── T-DISPLAY-RP2040 │ └── firmware.uf2 ├── T-DONGLE-S3 │ └── firmware.bin ├── TWATCH-2020 │ └── firmware.bin └── WIO_TERMINAL │ └── firmware.uf2 ├── fonts ├── bitmap │ ├── README.md │ ├── vga1_16x16.py │ ├── vga1_16x32.py │ ├── vga1_8x16.py │ ├── vga1_8x8.py │ ├── vga1_bold_16x16.py │ ├── vga1_bold_16x32.py │ ├── vga2_16x16.py │ ├── vga2_16x32.py │ ├── vga2_8x16.py │ ├── vga2_8x8.py │ ├── vga2_bold_16x16.py │ ├── vga2_bold_16x32.py │ ├── vga_8x16.bin │ └── vga_8x8.bin ├── truetype │ ├── Chango-Regular.ttf │ ├── LICENSE_OFL.txt │ ├── NotoSans-Regular.ttf │ ├── NotoSansMono-Regular.ttf │ ├── NotoSansMono_32.py │ ├── NotoSans_32.py │ ├── NotoSerif-Regular.ttf │ ├── NotoSerif_32.py │ ├── README.md │ └── inconsolata-700.ttf └── vector │ ├── README.md │ ├── astrol.py │ ├── cyrilc.py │ ├── gotheng.py │ ├── gothger.py │ ├── gothita.py │ ├── greekc.py │ ├── greekcs.py │ ├── greekp.py │ ├── greeks.py │ ├── italicc.py │ ├── italiccs.py │ ├── italict.py │ ├── lowmat.py │ ├── marker.py │ ├── meteo.py │ ├── music.py │ ├── romanc.py │ ├── romancs.py │ ├── romand.py │ ├── romanp.py │ ├── romans.py │ ├── romant.py │ ├── scriptc.py │ ├── scripts.py │ ├── symbol.py │ └── uppmat.py ├── lib ├── axp202c.py └── focaltouch.py ├── micropython.cmake ├── st7789 ├── .clang-format ├── jpg │ ├── tjpgd565.c │ └── tjpgd565.h ├── micropython.cmake ├── micropython.mk ├── mpfile.c ├── mpfile.h ├── png │ ├── miniz.c │ ├── miniz.h │ ├── pngle.c │ └── pngle.h ├── st7789.c └── st7789.h ├── uncrustify.cfg └── utils ├── codeformat.py ├── font2bitmap.py ├── font_from_romfont.py ├── hershey_to_py.py ├── howto-convert-to-jpg ├── imgtobitmap.py ├── maketoast ├── monofont2bitmap.py ├── png_from_font.py ├── requirements.txt ├── sprites2bitmap.py ├── t1.png ├── t2.png ├── t3.png ├── t4.png ├── t5.png ├── toasters.bmp └── wi-alien.svg /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .idea 3 | __pycache__ 4 | sphinx/build 5 | *~ 6 | *.pyc 7 | *.o 8 | *.P 9 | .DS_Store 10 | .history 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2020, 2021, 2022 Russ Hughes 3 | 4 | These files incorporate work covered by the following copyright and 5 | permission notice and are licensed under the same terms: 6 | 7 | The MIT License (MIT) 8 | 9 | Copyright (c) 2019 Ivan Belokobylskiy 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in 19 | all copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | THE SOFTWARE. 28 | 29 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.2.1 2 | -------------------------------------------------------------------------------- /docs/ST7789.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/ST7789.jpg -------------------------------------------------------------------------------- /docs/madctl_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/madctl_0.png -------------------------------------------------------------------------------- /docs/madctl_v.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/madctl_v.png -------------------------------------------------------------------------------- /docs/madctl_vx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/madctl_vx.png -------------------------------------------------------------------------------- /docs/madctl_vxy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/madctl_vxy.png -------------------------------------------------------------------------------- /docs/madctl_vy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/madctl_vy.png -------------------------------------------------------------------------------- /docs/madctl_x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/madctl_x.png -------------------------------------------------------------------------------- /docs/madctl_xy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/madctl_xy.png -------------------------------------------------------------------------------- /docs/madctl_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/madctl_y.png -------------------------------------------------------------------------------- /docs/vga1_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga1_16x16.png -------------------------------------------------------------------------------- /docs/vga1_16x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga1_16x32.png -------------------------------------------------------------------------------- /docs/vga1_8x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga1_8x16.png -------------------------------------------------------------------------------- /docs/vga1_8x8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga1_8x8.png -------------------------------------------------------------------------------- /docs/vga1_bold_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga1_bold_16x16.png -------------------------------------------------------------------------------- /docs/vga1_bold_16x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga1_bold_16x32.png -------------------------------------------------------------------------------- /docs/vga2_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga2_16x16.png -------------------------------------------------------------------------------- /docs/vga2_16x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga2_16x32.png -------------------------------------------------------------------------------- /docs/vga2_8x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga2_8x16.png -------------------------------------------------------------------------------- /docs/vga2_8x8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga2_8x8.png -------------------------------------------------------------------------------- /docs/vga2_bold_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga2_bold_16x16.png -------------------------------------------------------------------------------- /docs/vga2_bold_16x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/docs/vga2_bold_16x32.png -------------------------------------------------------------------------------- /examples/bitmap_fonts.py: -------------------------------------------------------------------------------- 1 | """ 2 | fonts.py 3 | 4 | Cycles through all characters of four bitmap fonts on the display 5 | 6 | """ 7 | 8 | import utime 9 | import st7789 10 | import tft_config 11 | import vga1_8x8 as font1 12 | import vga1_8x16 as font2 13 | import vga1_bold_16x16 as font3 14 | import vga1_bold_16x32 as font4 15 | 16 | 17 | tft = tft_config.config(0) 18 | 19 | 20 | def main(): 21 | tft.init() 22 | 23 | while True: 24 | for font in (font1, font2, font3, font4): 25 | tft.fill(st7789.BLUE) 26 | line = 0 27 | col = 0 28 | for char in range(font.FIRST, font.LAST): 29 | tft.text(font, chr(char), col, line, st7789.WHITE, st7789.BLUE) 30 | col += font.WIDTH 31 | if col > tft.width() - font.WIDTH: 32 | col = 0 33 | line += font.HEIGHT 34 | 35 | if line > tft.height()-font.HEIGHT: 36 | utime.sleep(3) 37 | tft.fill(st7789.BLUE) 38 | line = 0 39 | col = 0 40 | 41 | utime.sleep(3) 42 | 43 | main() 44 | -------------------------------------------------------------------------------- /examples/chango/chango.py: -------------------------------------------------------------------------------- 1 | """ 2 | chango.py proportional font test for font2bitmap converter. 3 | """ 4 | 5 | import time 6 | import gc 7 | import st7789 8 | import tft_config 9 | 10 | tft = tft_config.config(1) 11 | 12 | # 13 | # Large fonts take a lot of memory, they should be frozen in the 14 | # firmware or compiled using the mpy-cross compiler. 15 | # 16 | 17 | import chango_16 as font_16 18 | import chango_32 as font_32 19 | import chango_64 as font_64 20 | 21 | gc.collect() 22 | 23 | def display_font(font): 24 | 25 | tft.fill(st7789.BLUE) # clear the screen 26 | column = 0 # first column 27 | row = 0 # first row 28 | 29 | for char in font.MAP: # for each character in the font map 30 | width = tft.write_len(font, char) # get the width of the character 31 | 32 | if column + width > tft.width(): # if the character will not fit on the current line 33 | row += font.HEIGHT # move to the next row 34 | column = 0 # reset the column 35 | 36 | if row+font.HEIGHT > tft.height(): # if the row will not fit on the screen 37 | time.sleep(1) # pause for a second 38 | tft.fill(st7789.BLUE) # clear the screen 39 | row = 0 # reset the row 40 | 41 | tft.write( # write to the screen 42 | font, # in this font 43 | char, # the character 44 | column, # at this column 45 | row, # on this row 46 | st7789.WHITE, # in white 47 | st7789.BLUE) # with blue background 48 | 49 | column += width # move the column past the character 50 | 51 | def main(): 52 | tft.init() 53 | tft.fill(st7789.BLUE) 54 | 55 | for font in [font_16, font_32, font_64]: # for each font 56 | display_font(font) # display the font characters 57 | time.sleep(1) # pause for a second 58 | 59 | 60 | main() 61 | -------------------------------------------------------------------------------- /examples/chango/make_fonts_py.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ../../utils/font2bitmap.py ../../fonts/truetype/Chango-Regular.ttf 16 -c 0x20-0x7f > chango_16.py 4 | ../../utils/font2bitmap.py ../../fonts/truetype/Chango-Regular.ttf 32 -c 0x20-0x7f > chango_32.py 5 | ../../utils/font2bitmap.py ../../fonts/truetype/Chango-Regular.ttf 64 -c 0x20-0x7f > chango_64.py 6 | 7 | mpy-cross chango_16.py 8 | mpy-cross chango_32.py 9 | mpy-cross chango_64.py 10 | 11 | -------------------------------------------------------------------------------- /examples/clock/OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright 2018 The Pacifico Project Authors (https://github.com/googlefonts/Pacifico) 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /examples/clock/Pacifico-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/Pacifico-Regular.ttf -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa01.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa02.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa03.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa04.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa05.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa06.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa07.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa08.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa09.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa10.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa11.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa12.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa13.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa14.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa15.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa16.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa17.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa18.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa19.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa20.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa21.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa22.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa23.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa24.jpg -------------------------------------------------------------------------------- /examples/clock/clock_128x128/nasa25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_128x128/nasa25.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa01.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa02.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa03.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa04.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa05.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa06.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa07.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa08.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa09.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa10.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa11.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa12.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa13.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa14.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa15.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa16.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa17.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa18.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa19.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa20.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa21.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa22.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa23.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa24.jpg -------------------------------------------------------------------------------- /examples/clock/clock_160x128/nasa25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_160x128/nasa25.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa01.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa02.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa03.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa04.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa05.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa06.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa07.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa08.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa09.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa10.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa11.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa12.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa13.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa14.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa15.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa16.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa17.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa18.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa19.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa20.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa21.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa22.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa23.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa24.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x135/nasa25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x135/nasa25.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa01.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa02.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa03.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa04.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa05.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa06.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa07.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa08.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa09.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa10.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa11.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa12.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa13.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa14.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa15.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa16.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa17.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa18.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa19.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa20.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa21.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa22.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa23.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa24.jpg -------------------------------------------------------------------------------- /examples/clock/clock_240x240/nasa25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_240x240/nasa25.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa01.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa02.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa03.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa04.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa05.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa06.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa07.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa08.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa09.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa10.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa11.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa12.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa13.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa14.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa15.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa16.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa17.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa18.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa19.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa20.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa21.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa22.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa23.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa24.jpg -------------------------------------------------------------------------------- /examples/clock/clock_320x240/nasa25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/clock/clock_320x240/nasa25.jpg -------------------------------------------------------------------------------- /examples/clock/pacifico30.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Converted from Pacifico-Regular.ttf using: 3 | # ../../utils/font2bitmap.py -s '0123456789:. ' Pacifico-Regular.ttf 30 4 | 5 | MAP = ( 6 | '.2 4130895:67' 7 | ) 8 | BPP = 1 9 | HEIGHT = 18 10 | MAX_WIDTH = 17 11 | _WIDTHS = \ 12 | b'\x08\x11\x08\x11\x0b\x10\x10\x0f\x10\x10\x08\x10\x10' 13 | 14 | OFFSET_WIDTH = 2 15 | _OFFSETS = \ 16 | b'\x00\x00\x00\x90\x01\xc2\x02\x52\x03\x84\x04\x4a\x05\x6a\x06\x8a'\ 17 | b'\x07\x98\x08\xb8\x09\xd8\x0a\x68\x0b\x88' 18 | 19 | _BITMAPS =\ 20 | b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x38\x7c\x7c\x7c'\ 21 | b'\x7c\x38\x03\xf0\x07\xfe\x03\xff\x03\xe7\xc1\xc1\xe1\xe0\xf0\x70'\ 22 | b'\x78\x30\x3c\x00\x3c\x00\x3e\x00\x3e\x00\x3e\x00\x3e\x00\x7c\x00'\ 23 | b'\xfc\x00\xff\xfc\x7f\xff\x1f\xff\x00\x00\x00\x00\x00\x00\x00\x00'\ 24 | b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x70\x00\x78\x00\x78'\ 25 | b'\x00\x3c\x00\x3c\x38\x1e\x3c\x1e\x1e\x0f\x0e\x0f\x0f\x07\x87\x83'\ 26 | b'\xc3\xc3\xff\xf8\xff\xfe\x7f\xfe\x00\x38\x00\x1c\x00\x0e\x00\x07'\ 27 | b'\x00\x08\x1f\x8f\xf1\xfe\x3b\xc0\xf0\x1e\x03\xc0\x78\x0f\x01\xe0'\ 28 | b'\x3c\x0f\x01\xe0\x3c\x07\x80\xf0\x1c\x00\xfc\x03\xfe\x07\xff\x0f'\ 29 | b'\x9f\x0e\x0f\x8e\x0f\x04\x0f\x00\x1e\x00\xfc\x00\xfc\x00\xfe\x00'\ 30 | b'\x0f\x1c\x0f\x1c\x0f\x1f\x3f\x1f\xff\x0f\xfe\x03\xf8\x00\x00\x00'\ 31 | b'\xfc\x01\xfe\x03\xff\x07\x8f\x8f\x07\x8f\x07\x8f\x07\x8e\x07\x8e'\ 32 | b'\x07\x8e\x07\x8e\x07\x8e\x07\x8f\x0f\x0f\x9f\x07\xfe\x07\xfc\x01'\ 33 | b'\xf0\x00\xfc\x07\xfe\x1f\xfc\x3c\x7c\xf0\x79\xe0\xe3\xe3\xc3\xff'\ 34 | b'\x03\xfc\x07\xf8\x1f\xf8\x70\xf9\xe0\xf3\xc1\xe7\xc7\xc7\xff\x0f'\ 35 | b'\xfc\x07\xf0\x03\xf0\x0f\xf8\x1f\xfc\x1e\x3c\x3c\x1e\x3c\x1e\x3c'\ 36 | b'\x1e\x3e\x3e\x1f\xfe\x1f\xfe\x0f\xde\x00\x1e\x30\x3c\x78\x3c\x7c'\ 37 | b'\xf8\x3f\xf0\x3f\xe0\x0f\xc0\x00\x00\x1f\xfe\x3f\xfe\x3f\xfe\x1e'\ 38 | b'\x00\x1e\x00\x1e\x00\x1f\xc0\x1f\xf0\x1f\xf8\x00\xfc\x00\x3c\x38'\ 39 | b'\x3c\x78\x3c\x7e\x7c\x3f\xf8\x1f\xf0\x0f\xe0\x00\x00\x00\x1e\x3e'\ 40 | b'\x3e\x3e\x3e\x1c\x00\x00\x00\x38\x7c\x7c\x7c\x7c\x38\x01\xf8\x07'\ 41 | b'\xfc\x0f\xfe\x1f\x1e\x1e\x0e\x3c\x0e\x3c\x00\x3d\xf0\x3b\xf8\x3f'\ 42 | b'\xfc\x7e\x3c\x3c\x1e\x3c\x1e\x3c\x3c\x3e\x7c\x1f\xf8\x0f\xf0\x07'\ 43 | b'\xe0\x10\x02\x3f\xfe\x7f\xff\x3f\xfe\x00\x7c\x00\xf0\x01\xe0\x03'\ 44 | b'\xe0\x03\xc0\x07\x80\x07\x80\x0f\x80\x0f\x00\x0f\x00\x0f\x00\x0f'\ 45 | b'\x00\x0f\x00\x0e\x00' 46 | 47 | WIDTHS = memoryview(_WIDTHS) 48 | OFFSETS = memoryview(_OFFSETS) 49 | BITMAPS = memoryview(_BITMAPS) 50 | -------------------------------------------------------------------------------- /examples/clock/pacifico40.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Converted from Pacifico-Regular.ttf using: 3 | # ../../utils/font2bitmap.py -s '0123456789:. ' Pacifico-Regular.ttf 40 4 | 5 | MAP = ( 6 | '1924.73 5680:' 7 | ) 8 | BPP = 1 9 | HEIGHT = 25 10 | MAX_WIDTH = 23 11 | _WIDTHS = \ 12 | b'\x0f\x16\x16\x17\x0a\x15\x15\x0b\x15\x16\x14\x16\x0a' 13 | 14 | OFFSET_WIDTH = 2 15 | _OFFSETS = \ 16 | b'\x00\x00\x01\x77\x03\x9d\x05\xc3\x08\x02\x08\xfc\x0b\x09\x0d\x16'\ 17 | b'\x0e\x29\x10\x36\x12\x5c\x14\x50\x16\x76' 18 | 19 | _BITMAPS =\ 20 | b'\x00\x00\x01\xe0\x1f\xe0\xff\xc3\xff\x87\xff\x0f\xfe\x08\xfc\x01'\ 21 | b'\xf0\x03\xe0\x07\xc0\x0f\x80\x1f\x00\x7e\x00\xfc\x01\xf8\x03\xe0'\ 22 | b'\x07\xc0\x0f\x80\x1f\x00\x3e\x00\xfc\x01\xf8\x03\xe0\x03\xc0\x00'\ 23 | b'\x00\x00\x07\xf0\x00\x7f\xf0\x03\xff\xe0\x1f\xff\xc0\x7f\x7f\x03'\ 24 | b'\xf0\x7e\x0f\x81\xf8\x3e\x03\xe0\xf8\x1f\x83\xe0\x7e\x0f\xe7\xf8'\ 25 | b'\x1f\xff\xe0\x7f\xff\x80\xff\xbe\x00\xf8\xf8\x00\x07\xc0\xc0\x1f'\ 26 | b'\x07\x80\xfc\x1f\x03\xe0\x7f\x7f\x81\xff\xfc\x03\xff\xe0\x07\xfe'\ 27 | b'\x00\x07\xe0\x00\x00\x00\x00\x0f\xe0\x00\xff\xe0\x0f\xff\xc0\x3f'\ 28 | b'\xff\x01\xfc\xfe\x07\xc1\xf8\x3e\x03\xe0\xf8\x0f\x83\xe0\x3e\x07'\ 29 | b'\x81\xf8\x00\x07\xc0\x00\x3f\x00\x00\xf8\x00\x07\xe0\x00\x3f\x00'\ 30 | b'\x03\xf8\x00\x1f\xc0\x01\xfc\x00\x1f\xe0\x00\xfe\x00\x07\xff\xff'\ 31 | b'\x1f\xff\xfc\x7f\xff\xf1\xff\xff\x80\x02\x00\x00\x1e\x00\x00\x7c'\ 32 | b'\x00\x01\xf8\x00\x03\xe0\x00\x0f\xc0\x00\x1f\x07\x00\x7e\x1f\x00'\ 33 | b'\xf8\x3e\x03\xf0\xfc\x07\xc1\xf0\x1f\x83\xe0\x3e\x07\xc0\x7c\x0f'\ 34 | b'\x81\xf0\x1f\x03\xff\xff\xc7\xff\xff\x8f\xff\xff\x0f\xff\xfe\x00'\ 35 | b'\x07\xc0\x00\x0f\x80\x00\x1f\x00\x00\x3e\x00\x00\x78\x00\x00\xf0'\ 36 | b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\ 37 | b'\x00\x00\x00\x00\x00\x01\xe0\xfc\x7f\x1f\xe7\xf9\xfc\x3f\x07\x80'\ 38 | b'\x00\x00\x0f\x80\x38\xff\xff\xe7\xff\xff\x3f\xff\xf9\xff\xff\x80'\ 39 | b'\x01\xf8\x00\x1f\x00\x03\xf0\x00\x1f\x00\x01\xf0\x00\x1f\x00\x01'\ 40 | b'\xf8\x00\x0f\x80\x00\xfc\x00\x07\xe0\x00\x3e\x00\x03\xf0\x00\x1f'\ 41 | b'\x80\x00\xfc\x00\x07\xc0\x00\x3e\x00\x01\xf0\x00\x0f\x80\x00\x38'\ 42 | b'\x00\x00\x00\x00\x03\xf8\x00\x7f\xf0\x0f\xff\xc0\xff\xff\x07\xf3'\ 43 | b'\xf8\x7e\x07\xc3\xe0\x3e\x0f\x01\xf0\x70\x1f\x80\x01\xf8\x00\x3f'\ 44 | b'\x80\x07\xf8\x00\x7f\x80\x01\xff\x00\x01\xfc\x00\x03\xf0\xe0\x0f'\ 45 | b'\x8f\x80\xfc\x7c\x07\xe3\xf8\xff\x0f\xff\xf0\x7f\xff\x01\xff\xf0'\ 46 | b'\x01\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\ 47 | b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\ 48 | b'\x00\x00\x00\x00\x00\x00\x00\x00\x1f\xff\x83\xff\xfe\x1f\xff\xf0'\ 49 | b'\xff\xff\x81\xf0\x00\x0f\x00\x00\xf8\x00\x07\xc0\x00\x3e\x00\x01'\ 50 | b'\xff\x00\x1f\xff\x00\xff\xfc\x03\xff\xf0\x01\xff\x80\x00\xfe\x00'\ 51 | b'\x03\xf0\xf0\x0f\x87\x80\x7c\x3e\x07\xe1\xf8\x7e\x0f\xff\xf0\x3f'\ 52 | b'\xff\x00\xff\xf0\x01\xfe\x00\x00\x00\x00\x03\xf0\x00\x3f\xf0\x03'\ 53 | b'\xff\xe0\x1f\xff\xc0\x7f\x7f\x03\xf0\x7e\x1f\x80\xf8\x7c\x01\xc1'\ 54 | b'\xf0\x00\x0f\xcf\x80\x3e\xff\x80\xff\xff\x03\xff\xfe\x0f\xf3\xf8'\ 55 | b'\x3f\x03\xe0\xfc\x0f\x83\xf0\x3e\x0f\xc0\xf8\x1f\x07\xe0\x7f\x7f'\ 56 | b'\x80\xff\xfc\x03\xff\xe0\x07\xff\x00\x07\xf0\x00\x00\x00\x00\xfe'\ 57 | b'\x00\x3f\xf8\x07\xff\xc0\xff\xfe\x1f\xe7\xe1\xf8\x3f\x1f\x01\xe1'\ 58 | b'\xf0\x3e\x1f\x83\xe0\xfc\xfc\x0f\xff\x80\x7f\xf0\x03\xff\x00\xff'\ 59 | b'\xfc\x1f\x1f\xc3\xe0\x7e\x3e\x03\xe3\xc0\x3e\x3e\x03\xe3\xf8\xfe'\ 60 | b'\x3f\xff\xc1\xff\xf8\x0f\xff\x00\x3f\xc0\x00\x00\x00\x01\xf8\x00'\ 61 | b'\x1f\xf8\x00\xff\xf0\x07\xff\xe0\x3f\xbf\x80\xf8\x3f\x07\xc0\x7c'\ 62 | b'\x1f\x01\xf0\x7c\x07\xc3\xe0\x1f\x0f\x80\x7c\x3e\x01\xf0\xf8\x07'\ 63 | b'\xc3\xe0\x1f\x0f\x80\x7c\x3e\x01\xf0\xf8\x0f\x83\xf0\x3e\x07\xc1'\ 64 | b'\xf0\x1f\xdf\xc0\x3f\xfe\x00\xff\xf0\x01\xff\x80\x01\xf8\x00\x00'\ 65 | b'\x00\x00\x00\x00\x00\x00\x03\xe1\xf8\x7f\x1f\xc7\xf1\xfc\x7e\x0f'\ 66 | b'\x00\x00\x00\x00\x1e\x0f\xc7\xf1\xfe\x7f\x9f\xc3\xf0\x78' 67 | 68 | WIDTHS = memoryview(_WIDTHS) 69 | OFFSETS = memoryview(_OFFSETS) 70 | BITMAPS = memoryview(_BITMAPS) 71 | -------------------------------------------------------------------------------- /examples/configs/README.md: -------------------------------------------------------------------------------- 1 | # Displays Modules 2 | 3 | The following folders contain tft_config.py modules used by the example programs to configure the display. Install the approate configuration module for your device. 4 | 5 | Folder | Device 6 | --------------- | ------------------------------------------------- 7 | esp32_7735_128 | Generic ESP32 st7735 128x128 Display 8 | esp32_7735_160 | Generic ESP32 st7735 128x160 Display 9 | esp32_st7789 | Generic ESP32 st7789 240x320 Display 10 | esp32_box_lite | ESP32 Box and Box Lite ili9342c 320x240 Display 11 | m5stack_core | M5Stack Core ili9342 320x240 Display 12 | m5stack_core2 | M5Stack Core2 ili9342 320x240 Display 13 | pybv11_st7789 | Pyboard Version 1.1 st7789 240x320 Display 14 | tdisplay_esp32 | TTGO T-DISPLAY ESP32 st7789 135x240 Display 15 | tdisplay_rp2040 | TTGO T-DISPLAY RP2040 st7789 135x240 Display 16 | t_dongle_s3 | TTGO T-DONGLE-S3 80x160 ST7735 Display 17 | t-picoc3 | TTGO T-PicoC3 st7789 135x240 Display 18 | twatch_2020_v2 | TTGO TWATCH-2020 v2 st7789 240x240 Display 19 | wio_terminal | Seeed Wio Terminal ili9341 320x240 Display 20 | ws_pico_114 | Raspberry Pi Pico Waveshare-Pico-lcd-1.14 Display 21 | ws_pico_13 | Raspberry Pi Pico Waveshare-Pico-lcd-1.3 Display 22 | ws_pico_2 | Raspberry Pi Pico Waveshare-Pico-lcd-2 Display 23 | 24 | # Button Modules 25 | 26 | These following folders contain buttons.py config modules that are used by the roids.py example program to configure the buttons. 27 | 28 | Folder | Device 29 | --------------- | ------------------------------------------------- 30 | esp32_buttons | Generic ESP32 buttons as used on my breadboard. 31 | ws_pico_114 | Raspberry Pi Pico Waveshare-Pico-lcd-1.14 Display 32 | ws_pico_13 | Raspberry Pi Pico Waveshare-Pico-lcd-1.3 Display 33 | ws_pico_2 | Raspberry Pi Pico Waveshare-Pico-lcd-2 Display 34 | tdisplay_esp32 | TTGO T-DISPLAY ESP32 35 | tdisplay_rp2040 | TTGO T-DISPLAY RP2040 36 | -------------------------------------------------------------------------------- /examples/configs/adafruit_320x172/tft_config.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | Adafruit 1.47" 320x172 Round Rectangle Color IPS TFT Display - Product ID: 5393 4 | 5 | Assumes the following pin use, modify code below for your configuration: 6 | sck: 18, mosi: 19, reset: 23, cs: 5, dc: 16, backlight: 4 7 | 8 | NOTE: Reduce the SPI baudrate below 26.7MHz unless you are using my compiled firmware or you modify 9 | the spi_device_interface_config_t devcfg.flags setting in the micropython/ports/esp machine_hw_spi.c 10 | file to include the SPI_DEVICE_NO_DUMMY flag. 11 | 12 | for example change line 262 in micropython/ports/esp32/machine_hw_spi.c from this: 13 | 14 | .flags = self->firstbit == MICROPY_PY_MACHINE_SPI_LSB ? SPI_DEVICE_TXBIT_LSBFIRST | SPI_DEVICE_RXBIT_LSBFIRST : 0, 15 | 16 | to this: 17 | 18 | .flags = self->firstbit == MICROPY_PY_MACHINE_SPI_LSB ? SPI_DEVICE_TXBIT_LSBFIRST | SPI_DEVICE_RXBIT_LSBFIRST : 0 | SPI_DEVICE_NO_DUMMY, 19 | 20 | Recompile and flash the firmware and you can use the 40MHz speed. 21 | """ 22 | 23 | 24 | """ 25 | Adafruit 1.47" 320x172 Round Rectangle Color IPS TFT Display - Product ID: 5393 26 | """ 27 | 28 | from machine import Pin, SPI 29 | import st7789 30 | 31 | TFA = 40 32 | BFA = 40 33 | 34 | custom_rotations = [ 35 | (0x00, 172, 320, 34, 0), 36 | (0x60, 320, 172, 0, 34), 37 | (0xc0, 172, 320, 34, 0), 38 | (0xa0, 320, 172, 0, 34), 39 | ] 40 | 41 | def config(rotation=0, buffer_size=0, options=0): 42 | return st7789.ST7789( 43 | SPI(2, baudrate=40000000, sck=Pin(18), mosi=Pin(19), miso=None), 44 | 172, 45 | 320, 46 | reset=Pin(23, Pin.OUT), 47 | cs=Pin(5, Pin.OUT), 48 | dc=Pin(16, Pin.OUT), 49 | backlight=Pin(4, Pin.OUT), 50 | rotations=custom_rotations, 51 | rotation=rotation, 52 | options=options, 53 | buffer_size= buffer_size) 54 | -------------------------------------------------------------------------------- /examples/configs/esp32_7735_128/tft_config.py: -------------------------------------------------------------------------------- 1 | """Generic ESP32 with 128x128 7735 display""" 2 | 3 | from machine import Pin, SPI 4 | import st7789 5 | 6 | TFA = 1 7 | BFA = 3 8 | 9 | def config(rotation=0, buffer_size=0, options=0): 10 | return st7789.ST7789( 11 | SPI(1, baudrate=30000000, sck=Pin(18), mosi=Pin(19)), 12 | 128, 13 | 128, 14 | reset=Pin(4, Pin.OUT), 15 | cs=Pin(13, Pin.OUT), 16 | dc=Pin(12, Pin.OUT), 17 | backlight=Pin(15, Pin.OUT), 18 | color_order=st7789.BGR, 19 | inversion=False, 20 | rotation=rotation, 21 | options=options, 22 | buffer_size=buffer_size) 23 | -------------------------------------------------------------------------------- /examples/configs/esp32_7735_160/tft_config.py: -------------------------------------------------------------------------------- 1 | """Generic ESP32 with 128x160 7735 display""" 2 | 3 | from machine import Pin, SPI 4 | import st7789 5 | 6 | TFA = 0 7 | BFA = 0 8 | 9 | def config(rotation=0, buffer_size=0, options=0): 10 | return st7789.ST7789( 11 | SPI(1, baudrate=20000000, sck=Pin(18), mosi=Pin(19)), 12 | 128, 13 | 160, 14 | reset=Pin(4, Pin.OUT), 15 | cs=Pin(13, Pin.OUT), 16 | dc=Pin(12, Pin.OUT), 17 | backlight=Pin(15, Pin.OUT), 18 | color_order=st7789.RGB, 19 | inversion=False, 20 | rotation=rotation, 21 | options=options, 22 | buffer_size=buffer_size) 23 | -------------------------------------------------------------------------------- /examples/configs/esp32_box_lite/tft_buttons.py: -------------------------------------------------------------------------------- 1 | # input pins for my esp32 test breadboard 2 | 3 | from machine import Pin 4 | 5 | class Buttons(): 6 | def __init__(self): 7 | self.left = 0 8 | self.right = 0 9 | self.hyper = 0 10 | self.thrust = 0 11 | self.fire = 0 12 | -------------------------------------------------------------------------------- /examples/configs/esp32_box_lite/tft_config.py: -------------------------------------------------------------------------------- 1 | """ESP32 Box or Box Lite with ili9342c 320x240 display""" 2 | 3 | from machine import Pin, SPI, freq 4 | import st7789 5 | 6 | TFA = 0 7 | BFA = 0 8 | 9 | def config(rotation=0, buffer_size=0, options=0): 10 | custom_init = [ 11 | (b'\x01', 150), # soft reset 12 | (b'\x11', 255), # exit sleep 13 | (b'\xCB\x39\x2C\x00\x34\x02',), # power control A 14 | (b'\xCF\x00\xC1\x30',), # power control B 15 | (b'\xE8\x85\x00\x78',), # driver timing control A 16 | (b'\xEA\x00\x00',), # driver timing control B 17 | (b'\xED\x64\x03\x12\x81',), # power on sequence control 18 | (b'\xF7\x20',), # pump ratio control 19 | (b'\xC0\x23',), # power control,VRH[5:0] 20 | (b'\xC1\x10',), # Power control,SAP[2:0];BT[3:0] 21 | (b'\xC5\x3E\x28',), # vcm control 22 | (b'\xC7\x86',), # vcm control 2 23 | (b'\x3A\x55',), # pixel format 24 | (b'\x36\x08',), # madctl 25 | (b'\xB1\x00\x18',), # frameration control,normal mode full colours 26 | (b'\xB6\x08\x82\x27',), # display function control 27 | (b'\xF2\x00',), # 3gamma function disable 28 | (b'\x26\x01',), # gamma curve selected 29 | # set positive gamma correction 30 | (b'\xE0\x0F\x31\x2B\x0C\x0E\x08\x4E\xF1\x37\x07\x10\x03\x0E\x09\x00',), 31 | # set negative gamma correction 32 | (b'\xE1\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F',), 33 | (b'\x29', 100), # display on 34 | ] 35 | 36 | # rotated 180 degrees -- scrolling demos need to be modified to 37 | # to scroll in the opposite direction. 38 | custom_rotations = [ 39 | (0xc8, 320, 240, 0, 0), 40 | (0xa8, 240, 320, 0, 0), 41 | (0x08, 320, 240, 0, 0), 42 | (0x68, 240, 320, 0, 0), 43 | ] 44 | 45 | # upside down -- scrolling demos are scrolled in the correct direction. 46 | # custom_rotations = [ 47 | # (0x08, 320, 240, 0, 0), 48 | # (0x68, 240, 320, 0, 0), 49 | # (0xc8, 320, 240, 0, 0), 50 | # (0xa8, 240, 320, 0, 0), 51 | # ] 52 | 53 | # Set clock to 240MHz 54 | freq(240000000) 55 | 56 | # To use baudrates above 26.6MHz you must use my firmware or modify the micropython 57 | # source code to increase the SPI baudrate limit by adding SPI_DEVICE_NO_DUMMY to the 58 | # .flag member of the spi_device_interface_config_t struct in the machine_hw_spi_init_internal.c 59 | # file. Not doing so will cause the ESP32 to crash if you use a baudrate that is too high. 60 | 61 | return st7789.ST7789( 62 | SPI(1, baudrate=40000000, sck=Pin(7), mosi=Pin(6)), 63 | 320, 64 | 240, 65 | reset=Pin(48, Pin.OUT), 66 | cs=Pin(5, Pin.OUT), 67 | dc=Pin(4, Pin.OUT), 68 | backlight=Pin(45, Pin.OUT), 69 | custom_init=custom_init, 70 | rotations=custom_rotations, 71 | rotation=rotation, 72 | options=options, 73 | inversion=False, 74 | color_order=st7789.BGR, 75 | buffer_size=buffer_size) 76 | -------------------------------------------------------------------------------- /examples/configs/esp32_buttons/tft_buttons.py: -------------------------------------------------------------------------------- 1 | # input pins for my esp32 test breadboard 2 | 3 | from machine import Pin 4 | 5 | class Buttons(): 6 | def __init__(self): 7 | self.left = Pin(32, Pin.IN) 8 | self.right = Pin(39, Pin.IN) 9 | self.hyper = Pin(38, Pin.IN) 10 | self.thrust = Pin(37, Pin.IN) 11 | self.fire = Pin(36, Pin.IN) 12 | -------------------------------------------------------------------------------- /examples/configs/esp32_st7789/tft_config.py: -------------------------------------------------------------------------------- 1 | """Generic ESP32 with ST7789 240x320 display""" 2 | 3 | from machine import Pin, SPI 4 | import st7789 5 | 6 | TFA = 0 7 | BFA = 0 8 | 9 | def config(rotation=0, buffer_size=0, options=0): 10 | return st7789.ST7789( 11 | SPI(1, baudrate=31250000, sck=Pin(18), mosi=Pin(19)), 12 | 240, 13 | 320, 14 | reset=Pin(4, Pin.OUT), 15 | cs=Pin(13, Pin.OUT), 16 | dc=Pin(12, Pin.OUT), 17 | backlight=Pin(15, Pin.OUT), 18 | rotation=rotation, 19 | options=options, 20 | buffer_size=buffer_size) 21 | -------------------------------------------------------------------------------- /examples/configs/esp32c3_st7789_240/tft_config.py: -------------------------------------------------------------------------------- 1 | """Generic ESP32-C3 with ST7789 240x240 display""" 2 | 3 | from machine import Pin, SPI 4 | import st7789 5 | 6 | TFA = 0 7 | BFA = 80 8 | 9 | def config(rotation=0, buffer_size=0, options=0): 10 | return st7789.ST7789( 11 | SPI(1, baudrate=80000000, polarity=1, sck=Pin(6), mosi=Pin(7)), 12 | 240, 13 | 240, 14 | reset=Pin(10, Pin.OUT), 15 | dc=Pin(4, Pin.OUT), 16 | rotation=rotation, 17 | options=options, 18 | buffer_size=buffer_size) 19 | -------------------------------------------------------------------------------- /examples/configs/m5stack_core/tft_buttons.py: -------------------------------------------------------------------------------- 1 | 2 | # input pins for M5Stack Core buttons 3 | 4 | from machine import Pin 5 | 6 | 7 | class Buttons(): 8 | def __init__(self): 9 | self.name = "m5stack_core" 10 | 11 | self.button_a = Pin(39, Pin.IN) # button A 12 | self.button_b = Pin(38, Pin.IN) # button B 13 | self.button_c = Pin(37, Pin.IN) # button C 14 | 15 | -------------------------------------------------------------------------------- /examples/configs/m5stack_core/tft_config.py: -------------------------------------------------------------------------------- 1 | """M5Stack CORE ili9342 320x240 display""" 2 | 3 | from machine import Pin, SPI, freq 4 | import st7789 5 | 6 | TFA = 0 7 | BFA = 0 8 | 9 | 10 | def config(rotation=0, buffer_size=0, options=0): 11 | """Configure the M5Stack CORE display using a custom_init and 12 | custom_rotations since the display is ili9342c. The custom_init is a 13 | list of commands to send to the display during the init() metehod. The 14 | list contains tuples with a bytes object, optionally followed by a 15 | delay specified in ms. The first byte of the bytes object contains the 16 | command to send optionally followed by data bytes. 17 | """ 18 | 19 | custom_init = [ 20 | (b'\x01', 150), # soft reset 21 | (b'\x11', 255), # exit sleep 22 | (b'\xCB\x39\x2C\x00\x34\x02',), # power control A 23 | (b'\xCF\x00\xC1\x30',), # power control B 24 | (b'\xE8\x85\x00\x78',), # driver timing control A 25 | (b'\xEA\x00\x00',), # driver timing control B 26 | (b'\xED\x64\x03\x12\x81',), # power on sequence control 27 | (b'\xF7\x20',), # pump ratio control 28 | (b'\xC0\x23',), # power control,VRH[5:0] 29 | (b'\xC1\x10',), # Power control,SAP[2:0];BT[3:0] 30 | (b'\xC5\x3E\x28',), # vcm control 31 | (b'\xC7\x86',), # vcm control 2 32 | (b'\x3A\x55',), # pixel format 33 | (b'\x36\x00',), # madctl 34 | (b'\x21',), # inversion on 35 | (b'\xB1\x00\x18',), # frameration control,normal mode full colours 36 | (b'\xB6\x08\x82\x27',), # display function control 37 | (b'\xF2\x00',), # 3gamma function disable 38 | (b'\x26\x01',), # gamma curve selected 39 | # set positive gamma correction 40 | (b'\xE0\x0F\x31\x2B\x0C\x0E\x08\x4E\xF1\x37\x07\x10\x03\x0E\x09\x00',), 41 | # set negative gamma correction 42 | (b'\xE1\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F',), 43 | (b'\x29', 100), # display on 44 | ] 45 | 46 | custom_rotations = [ 47 | (0x08, 320, 240, 0, 0), 48 | (0x68, 240, 320, 0, 0), 49 | (0xc8, 320, 240, 0, 0), 50 | (0xa8, 240, 320, 0, 0), 51 | ] 52 | 53 | # Set clock to 240MHz 54 | freq(240000000) 55 | 56 | return st7789.ST7789( 57 | SPI(2, baudrate=60000000, sck=Pin(18), mosi=Pin(23)), 58 | 320, 59 | 240, 60 | reset=Pin(33, Pin.OUT), 61 | cs=Pin(14, Pin.OUT), 62 | dc=Pin(27, Pin.OUT), 63 | backlight=Pin(32, Pin.OUT), 64 | custom_init=custom_init, 65 | rotations=custom_rotations, 66 | rotation=rotation, 67 | color_order=st7789.RGB, 68 | inversion=True, 69 | options=options, 70 | buffer_size=buffer_size) 71 | -------------------------------------------------------------------------------- /examples/configs/m5stack_core2/tft_buttons.py: -------------------------------------------------------------------------------- 1 | 2 | # input pins for M5Stack Core2 buttons 3 | 4 | from machine import Pin 5 | 6 | 7 | class Buttons(): 8 | def __init__(self): 9 | self.name = "m5stack_core2" 10 | -------------------------------------------------------------------------------- /examples/configs/m5stack_core2/tft_config.py: -------------------------------------------------------------------------------- 1 | """M5Stack CORE2 ili9342 320x240 display""" 2 | 3 | from machine import Pin, SPI, freq 4 | import st7789 5 | import axp202c 6 | 7 | TFA = 0 8 | BFA = 0 9 | 10 | 11 | def config(rotation=0, buffer_size=0, options=0): 12 | """Configure the M5Stack CORE2 display using a custom_init and 13 | custom_rotations since the display is ili9342c. The custom_init is a 14 | list of commands to send to the display during the init() metehod. The 15 | list contains tuples with a bytes object, optionally followed by a 16 | delay specified in ms. The first byte of the bytes object contains the 17 | command to send optionally followed by data bytes. 18 | """ 19 | custom_init = [ 20 | (b'\x01', 150), # soft reset 21 | (b'\x11', 255), # exit sleep 22 | (b'\xCB\x39\x2C\x00\x34\x02',), # power control A 23 | (b'\xCF\x00\xC1\x30',), # power control B 24 | (b'\xE8\x85\x00\x78',), # driver timing control A 25 | (b'\xEA\x00\x00',), # driver timing control B 26 | (b'\xED\x64\x03\x12\x81',), # power on sequence control 27 | (b'\xF7\x20',), # pump ratio control 28 | (b'\xC0\x23',), # power control,VRH[5:0] 29 | (b'\xC1\x10',), # Power control,SAP[2:0];BT[3:0] 30 | (b'\xC5\x3E\x28',), # vcm control 31 | (b'\xC7\x86',), # vcm control 2 32 | (b'\x3A\x55',), # pixel format 33 | (b'\x36\x00',), # madctl 34 | (b'\x21',), # inversion on 35 | (b'\xB1\x00\x18',), # frameration control,normal mode full colours 36 | (b'\xB6\x08\x82\x27',), # display function control 37 | (b'\xF2\x00',), # 3gamma function disable 38 | (b'\x26\x01',), # gamma curve selected 39 | # set positive gamma correction 40 | (b'\xE0\x0F\x31\x2B\x0C\x0E\x08\x4E\xF1\x37\x07\x10\x03\x0E\x09\x00',), 41 | # set negative gamma correction 42 | (b'\xE1\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F',), 43 | (b'\x29', 100), # display on 44 | ] 45 | 46 | custom_rotations = [ 47 | (0x08, 320, 240, 0, 0), 48 | (0x68, 240, 320, 0, 0), 49 | (0xc8, 320, 240, 0, 0), 50 | (0xa8, 240, 320, 0, 0), 51 | ] 52 | 53 | # Set clock to 240MHz 54 | freq(240000000) 55 | 56 | axp = axp202c.PMU(address=0x34) 57 | axp.enablePower(axp202c.AXP192_LDO2) 58 | # Set backlight voltage 59 | axp.setDC3Voltage(3000) 60 | 61 | return st7789.ST7789( 62 | SPI(2, baudrate=24000000, sck=Pin(18), mosi=Pin(23)), 63 | 320, 64 | 240, 65 | cs=Pin(5, Pin.OUT), 66 | dc=Pin(15, Pin.OUT), 67 | custom_init=custom_init, 68 | rotations=custom_rotations, 69 | rotation=rotation, 70 | color_order=st7789.RGB, 71 | inversion=False, 72 | options=options, 73 | buffer_size=buffer_size) 74 | -------------------------------------------------------------------------------- /examples/configs/pybv11_st7789/tft_config.py: -------------------------------------------------------------------------------- 1 | """PYBOARD V1.1 with Generic 240x320 ST7789 display""" 2 | 3 | from pyb import SPI, Pin 4 | import st7789 5 | 6 | TFA = 0 7 | BFA = 0 8 | 9 | def config(rotation=0, buffer_size=0, options=0): 10 | return st7789.ST7789( 11 | SPI(1, SPI.MASTER, baudrate=42000000, prescaler=2), 12 | 240, 13 | 320, 14 | reset=Pin('X3', Pin.OUT), 15 | cs=Pin('X5', Pin.OUT), 16 | dc=Pin('X4', Pin.OUT), 17 | backlight=Pin('X2', Pin.OUT), 18 | rotation=rotation, 19 | options=options, 20 | buffer_size=buffer_size) 21 | -------------------------------------------------------------------------------- /examples/configs/t-picoc3/tft_config.py: -------------------------------------------------------------------------------- 1 | """TTGO T-PicoC3 RP2040 display""" 2 | 3 | from machine import Pin, SPI 4 | from time import sleep 5 | import st7789 6 | 7 | TFA = 40 # top free area when scrolling 8 | BFA = 40 # bottom free area when scrolling 9 | 10 | def config(rotation=0, buffer_size=0, options=0): 11 | 12 | Pin(22, Pin.OUT, value=1) 13 | 14 | spi = SPI(0, 15 | baudrate=62500000, 16 | polarity=1, 17 | phase=1, 18 | sck=Pin(2, Pin.OUT), 19 | mosi=Pin(3, Pin.OUT), 20 | miso=None) 21 | 22 | return st7789.ST7789( 23 | spi, 24 | 135, 25 | 240, 26 | cs=Pin(5, Pin.OUT), 27 | dc=Pin(1, Pin.OUT), 28 | backlight=Pin(4, Pin.OUT), 29 | rotation=rotation, 30 | options=options, 31 | buffer_size=buffer_size) 32 | -------------------------------------------------------------------------------- /examples/configs/t_dongle_s3/tft_buttons.py: -------------------------------------------------------------------------------- 1 | # input pin for esp32 T-DONGLE-S3 module 2 | 3 | from machine import Pin 4 | 5 | class Buttons(): 6 | def __init__(self): 7 | self.name = "t-dongle-s3" 8 | self.button = Pin(0, Pin.IN) 9 | -------------------------------------------------------------------------------- /examples/configs/t_dongle_s3/tft_config.py: -------------------------------------------------------------------------------- 1 | """ LilyGo T-DONGLE-S3 80x160 ST7735 display """ 2 | 3 | from machine import freq, Pin, SPI 4 | import st7789 5 | 6 | # start in second gear 7 | freq(240000000) 8 | 9 | TFA = 1 10 | BFA = 1 11 | 12 | def config(rotation=0, buffer_size=0, options=0): 13 | """Configure the T-DONGLE-S3 display using a custom_init and 14 | custom_rotations since the display is st7735. 15 | 16 | The custom_init is a list of commands to send to the display during the init() metehod. 17 | The list contains tuples with a bytes object, optionally followed by a delay specified in ms. 18 | The first byte of the bytes object contains the command to send optionally followed by data bytes. 19 | """ 20 | 21 | custom_init = [ 22 | (b'\x01', 150), 23 | (b'\x11', 255), 24 | (b'\xb1\x01\x2c\x2d',), 25 | (b'\xb2\x01\x2c\x2d',), 26 | (b'\xb3\x01\x2c\x2d\x01\x2c\x2d',), 27 | (b'\xb4\x07',), 28 | (b'\xc0\xa2\x02\x84',), 29 | (b'\xc1\xc5',), 30 | (b'\xc2\x0a\x00',), 31 | (b'\xc3\x8a\x2a',), 32 | (b'\xc4\x8a\xee',), 33 | (b'\xc5\x0e',), 34 | (b'\x21',), 35 | (b'\x36\x08',), 36 | (b'\x3a\x05',), 37 | (b'\x2a\x00\x01\x00\x7f',), 38 | (b'\x2b\x00\x01\x00\x9f',), 39 | (b'\xe0\x02\x1c\x07\x12\x37\x32\x29\x2d\x29\x25\x2b\x39\x00\x01\x03\x10',), 40 | (b'\xe1\x03\x1d\x07\x06\x2e\x2c\x29\x2d\x2e\x2e\x37\x3f\x00\x00\x02\x10',), 41 | (b'\x13', 10), 42 | (b'\x29', 100), 43 | ] 44 | 45 | custom_rotations = [ 46 | (0x08, 80, 160, 26, 1), 47 | (0x68, 160, 80, 1, 26), 48 | (0xc8, 80, 160, 26, 1), 49 | (0xa8, 160, 80, 1, 26) 50 | ] 51 | 52 | return st7789.ST7789( 53 | SPI(2, baudrate=60000000, sck=Pin(5), mosi=Pin(3), miso=None), 54 | 80, 55 | 160, 56 | reset=Pin(1, Pin.OUT), 57 | cs=Pin(4, Pin.OUT), 58 | dc=Pin(2, Pin.OUT), 59 | custom_init=custom_init, 60 | rotations=custom_rotations, 61 | color_order=st7789.BGR, 62 | rotation=rotation, 63 | options=options, 64 | buffer_size=buffer_size) 65 | -------------------------------------------------------------------------------- /examples/configs/tdisplay_esp32/tft_buttons.py: -------------------------------------------------------------------------------- 1 | # input pins for esp32 T-Display module 2 | 3 | from machine import Pin 4 | 5 | class Buttons(): 6 | def __init__(self): 7 | self.name = "tdisplay_esp32" 8 | self.left = Pin(0, Pin.IN) 9 | self.right = Pin(35, Pin.IN) 10 | -------------------------------------------------------------------------------- /examples/configs/tdisplay_esp32/tft_config.py: -------------------------------------------------------------------------------- 1 | """ LilyGo T-DISPLAY 135x240 ST7789 display 2 | 3 | NOTE: Reduce the SPI baudrate below 26.7MHz unless you are using my compiled firmware or you modify 4 | the spi_device_interface_config_t devcfg.flags setting in the micropython/ports/esp machine_hw_spi.c 5 | file to include the SPI_DEVICE_NO_DUMMY flag. 6 | 7 | for example change line 262 in micropython/ports/esp32/machine_hw_spi.c from this: 8 | 9 | .flags = self->firstbit == MICROPY_PY_MACHINE_SPI_LSB ? SPI_DEVICE_TXBIT_LSBFIRST | SPI_DEVICE_RXBIT_LSBFIRST : 0, 10 | 11 | to this: 12 | 13 | .flags = self->firstbit == MICROPY_PY_MACHINE_SPI_LSB ? SPI_DEVICE_TXBIT_LSBFIRST | SPI_DEVICE_RXBIT_LSBFIRST : 0 | SPI_DEVICE_NO_DUMMY, 14 | 15 | Recompile and flash the firmware and you can use the 40MHz speed. 16 | 17 | """ 18 | from machine import Pin, SPI 19 | import st7789 20 | 21 | TFA = 40 22 | BFA = 40 23 | 24 | def config(rotation=0, buffer_size=0, options=0): 25 | return st7789.ST7789( 26 | SPI(2, baudrate=40000000, sck=Pin(18), mosi=Pin(19), miso=None), 27 | 135, 28 | 240, 29 | reset=Pin(23, Pin.OUT), 30 | cs=Pin(5, Pin.OUT), 31 | dc=Pin(16, Pin.OUT), 32 | backlight=Pin(4, Pin.OUT), 33 | rotation=rotation, 34 | options=options, 35 | buffer_size= buffer_size) 36 | -------------------------------------------------------------------------------- /examples/configs/tdisplay_rp2040/tft_buttons.py: -------------------------------------------------------------------------------- 1 | 2 | # input pins for tdisplay_rp2040 3 | 4 | from machine import Pin 5 | 6 | class Buttons(): 7 | def __init__(self): 8 | self.name = "tdisplay_rp2040" 9 | self.left = Pin(6,Pin.IN,Pin.PULL_UP) # joystick left 10 | self.right = Pin(7,Pin.IN,Pin.PULL_UP) # joystick right 11 | -------------------------------------------------------------------------------- /examples/configs/tdisplay_rp2040/tft_config.py: -------------------------------------------------------------------------------- 1 | """TTGO T-Display RP2040 display""" 2 | 3 | from machine import Pin, SPI 4 | from time import sleep 5 | import st7789 6 | 7 | TFA = 40 # top free area when scrolling 8 | BFA = 40 # bottom free area when scrolling 9 | 10 | def config(rotation=0, buffer_size=0, options=0): 11 | 12 | Pin(22, Pin.OUT, value=1) 13 | 14 | spi = SPI(0, 15 | baudrate=62500000, 16 | polarity=0, 17 | phase=0, 18 | sck=Pin(2, Pin.OUT), 19 | mosi=Pin(3, Pin.OUT), 20 | miso=None) 21 | 22 | return st7789.ST7789( 23 | spi, 24 | 135, 25 | 240, 26 | cs=Pin(5, Pin.OUT), 27 | dc=Pin(1, Pin.OUT), 28 | reset=Pin(6, Pin.OUT), 29 | backlight=Pin(4, Pin.OUT), 30 | rotation=rotation, 31 | options=options, 32 | buffer_size=buffer_size) 33 | -------------------------------------------------------------------------------- /examples/configs/twatch_2020_v2/tft_config.py: -------------------------------------------------------------------------------- 1 | """TTGO TWATCH-2020 V2 with ST7789 240x240 display""" 2 | 3 | from machine import Pin, SPI 4 | import axp202c 5 | import st7789 6 | 7 | TFA = 0 8 | BFA = 80 9 | 10 | def config(rotation=0, buffer_size=0, options=0): 11 | axp = axp202c.PMU() 12 | axp.enablePower(axp202c.AXP202_LDO2) 13 | return st7789.ST7789( 14 | SPI(1, baudrate=32000000, sck=Pin(18, Pin.OUT), mosi=Pin(19, Pin.OUT)), 15 | 240, 16 | 240, 17 | cs=Pin(5, Pin.OUT), 18 | dc=Pin(27, Pin.OUT), 19 | backlight=Pin(12, Pin.OUT), 20 | rotation=rotation, 21 | options=options, 22 | buffer_size=buffer_size) 23 | -------------------------------------------------------------------------------- /examples/configs/wio_terminal/tft_buttons.py: -------------------------------------------------------------------------------- 1 | 2 | # input pins for ws_pico_13 3 | 4 | from machine import Pin 5 | 6 | 7 | class Buttons(): 8 | def __init__(self): 9 | self.name = "wio_terminal" 10 | self.up = Pin("SWITCH_U", Pin.IN) # joystick up 11 | self.down = Pin("SWITCH_X", Pin.IN) # joystick down 12 | self.left = Pin("SWITCH_B", Pin.IN) # joystick left 13 | self.right = Pin("SWITCH_Y", Pin.IN) # joystick right 14 | self.center = Pin("SWITCH_Z", Pin.IN) # joystick center 15 | 16 | self.button1 = Pin("BUTTON_1", Pin.IN) # button A 17 | self.button2 = Pin("BUTTON_2", Pin.IN) # button B 18 | self.button3 = Pin("BUTTON_3", Pin.IN) # button X 19 | 20 | # for roids.py 21 | self.thrust = self.center 22 | self.hyper = self.button1 23 | self.fire = self.button3 24 | -------------------------------------------------------------------------------- /examples/configs/wio_terminal/tft_config.py: -------------------------------------------------------------------------------- 1 | """Wio Terminal ili9341 320x240 display""" 2 | 3 | from machine import Pin, SPI 4 | import st7789 5 | 6 | TFA = 0 7 | BFA = 0 8 | 9 | 10 | def config(rotation=0, buffer_size=0, options=0): 11 | """Configure the Wio Terminal display using a custom_init and 12 | custom_rotations since the display is ili9341. The custom_init is a 13 | list of commands to send to the display during the init() metehod. The 14 | list contains tuples with a bytes object, optionally followed by a 15 | delay specified in ms. The first byte of the bytes object contains the 16 | command to send optionally followed by data bytes. 17 | """ 18 | 19 | custom_init = [ 20 | (b'\x01', 150), # soft reset 21 | (b'\x11', 255), # exit sleep 22 | (b'\xCB\x39\x2C\x00\x34\x02',), # power control A 23 | (b'\xCF\x00\xC1\x30',), # power control B 24 | (b'\xE8\x85\x00\x78',), # driver timing control A 25 | (b'\xEA\x00\x00',), # driver timing control B 26 | (b'\xED\x64\x03\x12\x81',), # power on sequence control 27 | (b'\xF7\x20',), # pump ratio control 28 | (b'\xC0\x23',), # power control,VRH[5:0] 29 | (b'\xC1\x10',), # Power control,SAP[2:0];BT[3:0] 30 | (b'\xC5\x3E\x28',), # vcm control 31 | (b'\xC7\x86',), # vcm control 2 32 | (b'\x3A\x55',), # pixel format 33 | (b'\xB1\x00\x18',), # frameration control,normal mode full colours 34 | (b'\xB6\x08\x82\x27',), # display function control 35 | (b'\xF2\x00',), # 3gamma function disable 36 | (b'\x26\x01',), # gamma curve selected 37 | # set positive gamma correction 38 | (b'\xE0\x0F\x31\x2B\x0C\x0E\x08\x4E\xF1\x37\x07\x10\x03\x0E\x09\x00',), 39 | # set negative gamma correction 40 | (b'\xE1\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F',), 41 | (b'\x29', 100), # display on 42 | ] 43 | 44 | custom_rotations = [ 45 | (0x48, 240, 320, 0, 0), 46 | (0x28, 320, 240, 0, 0), 47 | (0x88, 240, 320, 0, 0), 48 | (0xe8, 320, 240, 0, 0), 49 | ] 50 | return st7789.ST7789( 51 | SPI(7, baudrate=24000000, sck=Pin("LCD_SCK"), mosi=Pin("LCD_MOSI")), 52 | 240, 53 | 320, 54 | reset=Pin("LCD_RESET", Pin.OUT), 55 | cs=Pin("LCD_CS", Pin.OUT), 56 | dc=Pin("LCD_D_C", Pin.OUT), 57 | backlight=Pin("LED_LCD", Pin.OUT), 58 | custom_init=custom_init, 59 | rotations=custom_rotations, 60 | rotation=rotation, 61 | color_order=st7789.RGB, 62 | inversion=False, 63 | options=options, 64 | buffer_size=buffer_size) 65 | -------------------------------------------------------------------------------- /examples/configs/ws_pico_114/tft_buttons.py: -------------------------------------------------------------------------------- 1 | # input pins for ws_pico_114 v1 with four buttons 2 | 3 | from machine import Pin 4 | 5 | class Buttons(): 6 | def __init__(self): 7 | self.name = "ws_pico_114" 8 | self.key0 = Pin(15,Pin.IN,Pin.PULL_UP) # KEY 0 9 | self.key1 = Pin(17 ,Pin.IN,Pin.PULL_UP) # KEY 1 10 | self.key2 = Pin(2,Pin.IN,Pin.PULL_UP) # KEY 2 11 | self.key3 = Pin(3,Pin.IN,Pin.PULL_UP) # KEY 3 12 | 13 | # for roids.py 14 | self.left = self.key2 # KEY 2 15 | self.right = self.key0 # KEY 0 16 | self.thrust = self.key3 # KEY 3 17 | self.hyper = None # None 18 | self.fire = self.key1 # KEY 1 19 | -------------------------------------------------------------------------------- /examples/configs/ws_pico_114/tft_config.py: -------------------------------------------------------------------------------- 1 | """Waveshare Pico LCD 1.14 inch display""" 2 | 3 | from machine import Pin, SPI 4 | import st7789 5 | 6 | TFA = 40 # top free area when scrolling 7 | BFA = 40 # bottom free area when scrolling 8 | 9 | def config(rotation=0, buffer_size=0, options=0): 10 | return st7789.ST7789( 11 | SPI(1, baudrate=62500000, sck=Pin(10), mosi=Pin(11)), 12 | 135, 13 | 240, 14 | reset=Pin(12, Pin.OUT), 15 | cs=Pin(9, Pin.OUT), 16 | dc=Pin(8, Pin.OUT), 17 | backlight=Pin(13, Pin.OUT), 18 | rotation=rotation, 19 | options=options, 20 | buffer_size=buffer_size) 21 | -------------------------------------------------------------------------------- /examples/configs/ws_pico_114/tft_joystick.py: -------------------------------------------------------------------------------- 1 | # input pins for ws_pico_114 v2 witjh Joystick 2 | 3 | from machine import Pin 4 | 5 | class Buttons(): 6 | def __init__(self): 7 | self.left = Pin(16,Pin.IN,Pin.PULL_UP) # joystick left 8 | self.right = Pin(20,Pin.IN,Pin.PULL_UP) # joystick right 9 | self.thrust = Pin(3,Pin.IN,Pin.PULL_UP) # joystick center 10 | self.hyper = Pin(15,Pin.IN,Pin.PULL_UP) # button A 11 | self.fire = Pin(17 ,Pin.IN,Pin.PULL_UP) # button B 12 | -------------------------------------------------------------------------------- /examples/configs/ws_pico_13/tft_buttons.py: -------------------------------------------------------------------------------- 1 | 2 | # input pins for ws_pico_13 3 | 4 | from machine import Pin 5 | 6 | class Buttons(): 7 | def __init__(self): 8 | self.name = "ws_pico_13" 9 | self.up = Pin(2,Pin.IN,Pin.PULL_UP) # joystick up 10 | self.down = Pin(18,Pin.IN,Pin.PULL_UP) # joystick down 11 | self.left = Pin(16,Pin.IN,Pin.PULL_UP) # joystick left 12 | self.right = Pin(20,Pin.IN,Pin.PULL_UP) # joystick right 13 | self.center = Pin(3,Pin.IN,Pin.PULL_UP) # joystick center 14 | 15 | self.a = Pin(15,Pin.IN,Pin.PULL_UP) # button A 16 | self.b = Pin(17,Pin.IN,Pin.PULL_UP) # button B 17 | self.x = Pin(19,Pin.IN,Pin.PULL_UP) # button X 18 | self.y = Pin(21,Pin.IN,Pin.PULL_UP) # button Y 19 | 20 | # for roids.py 21 | 22 | self.thrust = self.center # joystick center 23 | self.hyper = self.a # button A 24 | self.fire = self.y # button Y 25 | -------------------------------------------------------------------------------- /examples/configs/ws_pico_13/tft_config.py: -------------------------------------------------------------------------------- 1 | """Waveshare Pico LCD 1.3 inch display""" 2 | 3 | from machine import Pin, SPI 4 | import st7789 5 | 6 | TFA = 0 # top free area when scrolling 7 | BFA = 80 # bottom free area when scrolling 8 | 9 | def config(rotation=0, buffer_size=0, options=0): 10 | return st7789.ST7789( 11 | SPI(1, baudrate=62500000, sck=Pin(10), mosi=Pin(11)), 12 | 240, 13 | 240, 14 | reset=Pin(12, Pin.OUT), 15 | cs=Pin(9, Pin.OUT), 16 | dc=Pin(8, Pin.OUT), 17 | backlight=Pin(13, Pin.OUT), 18 | rotation=rotation, 19 | options=options, 20 | buffer_size=buffer_size) 21 | -------------------------------------------------------------------------------- /examples/configs/ws_pico_2/tft_buttons.py: -------------------------------------------------------------------------------- 1 | # input pins for ws_pico_2 2 | 3 | from machine import Pin 4 | 5 | class Buttons(): 6 | def __init__(self): 7 | self.name = "ws_pico_2" 8 | self.key0 = Pin(15, Pin.IN, Pin.PULL_UP) # Top Right 9 | self.key1 = Pin(17, Pin.IN, Pin.PULL_UP) # Bottom Right 10 | self.key2 = Pin(2, Pin.IN, Pin.PULL_UP) # Bottom Left 11 | self.key3 = Pin(3, Pin.IN, Pin.PULL_UP) # Top Left 12 | 13 | # for roids.py in landscape mode 14 | 15 | self.left = self.key2 16 | self.right = self.key3 17 | self.fire = self.key1 18 | self.thrust = self.key0 19 | self.hyper = None 20 | -------------------------------------------------------------------------------- /examples/configs/ws_pico_2/tft_config.py: -------------------------------------------------------------------------------- 1 | """Waveshare Pico LCD 2 inch display""" 2 | 3 | from machine import Pin, SPI 4 | import st7789 5 | 6 | TFA = 0 # top free area when scrolling 7 | BFA = 0 # bottom free area when scrolling 8 | 9 | def config(rotation=0, buffer_size=0, options=0): 10 | return st7789.ST7789( 11 | SPI(1, baudrate=62500000, sck=Pin(10), mosi=Pin(11)), 12 | 240, 13 | 320, 14 | reset=Pin(12, Pin.OUT), 15 | cs=Pin(9, Pin.OUT), 16 | dc=Pin(8, Pin.OUT), 17 | backlight=Pin(13, Pin.OUT), 18 | rotation=rotation, 19 | options=options, 20 | buffer_size=buffer_size) 21 | -------------------------------------------------------------------------------- /examples/feathers.py: -------------------------------------------------------------------------------- 1 | """ 2 | feathers.py 3 | Smoothly scroll rainbow-colored mirrored random curves across the display. 4 | """ 5 | 6 | import random 7 | import math 8 | import utime 9 | import st7789 10 | import tft_config 11 | 12 | def between(left, right, along): 13 | """returns a point along the curve from left to right""" 14 | dist = (1 - math.cos(along * math.pi)) / 2 15 | return left * (1 - dist) + right * dist 16 | 17 | 18 | def color_wheel(position): 19 | """returns a 565 color from the given position of the color wheel""" 20 | position = (255 - position) % 255 21 | 22 | if position < 85: 23 | return st7789.color565(255 - position * 3, 0, position * 3) 24 | 25 | if position < 170: 26 | position -= 85 27 | return st7789.color565(0, position * 3, 255 - position * 3) 28 | 29 | position -= 170 30 | return st7789.color565(position * 3, 255 - position * 3, 0) 31 | 32 | 33 | def main(): 34 | ''' 35 | The big show! 36 | ''' 37 | 38 | tft = tft_config.config(1) # configure driver to rotate screen 90 degrees 39 | tft.init() # initialize display 40 | 41 | height = tft.height() # height of display in pixels 42 | width = tft.width() # width if display in pixels 43 | 44 | tfa = tft_config.TFA # top free area when scrolling 45 | bfa = tft_config.BFA # bottom free area when scrolling 46 | 47 | scroll = 0 # scroll position 48 | wheel = 0 # color wheel position 49 | 50 | tft.vscrdef(tfa, width, bfa) # set scroll area 51 | tft.vscsad(scroll + tfa) # set scroll position 52 | tft.fill(st7789.BLACK) # clear screen 53 | 54 | half = (height >> 1) - 1 # half the height of the display 55 | interval = 0 # steps between new points 56 | increment = 0 # increment per step 57 | counter = 1 # step counter, overflow to start 58 | current_y = 0 # current_y value (right point) 59 | last_y = 0 # last_y value (left point) 60 | 61 | # segment offsets 62 | x_offsets = [x * (width // 8) -1 for x in range(2,9)] 63 | 64 | while True: 65 | # when the counter exceeds the interval, save current_y to last_y, 66 | # choose a new random value for current_y between 0 and 1/2 the 67 | # height of the display, choose a new random interval then reset 68 | # the counter to 0 69 | 70 | if counter > interval: 71 | last_y = current_y 72 | current_y = random.randint(0, half) 73 | counter = 0 74 | interval = random.randint(10, 100) 75 | increment = 1 / interval 76 | 77 | # clear the first column of the display and scroll it 78 | tft.vline(scroll, 0, height, st7789.BLACK) 79 | tft.vscsad(scroll + tfa) 80 | 81 | # get the next point between last_y and current_y 82 | tween = int(between(last_y, current_y, counter * increment)) 83 | 84 | # draw mirrored pixels across the display at the offsets using the color_wheel effect 85 | for i, x_offset in enumerate(x_offsets): 86 | tft.pixel((scroll + x_offset) % width, half + tween, color_wheel(wheel+(i<<2))) 87 | tft.pixel((scroll + x_offset) % width, half - tween, color_wheel(wheel+(i<<2))) 88 | 89 | # increment scroll, counter, and wheel 90 | scroll = (scroll + 1) % width 91 | wheel = (wheel + 1) % 256 92 | counter += 1 93 | 94 | # pause to slow down scrolling 95 | utime.sleep(0.005) 96 | 97 | 98 | main() 99 | -------------------------------------------------------------------------------- /examples/font_decode.py: -------------------------------------------------------------------------------- 1 | """Example showing how to decode glyph bitmaps from a font module""" 2 | 3 | import proverbs_font as font 4 | 5 | text = "师父领进门,修行在个人" 6 | 7 | def get_bitmap_offset(index): 8 | """ Return the bitmap bit offset for the glyph at `index`""" 9 | offset_first = index * font.OFFSET_WIDTH 10 | offset = 0 11 | for offset_byte in range(font.OFFSET_WIDTH): 12 | offset = (offset << 8) + font.OFFSETS[offset_first + offset_byte] 13 | return offset 14 | 15 | def get_pixel_color(bit): 16 | """Return the color of the pixel starting at `bit` comprised of `font.BPP` bits""" 17 | pixel_color = 0 18 | for _ in range(font.BPP): 19 | pixel_color = (pixel_color << 1) | font.BITMAPS[bit // 8] & 1 << (7 - (bit % 8)) 20 | bit += 1 21 | 22 | return pixel_color 23 | 24 | # Draw the string `text` one glyph at a time 25 | for glyph in text: 26 | print({glyph}) 27 | glyph_index = font.MAP.index(glyph) 28 | glyph_width = font.WIDTHS[glyph_index] 29 | glyph_bitmap_data = get_bitmap_offset(glyph_index) 30 | for _ in range(font.HEIGHT): 31 | for _ in range(glyph_width): 32 | color = get_pixel_color(glyph_bitmap_data) 33 | print('#' if color else ' ', end='') 34 | glyph_bitmap_data += font.BPP 35 | print() 36 | print("\n") 37 | -------------------------------------------------------------------------------- /examples/hello.py: -------------------------------------------------------------------------------- 1 | """ 2 | hello.py 3 | 4 | Writes "Hello!" in random colors at random locations on the display. 5 | """ 6 | 7 | import random 8 | import utime 9 | import st7789 10 | import tft_config 11 | import vga2_bold_16x32 as font 12 | 13 | tft = tft_config.config(1) 14 | 15 | def center(text): 16 | length = 1 if isinstance(text, int) else len(text) 17 | tft.text( 18 | font, 19 | text, 20 | tft.width() // 2 - length // 2 * font.WIDTH, 21 | tft.height() // 2 - font.HEIGHT //2, 22 | st7789.WHITE, 23 | st7789.RED) 24 | 25 | def main(): 26 | tft.init() 27 | tft.fill(st7789.RED) 28 | center(b'\xAEHello\xAF') 29 | utime.sleep(2) 30 | tft.fill(st7789.BLACK) 31 | 32 | while True: 33 | for rotation in range(4): 34 | tft.rotation(rotation) 35 | tft.fill(0) 36 | col_max = tft.width() - font.WIDTH*6 37 | row_max = tft.height() - font.HEIGHT 38 | 39 | for _ in range(128): 40 | tft.text( 41 | font, 42 | b'Hello!', 43 | random.randint(0, col_max), 44 | random.randint(0, row_max), 45 | st7789.color565( 46 | random.getrandbits(8), 47 | random.getrandbits(8), 48 | random.getrandbits(8)), 49 | st7789.color565( 50 | random.getrandbits(8), 51 | random.getrandbits(8), 52 | random.getrandbits(8))) 53 | 54 | 55 | main() 56 | -------------------------------------------------------------------------------- /examples/hershey.py: -------------------------------------------------------------------------------- 1 | """ 2 | hershey.py 3 | 4 | Demo program that draws greetings on display cycling thru hershey fonts and colors. 5 | 6 | """ 7 | 8 | import random 9 | import utime 10 | import st7789 11 | import tft_config 12 | 13 | tft = tft_config.config(0, options=st7789.WRAP_V) 14 | 15 | # Load several frozen fonts from flash 16 | 17 | import greeks 18 | import italicc 19 | import italiccs 20 | import meteo 21 | import romanc 22 | import romancs 23 | import romand 24 | import romanp 25 | import romans 26 | import scriptc 27 | import scripts 28 | 29 | 30 | def cycle(p): 31 | """return the next item in a list""" 32 | try: 33 | len(p) 34 | except TypeError: 35 | cache = [] 36 | for i in p: 37 | yield i 38 | cache.append(i) 39 | 40 | p = cache 41 | while p: 42 | yield from p 43 | 44 | 45 | # Create a cycle of colors 46 | COLORS = cycle([0xe000, 0xece0, 0xe7e0, 0x5e0, 0x00d3, 0x7030]) 47 | 48 | # List Hershey fonts 49 | FONT = [greeks, italicc, italiccs, meteo, romanc, romancs, romand, romanp, romans, scriptc, scripts] 50 | 51 | # Create a cycle of tuples consisting of a FONT[] and the HEIGHT of the next FONT[] in the cycle 52 | FONTS = cycle([ 53 | (font, FONT[(i + 1) % len(FONT)].HEIGHT) 54 | for i, font in enumerate(FONT)]) 55 | 56 | # Greetings 57 | GREETING = [ 58 | "Ahoy", "Bonjour", "Bonsoir", "Buenos Dias", "Buenas tardes", "Buenas Noches", "Ciao", "Dude", 59 | "Good Morning", "Good Day", "Good Evening", "Hello", "Hey", "Hi", "Hiya", "Hola", "How Are You", 60 | "How Goes It", "Howdy", "How you doing", "Konnichiwa","Salut", "Shalom", "Welcome", "What's Up", 61 | 'Yo!'] 62 | 63 | # Create a cycle of tuples consisting of a list of words from a GREETING, the number of spaces+1 64 | # in the that GREETING, and the number of spaces+1 in the next GREETING of the cycle 65 | GREETINGS = cycle([ 66 | (greeting.split(), greeting.count(' ')+1, GREETING[(i + 1) % len(GREETING)].count(' ')+1) 67 | for i, greeting in enumerate(GREETING)]) 68 | 69 | 70 | def main(): 71 | """Scroll greetings on the display cycling thru Hershey fonts and colors""" 72 | 73 | tft.init() 74 | tft.fill(st7789.BLACK) 75 | 76 | height = tft.height() 77 | width = tft.width() 78 | 79 | # Set up scrolling area 80 | tfa = tft_config.TFA 81 | bfa = tft_config.BFA 82 | tft.vscrdef(tfa, height, bfa) 83 | 84 | scroll = 0 85 | to_scroll = 0 86 | 87 | while True: 88 | 89 | # if we have scrolled high enough for the next greeting 90 | if to_scroll == 0: 91 | font = next(FONTS) # get the next font 92 | greeting = next(GREETINGS) # get the next greeting 93 | color = next(COLORS) # get the next color 94 | lines = greeting[2] # number of lines in the greeting 95 | to_scroll = lines * font[1] + 8 # number of rows to scroll 96 | 97 | # draw each line of the greeting 98 | for i, word in enumerate(greeting[0][::-1]): 99 | word_len = tft.draw_len(font[0], word) # width in pixels 100 | col = 0 if word_len > width else (width//2 - word_len//2) # column to center 101 | row = (scroll + height - ((i + 1) * font[0].HEIGHT) % height) # row to draw 102 | tft.draw(font[0], word, col, row, color) # draw the word 103 | 104 | tft.fill_rect(0, scroll, width, 1, st7789.BLACK) # clear the top line 105 | tft.vscsad(scroll+tfa) # scroll the display 106 | scroll = (scroll+1) % height # update the scroll position 107 | to_scroll -= 1 # update rows left to scroll 108 | utime.sleep(0.02) # stop and smell the roses 109 | 110 | 111 | main() 112 | -------------------------------------------------------------------------------- /examples/hershey_to_poly.py: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2020 Russ Hughes 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | from ttfquery import describe 24 | from ttfquery import glyphquery 25 | import ttfquery.glyph as glyph 26 | char = "a" 27 | font_url ="arial.ttf" 28 | font = describe.openFont(font_url) 29 | g = glyph.Glyph(char) 30 | 31 | 32 | def text(font, message, row=32, column=0): 33 | ''' 34 | Write `text` on `display` starting on `row` stating in `column` using 35 | `font` in `color` 36 | 37 | Args: 38 | font: The pyfont module to use 39 | message: The message to write 40 | row: Row to start at, defaults to 32 41 | column: Column to start at, defaults to 0 42 | color: The color to write in 43 | ''' 44 | 45 | polygon = [] 46 | 47 | from_x = to_x = pos_x = column 48 | from_y = to_y = pos_y = row 49 | 50 | for char in [ord(char) for char in message]: 51 | penup = True 52 | if 32 <= char <= 127: 53 | data = bytearray(font.get_ch(char)) 54 | length = data[0] 55 | left = data[1] - 0x52 56 | right = data[2] - 0x52 57 | width = right - left 58 | 59 | for vect in range (3, len(data), 2): 60 | vector_x = data[vect] - 0x52 61 | vector_y = data[vect+1] - 0x52 62 | 63 | if vector_x == -50: 64 | penup = True 65 | continue 66 | 67 | if not vect or penup: 68 | from_x = pos_x + vector_x - left 69 | from_y = pos_y + vector_y 70 | else: 71 | to_x = pos_x + vector_x - left 72 | to_y = pos_y + vector_y 73 | 74 | polygon.append((from_x, from_y), (to_x, to_y)) 75 | 76 | from_x = to_x 77 | from_y = to_y 78 | penup = False 79 | 80 | pos_x += width 81 | 82 | return polygon -------------------------------------------------------------------------------- /examples/hola.py: -------------------------------------------------------------------------------- 1 | """ 2 | hello.py 3 | 4 | Writes "Hello!" in random colors at random locations on the display. 5 | """ 6 | 7 | import random 8 | import utime 9 | import st7789 10 | import tft_config 11 | import vga2_bold_16x32 as font 12 | 13 | tft = tft_config.config(1) 14 | 15 | def center(text): 16 | length = 1 if isinstance(text, int) else len(text) 17 | tft.text( 18 | font, 19 | text, 20 | tft.width() // 2 - length // 2 * font.WIDTH, 21 | tft.height() // 2 - font.HEIGHT //2, 22 | st7789.WHITE, 23 | st7789.RED) 24 | 25 | def main(): 26 | tft.init() 27 | tft.fill(st7789.RED) 28 | center(b'\xADHola!') 29 | utime.sleep(2) 30 | tft.fill(st7789.BLACK) 31 | 32 | while True: 33 | for rotation in range(4): 34 | tft.rotation(rotation) 35 | tft.fill(0) 36 | col_max = tft.width() - font.WIDTH*6 37 | row_max = tft.height() - font.HEIGHT 38 | 39 | for _ in range(128): 40 | tft.text( 41 | font, 42 | b'\xADHola!', 43 | random.randint(0, col_max), 44 | random.randint(0, row_max), 45 | st7789.color565( 46 | random.getrandbits(8), 47 | random.getrandbits(8), 48 | random.getrandbits(8)), 49 | st7789.color565( 50 | random.getrandbits(8), 51 | random.getrandbits(8), 52 | random.getrandbits(8))) 53 | 54 | 55 | main() 56 | -------------------------------------------------------------------------------- /examples/jpg/alien.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/jpg/alien.jpg -------------------------------------------------------------------------------- /examples/jpg/alien.py: -------------------------------------------------------------------------------- 1 | ''' 2 | alien.py 3 | 4 | Randomly draw alien.jpg on the display using various methods. 5 | 6 | The alien.png is from the Erik Flowers Weather Icons available from 7 | https://github.com/erikflowers/weather-icons and is licensed under 8 | SIL OFL 1.1 9 | 10 | ''' 11 | 12 | import gc 13 | import random 14 | import time 15 | import tft_config 16 | import st7789 17 | 18 | gc.enable() 19 | gc.collect() 20 | 21 | 22 | def main(): 23 | ''' 24 | Decode and draw jpg on display using various methods 25 | ''' 26 | 27 | tft = tft_config.config(1) 28 | 29 | # enable display and clear screen 30 | tft.init() 31 | 32 | # read png file into buffer without decoding 33 | with open('alien.jpg', 'rb') as file: 34 | alien = file.read() 35 | 36 | # read and decode png file into a tuple containing (image, width, height) 37 | decoded_bitmap = tft.jpg_decode('alien.jpg') 38 | draw_count = 100 39 | 40 | # display png in random locations 41 | while True: 42 | # decode and draw jpg from a file 43 | start = time.ticks_ms() 44 | for _ in range(draw_count): 45 | tft.rotation(random.randint(0, 4)) 46 | tft.jpg( 47 | 'alien.jpg', 48 | random.randint(0, tft.width() - 63), 49 | random.randint(0, tft.height() - 63), 50 | True) 51 | 52 | print(f"Drawing {draw_count} jpg's from a file took {time.ticks_ms() - start} ms.") 53 | 54 | # decode and draw jpg from a buffer 55 | start = time.ticks_ms() 56 | for _ in range(draw_count): 57 | tft.rotation(random.randint(0, 4)) 58 | tft.jpg( 59 | alien, 60 | random.randint(0, tft.width() - 63), 61 | random.randint(0, tft.height() - 63), 62 | True) 63 | 64 | print(f"Drawing {draw_count} jpg's from a buffer took {time.ticks_ms() - start} ms.") 65 | 66 | # draw decoded bitmap from a tuple created by jpg_decode() 67 | start = time.ticks_ms() 68 | for _ in range(draw_count): 69 | tft.rotation(random.randint(0, 4)) 70 | tft.blit_buffer( 71 | decoded_bitmap[0], 72 | random.randint(0, tft.width() - 63), 73 | random.randint(0, tft.height() - 63), 74 | decoded_bitmap[1], 75 | decoded_bitmap[2]) 76 | 77 | print(f"Drawing {draw_count} jpg's from a decoded buffer took {time.ticks_ms() - start} ms.\n") 78 | 79 | main() 80 | -------------------------------------------------------------------------------- /examples/jpg/bigbuckbunny-128x128.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/jpg/bigbuckbunny-128x128.jpg -------------------------------------------------------------------------------- /examples/jpg/bigbuckbunny-160x128.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/jpg/bigbuckbunny-160x128.jpg -------------------------------------------------------------------------------- /examples/jpg/bigbuckbunny-240x135.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/jpg/bigbuckbunny-240x135.jpg -------------------------------------------------------------------------------- /examples/jpg/bigbuckbunny-240x240.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/jpg/bigbuckbunny-240x240.jpg -------------------------------------------------------------------------------- /examples/jpg/bigbuckbunny-320x240.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/jpg/bigbuckbunny-320x240.jpg -------------------------------------------------------------------------------- /examples/jpg/jpg.py: -------------------------------------------------------------------------------- 1 | """ 2 | jpg.py 3 | 4 | Draw a full screen jpg using the slower but less memory intensive method of blitting 5 | each Minimum Coded Unit (MCU) block. Usually 8×8pixels but can be other multiples of 8. 6 | 7 | bigbuckbunny.jpg (c) copyright 2008, Blender Foundation / www.bigbuckbunny.org 8 | """ 9 | 10 | import random 11 | import st7789 12 | import tft_config 13 | 14 | tft = tft_config.config(1) 15 | 16 | def main(): 17 | ''' 18 | Decode and draw jpg on display 19 | ''' 20 | 21 | tft.init() 22 | tft.jpg(f'bigbuckbunny-{tft.width()}x{tft.height()}.jpg', 0, 0, st7789.SLOW) 23 | 24 | 25 | main() 26 | -------------------------------------------------------------------------------- /examples/mono_fonts/mono_fonts.py: -------------------------------------------------------------------------------- 1 | """ 2 | mono_fonts.py test for monofont2bitmap converter and bitmap method. This is the older method of 3 | converting monofonts to bitmaps. See the newer method in prop_fonts/chango.py that works with 4 | mono and proportional fonts using the write method. 5 | """ 6 | 7 | import time 8 | import st7789 9 | import tft_config 10 | 11 | import inconsolata_16 as font_16 12 | import inconsolata_32 as font_32 13 | import inconsolata_64 as font_64 14 | 15 | tft = tft_config.config(1, buffer_size=66*32*2) 16 | 17 | def display_font(font, fast): 18 | tft.fill(st7789.BLUE) 19 | column = 0 20 | row = 0 21 | for char in font.MAP: 22 | tft.bitmap(font, column, row, font.MAP.index(char)) 23 | column += font.WIDTH 24 | if column >= tft.width() - font.WIDTH: 25 | row += font.HEIGHT 26 | column = 0 27 | 28 | if row > tft.height() - font.HEIGHT: 29 | row = 0 30 | 31 | if not fast: 32 | time.sleep(0.05) 33 | 34 | 35 | def main(): 36 | fast = False 37 | 38 | tft.init() 39 | 40 | while True: 41 | for font in [font_16, font_32, font_64]: 42 | display_font(font, fast) 43 | 44 | fast = not fast 45 | 46 | 47 | main() 48 | -------------------------------------------------------------------------------- /examples/noto_fonts.py: -------------------------------------------------------------------------------- 1 | """ 2 | noto_fonts Writes the names of three Noto fonts centered on the display 3 | using the font. The fonts were converted from True Type fonts using 4 | the font2bitmap utility. 5 | """ 6 | 7 | import st7789 8 | import tft_config 9 | import NotoSans_32 as noto_sans 10 | import NotoSerif_32 as noto_serif 11 | import NotoSansMono_32 as noto_mono 12 | 13 | 14 | tft = tft_config.config(1, buffer_size=16*32*2) 15 | 16 | 17 | def center(font, s, row, color=st7789.WHITE): 18 | screen = tft.width() # get screen width 19 | width = tft.write_len(font, s) # get the width of the string 20 | if width and width < screen: # if the string < display 21 | col = tft.width() // 2 - width // 2 # find the column to center 22 | else: # otherwise 23 | col = 0 # left justify 24 | 25 | tft.write(font, s, col, row, color) # and write the string 26 | 27 | 28 | def main(): 29 | # init display 30 | tft.init() 31 | tft.fill(st7789.BLACK) 32 | 33 | # center the name of the first font, using the font 34 | row = 16 35 | center(noto_sans, "NotoSans", row, st7789.RED) 36 | row += noto_sans.HEIGHT 37 | 38 | # center the name of the second font, using the font 39 | center(noto_serif, "NotoSerif", row, st7789.GREEN) 40 | row += noto_serif.HEIGHT 41 | 42 | # center the name of the third font, using the font 43 | center(noto_mono, "NotoSansMono", row, st7789.BLUE) 44 | row += noto_mono.HEIGHT 45 | 46 | 47 | main() 48 | -------------------------------------------------------------------------------- /examples/paint.py: -------------------------------------------------------------------------------- 1 | """ 2 | paint.py 3 | 4 | A very simple paint program for the TTGO T-Watch-2020 5 | using the adafruit_focaltouch driver modified for micropython by franz 6 | schaefer from https://gitlab.com/mooond/t-watch2020-esp32-with-micropython 7 | See the lib directory for the focaltouch and axp202c drivers. 8 | 9 | https://www.youtube.com/watch?v=O_lDBnvH1Sw 10 | 11 | """ 12 | 13 | from machine import Pin, SPI, SoftI2C 14 | import axp202c 15 | import st7789 16 | import focaltouch 17 | import vga1_8x8 as font 18 | 19 | # color swatches 20 | COLORS = [ 21 | st7789.BLACK, 22 | st7789.BLUE, 23 | st7789.RED, 24 | st7789.GREEN, 25 | st7789.CYAN, 26 | st7789.MAGENTA, 27 | st7789.YELLOW, 28 | st7789.WHITE] 29 | 30 | 31 | def main(): 32 | ''' 33 | Draw on screen using focaltouch sensor 34 | ''' 35 | try: 36 | # Turn on display backlight 37 | axp = axp202c.PMU() 38 | axp.enablePower(axp202c.AXP202_LDO2) 39 | 40 | # initialize display spi port 41 | spi = SPI( 42 | 1, 43 | baudrate=32000000, 44 | polarity=1, 45 | phase=0, 46 | bits=8, 47 | firstbit=0, 48 | sck=Pin(18, Pin.OUT), 49 | mosi=Pin(19, Pin.OUT)) 50 | 51 | # configure display 52 | tft = st7789.ST7789( 53 | spi, 54 | 240, 55 | 240, 56 | cs=Pin(5, Pin.OUT), 57 | dc=Pin(27, Pin.OUT), 58 | backlight=Pin(12, Pin.OUT), 59 | rotation=2) 60 | 61 | # enable display and clear screen 62 | tft.init() 63 | tft.fill(st7789.BLACK) 64 | tft.text(font, "Draw", 104, 1, st7789.WHITE) 65 | 66 | # enable focaltouch touchscreen 67 | touch_i2c = SoftI2C(scl=Pin(32), sda=Pin(23)) 68 | touch = focaltouch.FocalTouch(touch_i2c) 69 | 70 | color_index = 0 71 | color = 0 72 | # draw color swatches used to select color to draw 73 | for color_index, color in enumerate(COLORS): 74 | tft.fill_rect(color_index*30, 210, 30, 30, color) 75 | 76 | add_highlight(tft, color_index) 77 | while True: 78 | # can be up to two touches 79 | if touch.touched == 1: 80 | 81 | # get x and y points of the first touch 82 | p_x = touch.touches[0]['x'] 83 | p_y = touch.touches[0]['y'] 84 | 85 | # If point is in the lowest 30 rows of the screen 86 | # change color to swatch pressed. 87 | if p_y > 209: 88 | # remove highlight from around previous color swatch 89 | remove_highlight(tft, color_index, color) 90 | 91 | # update new color 92 | color_index = p_x//30 93 | color = COLORS[color_index] 94 | 95 | add_highlight(tft, color_index) 96 | else: 97 | # draw the pixel - would be better with lines 98 | tft.pixel(p_x, p_y, color) 99 | 100 | finally: 101 | # shutdown spi 102 | spi.deinit() 103 | 104 | # turn off display backlight 105 | axp.disablePower(axp202c.AXP202_LDO2) 106 | 107 | def remove_highlight(tft, color_index, color): 108 | # remove highlight around previously selected color swatch 109 | tft.rect(color_index*30, 210, 30, 30, color) 110 | tft.rect(color_index*30+1, 211, 28, 28, color) 111 | tft.rect(color_index*30+2, 212, 26, 26, color) 112 | 113 | def add_highlight(tft, color_index): 114 | # draw highlight around newly selected color swatch 115 | tft.rect(color_index*30, 210, 30, 30, st7789.WHITE) 116 | tft.rect(color_index*30+1, 211, 28, 28, st7789.BLACK) 117 | tft.rect(color_index*30+2, 212, 26, 26, st7789.BLACK) 118 | 119 | 120 | main() 121 | -------------------------------------------------------------------------------- /examples/png/alien.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/alien.png -------------------------------------------------------------------------------- /examples/png/alien.py: -------------------------------------------------------------------------------- 1 | ''' 2 | alien.py 3 | 4 | Randomly draw alien.png with alpha-channel masking 5 | 6 | The alien.png is from the Erik Flowers Weather Icons available from 7 | https://github.com/erikflowers/weather-icons and is licensed under 8 | SIL OFL 1.1 9 | 10 | ''' 11 | 12 | import gc 13 | import random 14 | import tft_config 15 | import st7789 16 | 17 | gc.enable() 18 | gc.collect() 19 | 20 | 21 | def main(): 22 | ''' 23 | Decode and draw png on display 24 | ''' 25 | 26 | tft = tft_config.config(1, buffer_size=30*2) 27 | 28 | # enable display and clear screen 29 | tft.init() 30 | 31 | # display png in random locations 32 | while True: 33 | tft.rotation(random.randint(0, 4)) 34 | tft.png( 35 | "alien.png", 36 | random.randint(0, tft.width() - 63), 37 | random.randint(0, tft.height() - 63), 38 | True) 39 | 40 | 41 | main() 42 | -------------------------------------------------------------------------------- /examples/png/bigbuckbunny-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/bigbuckbunny-128x128.png -------------------------------------------------------------------------------- /examples/png/bigbuckbunny-160x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/bigbuckbunny-160x128.png -------------------------------------------------------------------------------- /examples/png/bigbuckbunny-240x135.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/bigbuckbunny-240x135.png -------------------------------------------------------------------------------- /examples/png/bigbuckbunny-240x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/bigbuckbunny-240x240.png -------------------------------------------------------------------------------- /examples/png/bigbuckbunny-240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/bigbuckbunny-240x320.png -------------------------------------------------------------------------------- /examples/png/bigbuckbunny-320x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/bigbuckbunny-320x240.png -------------------------------------------------------------------------------- /examples/png/logo-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-128x128.png -------------------------------------------------------------------------------- /examples/png/logo-160x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-160x128.png -------------------------------------------------------------------------------- /examples/png/logo-160x80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-160x80.png -------------------------------------------------------------------------------- /examples/png/logo-240x135.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-240x135.png -------------------------------------------------------------------------------- /examples/png/logo-240x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-240x240.png -------------------------------------------------------------------------------- /examples/png/logo-240x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-240x320.png -------------------------------------------------------------------------------- /examples/png/logo-320x170.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-320x170.png -------------------------------------------------------------------------------- /examples/png/logo-320x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-320x240.png -------------------------------------------------------------------------------- /examples/png/logo-480x320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-480x320.png -------------------------------------------------------------------------------- /examples/png/logo-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-64x64.png -------------------------------------------------------------------------------- /examples/png/logo-80x160.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/png/logo-80x160.png -------------------------------------------------------------------------------- /examples/png/logo.py: -------------------------------------------------------------------------------- 1 | """ 2 | logo.py 3 | 4 | Draw different sized png MicroPython logos to test the png decoder and clipping. 5 | Copy the png logo files to the same directory as this file. 6 | 7 | The MicroPython logo is copyright George Robotics Ltd. 8 | """ 9 | 10 | import gc 11 | from time import sleep, ticks_ms 12 | import st7789 13 | import tft_config 14 | 15 | LOGOS = ( 16 | (128, 128), 17 | (160, 128), 18 | (160, 80), 19 | (240, 135), 20 | (240, 240), 21 | (240, 320), 22 | (480, 320), 23 | (320, 170), 24 | (320, 240), 25 | (64, 64), 26 | (80, 160), 27 | ) 28 | 29 | gc.collect() 30 | tft = tft_config.config(0, buffer_size=32768) 31 | 32 | def main(): 33 | ''' 34 | Decode and draw png on display 35 | ''' 36 | 37 | tft.init() 38 | 39 | for width, height in LOGOS: 40 | tft.fill(st7789.BLACK) 41 | png_file_name = f'logo-{width}x{height}.png' 42 | start = ticks_ms() 43 | tft.png(png_file_name, 0, 0) 44 | print(f'Displaying {png_file_name} took {ticks_ms() - start}ms') 45 | sleep(2) 46 | 47 | 48 | main() 49 | -------------------------------------------------------------------------------- /examples/png/png.py: -------------------------------------------------------------------------------- 1 | """ 2 | bigbuckbunny.py 3 | 4 | Draw a full screen png 5 | 6 | bigbuckbunny.png (c) copyright 2008, Blender Foundation / www.bigbuckbunny.org 7 | """ 8 | 9 | import st7789 10 | import tft_config 11 | 12 | tft = tft_config.config(0, buffer_size=4096) 13 | 14 | def main(): 15 | ''' 16 | Decode and draw png on display 17 | ''' 18 | 19 | tft.init() 20 | png_file_name = f'bigbuckbunny-{tft.width()}x{tft.height()}.png' 21 | print(f'Displaying {png_file_name}') 22 | tft.png(png_file_name, 0, 0) 23 | 24 | 25 | main() 26 | -------------------------------------------------------------------------------- /examples/png/png_bounce.py: -------------------------------------------------------------------------------- 1 | """ 2 | png_bounce.py 3 | 4 | Bounce a png around the display to test png decoder and visibility clipping. 5 | 6 | """ 7 | 8 | import gc 9 | import random 10 | import time 11 | import tft_config 12 | import st7789 13 | 14 | gc.enable() 15 | gc.collect() 16 | 17 | LOGO_WIDTH = 30 18 | LOGO_HEIGHT = 30 19 | 20 | 21 | def main(): 22 | """ 23 | Bounce a png around the display. 24 | """ 25 | 26 | tft = tft_config.config(0, buffer_size=4096) 27 | 28 | # enable display and clear screen 29 | tft.init() 30 | tft.fill(st7789.BLACK) 31 | 32 | width = tft.width() 33 | height = tft.height() 34 | col = width // 2 - LOGO_WIDTH // 2 35 | row = height // 2 - LOGO_HEIGHT // 2 36 | xd = 3 37 | yd = 2 38 | 39 | ticks = 1000 // 45 40 | 41 | while True: 42 | last = time.ticks_ms() 43 | tft.png("alien.png", col, row) 44 | 45 | # Update the position to bounce the bitmap around the screen 46 | col += xd 47 | if col <= -LOGO_WIDTH - 1 or col > width: 48 | xd = -xd 49 | 50 | row += yd 51 | if row <= -LOGO_HEIGHT - 1 or row > height+1: 52 | yd = -yd 53 | 54 | if time.ticks_ms() - last < ticks: 55 | time.sleep_ms(ticks - (time.ticks_ms() - last)) 56 | 57 | 58 | main() 59 | -------------------------------------------------------------------------------- /examples/proverbs/NotoSansSC-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/proverbs/NotoSansSC-Regular.otf -------------------------------------------------------------------------------- /examples/proverbs/makefont: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ../../../utils/font2bitmap.py \ 4 | -s "万事起头难。熟能生巧。冰冻三尺,非一日之寒。三个臭皮匠,胜过诸葛亮。今日事,今日毕。师父领进门,修行在个人。一口吃不成胖子。欲速则不达。百闻不如一见。不入虎穴,焉得虎子。" \ 5 | NotoSansSC-Regular.otf 30 >proverbs_font.py 6 | -------------------------------------------------------------------------------- /examples/proverbs/proverbs.py: -------------------------------------------------------------------------------- 1 | """ 2 | proverbs.py - Displays what I hope are chinese proverbs in simplified chinese to test UTF-8 3 | font support. 4 | """ 5 | 6 | import utime 7 | import st7789 8 | import tft_config 9 | import proverbs_font as font 10 | 11 | 12 | tft = tft_config.config(1) 13 | 14 | 15 | def color_wheel(WheelPos): 16 | """returns a 565 color from the given position of the color wheel""" 17 | WheelPos = (255 - WheelPos) % 255 18 | 19 | if WheelPos < 85: 20 | return st7789.color565(255 - WheelPos * 3, 0, WheelPos * 3) 21 | 22 | if WheelPos < 170: 23 | WheelPos -= 85 24 | return st7789.color565(0, WheelPos * 3, 255 - WheelPos * 3) 25 | 26 | WheelPos -= 170 27 | return st7789.color565(WheelPos * 3, 255 - WheelPos * 3, 0) 28 | 29 | def main(): 30 | 31 | proverbs = [ 32 | "万事起头难", 33 | "熟能生巧", 34 | "冰冻三尺,非一日之寒", 35 | "三个臭皮匠,胜过诸葛亮", 36 | "今日事,今日毕", 37 | "师父领进门,修行在个人", 38 | "一口吃不成胖子", 39 | "欲速则不达", 40 | "百闻不如一见", 41 | "不入虎穴,焉得虎子"] 42 | 43 | # initialize display 44 | tft.init() 45 | line_height = font.HEIGHT+8 46 | half_height = tft.height() // 2 47 | half_width = tft.width() // 2 48 | wheel = 0 49 | 50 | tft.fill(st7789.BLACK) 51 | 52 | while True: 53 | for proverb in proverbs: 54 | proverb_lines = proverb.split(',') 55 | half_lines_height = len(proverb_lines) * line_height // 2 56 | 57 | tft.fill(st7789.BLACK) 58 | 59 | for count, proverb_line in enumerate(proverb_lines): 60 | half_length = tft.write_len(font, proverb_line) // 2 61 | 62 | tft.write( 63 | font, 64 | proverb_line, 65 | half_width - half_length, 66 | half_height - half_lines_height + count * line_height, 67 | color_wheel(wheel)) 68 | 69 | wheel = (wheel + 5) % 256 70 | 71 | # pause to slow down scrolling 72 | utime.sleep(5) 73 | 74 | 75 | main() 76 | -------------------------------------------------------------------------------- /examples/scroll.py: -------------------------------------------------------------------------------- 1 | """ 2 | scroll.py 3 | 4 | Smoothly scroll all characters of a font up the display. 5 | Fonts heights must be even multiples of the screen height 6 | (i.e. 8 or 16 pixels high). 7 | """ 8 | 9 | import utime 10 | import st7789 11 | import tft_config 12 | import vga1_bold_16x16 as font 13 | 14 | 15 | tft = tft_config.config(0) 16 | 17 | 18 | def cycle(p): 19 | try: 20 | len(p) 21 | except TypeError: 22 | cache = [] 23 | for i in p: 24 | yield i 25 | cache.append(i) 26 | p = cache 27 | while p: 28 | yield from p 29 | 30 | 31 | def main(): 32 | 33 | tft.init() 34 | 35 | colors = cycle([0xe000, 0xece0, 0xe7e0, 0x5e0, 0x00d3, 0x7030]) 36 | foreground = next(colors) 37 | background = st7789.BLACK 38 | 39 | tft.fill(background) 40 | utime.sleep(1) 41 | 42 | height = tft.height() 43 | width = tft.width() 44 | last_line = height - font.HEIGHT 45 | 46 | tfa = tft_config.TFA # top free area 47 | bfa = tft_config.BFA # bottom free area 48 | 49 | tft.vscrdef(tfa, height, bfa) 50 | 51 | scroll = 0 52 | character = font.FIRST 53 | 54 | while True: 55 | # clear top line before scrolling off display 56 | tft.fill_rect(0, scroll, width, 1, background) 57 | 58 | # Write new line when we have scrolled the height of a character 59 | if scroll % font.HEIGHT == 0: 60 | line = (scroll + last_line) % height 61 | 62 | # write character hex value as a string 63 | tft.text( 64 | font, 65 | 'x{:02x}'.format(character), 66 | 16, 67 | line, 68 | foreground, 69 | background) 70 | 71 | # write character using a integer (could be > 0x7f) 72 | tft.text( 73 | font, 74 | character, 75 | 90, 76 | line, 77 | foreground, 78 | background) 79 | 80 | # change color for next line 81 | foreground = next(colors) 82 | 83 | # next character with rollover at 256 84 | character += 1 85 | if character > font.LAST: 86 | character = font.FIRST 87 | 88 | # scroll the screen up 1 row 89 | tft.vscsad(scroll+tfa) 90 | scroll += 1 91 | scroll %= height 92 | 93 | utime.sleep(0.01) 94 | 95 | 96 | main() 97 | -------------------------------------------------------------------------------- /examples/tbbunny.py: -------------------------------------------------------------------------------- 1 | """ 2 | tbbunny.py 3 | 4 | Reads, decodes and displays movie frames from individual JPG's stored on 5 | a SD Card. See https://github.com/russhughes/TinyBigBuckBunny for JPG's. 6 | """ 7 | 8 | from pyb import SPI, Pin 9 | import uos 10 | import st7789 11 | import time 12 | import gc 13 | 14 | gc.collect() 15 | 16 | tft = st7789.ST7789( 17 | SPI(1, SPI.MASTER, baudrate=42000000, prescaler=2), 18 | 240, 19 | 320, 20 | reset=Pin('X3', Pin.OUT), 21 | cs=Pin('X5', Pin.OUT), 22 | dc=Pin('X4', Pin.OUT), 23 | backlight=Pin('X2', Pin.OUT), 24 | rotation=3) 25 | 26 | tft.init() 27 | tft.fill(st7789.BLACK) 28 | 29 | for i in range(1, 2387): 30 | last = time.ticks_ms() 31 | frame = "/sd/160x120/{:04d}.jpg".format(i) 32 | tft.jpg(frame, 80, 60, st7789.FAST) 33 | if time.ticks_diff(time.ticks_ms(), last) < 250: 34 | time.sleep_ms(10) 35 | -------------------------------------------------------------------------------- /examples/tiny_hello.py: -------------------------------------------------------------------------------- 1 | """ 2 | hello.py 3 | 4 | Writes "Hello!" in random colors at random locations on the display. 5 | """ 6 | 7 | import random 8 | import utime 9 | import st7789 10 | import tft_config 11 | import vga1_8x8 as font 12 | 13 | tft = tft_config.config(0) 14 | 15 | def center(text): 16 | length = len(text) 17 | tft.text( 18 | font, 19 | text, 20 | tft.width() // 2 - length // 2 * font.WIDTH, 21 | tft.height() // 2 - font.HEIGHT, 22 | st7789.WHITE, 23 | st7789.RED) 24 | 25 | def main(): 26 | tft.init() 27 | 28 | tft.fill(st7789.RED) 29 | center("Hello!") 30 | utime.sleep(2) 31 | tft.fill(st7789.BLACK) 32 | 33 | while True: 34 | for rotation in range(4): 35 | tft.rotation(rotation) 36 | tft.fill(st7789.BLACK) 37 | col_max = tft.width() - font.WIDTH*6 38 | row_max = tft.height() - font.HEIGHT 39 | 40 | for _ in range(128): 41 | tft.text( 42 | font, 43 | "Hello!", 44 | random.randint(0, col_max), 45 | random.randint(0, row_max), 46 | st7789.color565( 47 | random.getrandbits(8), 48 | random.getrandbits(8), 49 | random.getrandbits(8)), 50 | st7789.color565( 51 | random.getrandbits(8), 52 | random.getrandbits(8), 53 | random.getrandbits(8))) 54 | 55 | 56 | main() 57 | -------------------------------------------------------------------------------- /examples/tiny_toasters/ttoasters.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/tiny_toasters/ttoasters.bmp -------------------------------------------------------------------------------- /examples/toasters/toasters.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/toasters/toasters.bmp -------------------------------------------------------------------------------- /examples/toasters_jpg/toaster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/toasters_jpg/toaster.jpg -------------------------------------------------------------------------------- /examples/toasters_jpg/toasters_jpg.py: -------------------------------------------------------------------------------- 1 | """ 2 | toasters_jpg.py 3 | 4 | An example using a jpg sprite map to draw sprites on T-Display. This is an older version of the 5 | toasters.py and tiny_toasters example. It uses the jpg_decode() method to grab a bitmap of each 6 | sprite from the toaster.jpg sprite sheet. 7 | 8 | youtube video: https://youtu.be/0uWsjKQmCpU 9 | 10 | spritesheet from CircuitPython_Flying_Toasters 11 | https://learn.adafruit.com/circuitpython-sprite-animation-pendant-mario-clouds-flying-toasters 12 | """ 13 | 14 | import time 15 | import random 16 | from machine import Pin, SPI 17 | import st7789 18 | 19 | # 20 | # Select a config module for your display 21 | # 22 | 23 | # Not suitable for esp32_7735_128 due to resolution 24 | # Not suitable for esp32_7735_160 due to resolution 25 | # import tdisplay as Driver 26 | # import twatch_2020_v2 as Driver 27 | # import ws_pico_114 as Driver 28 | # import ws_pico_13 as Driver 29 | # import ws_pico_2 as Driver 30 | import tdisplay_rp2040 as Driver 31 | 32 | tft = Driver.config(0) 33 | 34 | class toast(): 35 | ''' 36 | toast class to keep track of a sprites locaton and step 37 | ''' 38 | 39 | def __init__(self, sprites, x, y): 40 | self.sprites = sprites 41 | self.steps = len(sprites) 42 | self.x = x 43 | self.y = y 44 | self.step = random.randint(0, self.steps-1) 45 | self.speed = random.randint(2, 5) 46 | 47 | def move(self): 48 | if self.x <= 0: 49 | self.speed = random.randint(2, 5) 50 | self.x = 135-64 51 | 52 | self.step += 1 53 | self.step %= self.steps 54 | self.x -= self.speed 55 | 56 | 57 | def main(): 58 | ''' 59 | Draw and move sprite 60 | ''' 61 | 62 | # enable display and clear screen 63 | tft.init() 64 | tft.fill(st7789.BLACK) 65 | 66 | width = 64 67 | height = 64 68 | 69 | # grab each sprite from the toaster.jpg sprite sheet 70 | t1, _, _ = tft.jpg_decode('toaster.jpg', 0, 0, width, height) 71 | t2, _, _ = tft.jpg_decode('toaster.jpg', width, 0, width, height) 72 | t3, _, _ = tft.jpg_decode('toaster.jpg', width*2, 0, width, height) 73 | t4, _, _ = tft.jpg_decode('toaster.jpg', 0, height, width, height) 74 | t5, _, _ = tft.jpg_decode('toaster.jpg', width, height, width, height) 75 | 76 | TOASTERS = [t1, t2, t3, t4] 77 | TOAST = [t5] 78 | 79 | sprites = [ 80 | toast(TOASTERS, tft.width() - width, 0), 81 | toast(TOAST, tft.width() - width * 2, tft.height() // 3), 82 | toast(TOASTERS, tft.width() - width * 4, tft.height() // 3 * 2) 83 | ] 84 | 85 | # move and draw sprites 86 | while True: 87 | for man in sprites: 88 | bitmap = man.sprites[man.step] 89 | tft.fill_rect( 90 | man.x+width-man.speed, 91 | man.y, 92 | man.speed, 93 | height, 94 | st7789.BLACK) 95 | 96 | man.move() 97 | 98 | if man.x > 0: 99 | tft.blit_buffer(bitmap, man.x, man.y, width, height) 100 | else: 101 | tft.fill_rect( 102 | 0, 103 | man.y, 104 | width, 105 | height, 106 | st7789.BLACK) 107 | 108 | time.sleep(0.05) 109 | 110 | 111 | main() 112 | -------------------------------------------------------------------------------- /examples/watch/LibreBaskerville-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/watch/LibreBaskerville-Regular.ttf -------------------------------------------------------------------------------- /examples/watch/create_face_jpg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Create a watch face_{width}x{height}.jpg file for a given width and height. 3 | """ 4 | 5 | import math 6 | from PIL import Image, ImageDraw, ImageFont 7 | 8 | width = 320 # width of the display 9 | height = 240 # height of the display 10 | face = min(width, height) # face is the smaller of the two 11 | ofs = (width - face) // 2 # offset from the left side of the display 12 | 13 | # create an image 14 | out = Image.new("RGB", (width, height), (255, 255, 255)) 15 | 16 | fnt = ImageFont.truetype("./LibreBaskerville-Regular.ttf", 18) # get a font of an appropriate size 17 | d = ImageDraw.Draw(out) # get a drawing context 18 | radius = int(face // 2 * 0.8) # radius of the clock face 19 | cx = int(face // 2) # center x of the clock face 20 | 21 | second = 0 22 | for minute in range(1, 60): 23 | # get the angle of the minute hand 24 | angle = ((minute*math.pi/30)+(second*math.pi/1800)) 25 | cos_a = math.cos(angle) 26 | sin_a = math.sin(angle) 27 | 28 | # x and y coordinates of the outer minute tick 29 | y1 = -cx * cos_a * 0.76 30 | x1 = cx * sin_a * 0.76 31 | 32 | # x and y coordinates of the inner minute tick 33 | y2 = -cx * cos_a * 0.7 34 | x2 = cx * sin_a * 0.7 35 | 36 | # draw the minute tick 37 | d.line([ofs+x1+cx, y1+cx, ofs+x2+cx, y2+cx], width=1, fill="#000000") 38 | 39 | for hour in range(1, 13): 40 | # get the angle of the hour hand 41 | angle = (hour*math.pi/6) 42 | cos_a = math.cos(angle) 43 | sin_a = math.sin(angle) 44 | 45 | # x and y coordinates of the outer hour tick 46 | y1 = -cx * cos_a * 0.76 47 | x1 = cx * sin_a * 0.76 48 | 49 | # x and y coordinates of the inner hour tick 50 | y2 = -cx * cos_a * 0.7 51 | x2 = cx * sin_a * 0.7 52 | 53 | # draw the hour tick 54 | d.line([ofs+x1+cx, y1+cx, ofs+x2+cx, y2+cx], width=5, fill="#ff0000") 55 | 56 | # x and y coordinates of the hour number 57 | y = -cx * cos_a * 0.9 58 | x = cx * sin_a * 0.9 59 | 60 | # draw the hour number in our previously selected font 61 | size = d.textbbox((0, 0), str(hour), font=fnt) 62 | d.text( 63 | (ofs+x+cx-((size[2]+size[0] >> 1)), y+cx-((size[3]+size[1]) >> 1)), 64 | str(hour), 65 | font=fnt, 66 | fill=(0, 0, 0), 67 | align="center") 68 | 69 | # save the face as a jpeg file 70 | out.save(f'face_{width}x{height}.jpg', "JPEG") 71 | # out.show() 72 | -------------------------------------------------------------------------------- /examples/watch/face_128x128.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/watch/face_128x128.jpg -------------------------------------------------------------------------------- /examples/watch/face_160x128.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/watch/face_160x128.jpg -------------------------------------------------------------------------------- /examples/watch/face_240x135.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/watch/face_240x135.jpg -------------------------------------------------------------------------------- /examples/watch/face_240x240.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/watch/face_240x240.jpg -------------------------------------------------------------------------------- /examples/watch/face_320x240.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/examples/watch/face_320x240.jpg -------------------------------------------------------------------------------- /examples/watch/watch.py: -------------------------------------------------------------------------------- 1 | """" 2 | watch.py - Analog Watch Display using jpg for the face and filled polygons for the hands 3 | Requires face_{width}x{height}.jpg in the same directory as this script. See the create_face.py 4 | script for creating a face image for a given sized display. 5 | 6 | Previous version video: https://youtu.be/NItKb6umMc4 7 | """ 8 | 9 | import utime 10 | import math 11 | import st7789 12 | import tft_config 13 | 14 | 15 | tft = tft_config.config(1) 16 | 17 | 18 | def hand_polygon(length, radius): 19 | return [ 20 | (0, 0), 21 | (-radius, radius), 22 | (-radius, int(length * 0.3)), 23 | (-1, length), 24 | (1, length), 25 | (radius, int(length * 0.3)), 26 | (radius, radius), 27 | (0,0) 28 | ] 29 | 30 | 31 | def main(): 32 | ''' 33 | Draw analog watch face and update time 34 | ''' 35 | 36 | # enable display 37 | tft.init() 38 | width = tft.width() 39 | height = tft.height() 40 | radius = min(width, height) # face is the smaller of the two 41 | ofs = (width - radius) // 2 # offset from the left to center the face 42 | center_x = radius // 2 + ofs - 1 # center of the face horizontally 43 | center_y = radius // 2 - 1 # center of the face vertically 44 | 45 | # draw the watch face background 46 | face = "face_{}x{}.jpg".format(width, height) 47 | tft.jpg(face, 0, 0, st7789.SLOW) 48 | 49 | # create the polygons for the hour, minute and second hands 50 | # polygons must be closed convex polygons or bad things(tm) happen. 51 | 52 | second_len = int(radius * 0.65 / 2) 53 | second_poly = hand_polygon(second_len, 2) 54 | 55 | minute_len = int(radius * 0.6 / 2) 56 | minute_poly = hand_polygon(minute_len, 2) 57 | 58 | hour_len = int(radius * 0.5 / 2) 59 | hour_poly = hand_polygon(hour_len, 3) 60 | 61 | # constants for calculating hand angles. 62 | pi_div_6 = math.pi/6 63 | pi_div_30 = math.pi/30 64 | pi_div_360 = math.pi/360 65 | pi_div_1800 = math.pi/1800 66 | pi_div_2160 = math.pi/2160 67 | 68 | # initialize variables for the bounding rectangles for the 69 | # hour, minute and second hands. Calling bounding with True will 70 | # reset the bounds, calling with False will disable bounding 71 | 72 | tft.bounding(True) 73 | hour_bound = tft.bounding(True) 74 | minute_bound = tft.bounding(True) 75 | second_bound = tft.bounding(True) 76 | 77 | while True: 78 | # save the current time in seconds so we can determine when 79 | # when to update the display. 80 | last = utime.time() 81 | 82 | # get the current hour, minute and second 83 | _, _, _, hour, minute, second, _, _ = utime.localtime() 84 | 85 | # constrain hours to 12 hour time 86 | hour %= 12 87 | 88 | # calculate the angle of the hour hand in radians 89 | hour_ang = ( 90 | (hour * pi_div_6) + 91 | (minute * pi_div_360) + 92 | (second * pi_div_2160)) 93 | 94 | # calculate the angle of the minute hand in radians 95 | minute_ang = ((minute*pi_div_30)+(second*pi_div_1800)) 96 | 97 | # calculate the angle of the second hand on radians 98 | second_ang = (second*pi_div_30) 99 | 100 | # erase the bounding area of the last drawn hour hand 101 | x1, y1, x2, y2 = hour_bound 102 | tft.fill_rect(x1, y1, x2, y2, st7789.WHITE) 103 | 104 | # erase the bounding area of the last drawn minute hand 105 | x1, y1, x2, y2 = minute_bound 106 | tft.fill_rect(x1, y1, x2, y2, st7789.WHITE) 107 | 108 | # erase the bounding area of the last drawn second hand 109 | x1, y1, x2, y2 = second_bound 110 | tft.fill_rect(x1, y1, x2, y2, st7789.WHITE) 111 | 112 | # draw the hub after erasing the bounding areas to reduce flickering 113 | tft.fill_circle(center_x, center_y, 5, st7789.BLACK) 114 | 115 | tft.bounding(True) # clear bounding rectangle 116 | 117 | # draw and fill the hour hand polygon rotated to hour_ang 118 | tft.fill_polygon(hour_poly, center_x, center_y, st7789.BLACK, hour_ang) 119 | 120 | # get the bounding rectangle of the hour_polygon as drawn and 121 | # reset the bounding box for the next polygon 122 | hour_bound = tft.bounding(True, True) 123 | 124 | # draw and fill the minute hand polygon rotated to minute_ang 125 | tft.fill_polygon(minute_poly, center_x, center_y, st7789.BLACK, minute_ang) 126 | 127 | # get the bounding rectangle of the minute_polygon as drawn and 128 | # reset the bounding box for the next polygon 129 | minute_bound = tft.bounding(True, True) 130 | 131 | # draw and fill the second hand polygon rotated to second_ang 132 | 133 | tft.fill_polygon(second_poly, center_x, center_y, st7789.RED, second_ang) 134 | 135 | # get the bounding rectangle of the second_polygon as drawn and 136 | # reset the bounding box for the next polygon 137 | second_bound = tft.bounding(True, True) 138 | 139 | # draw the hub again to cover up the second hand 140 | tft.fill_circle(center_x, center_y, 5, st7789.BLACK) 141 | 142 | # wait until the current second changes 143 | while last == utime.time(): 144 | utime.sleep_ms(50) 145 | 146 | 147 | main() 148 | -------------------------------------------------------------------------------- /firmware/ESP32_BOX_LITE/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/ESP32_BOX_LITE/firmware.bin -------------------------------------------------------------------------------- /firmware/ESP32_BOX_LITE/flash_instructions.md: -------------------------------------------------------------------------------- 1 | # Flashing firmware 2 | 3 | ## ESP32 4 | 5 | ### Erase flash 6 | 7 | esptool.py --chip esp32 --port /dev/ttyACM0 erase_flash 8 | 9 | ### Flash firmware 10 | esptool.py --chip esp32 --port /dev/ttyACM0 write_flash -z 0x1000 firmware.bin 11 | 12 | Power Cycle device 13 | 14 | 15 | ## ESP32-S3 16 | 17 | Place device unto flash mode by pressing and holding the BOOT button, then 18 | pressing and releasing the RESET button and finally releasing the BOOT button. 19 | 20 | ### Erase flash 21 | 22 | esptool.py --chip esp32s3 --port /dev/ttyACM0 erase_flash 23 | 24 | ### Flash firmware 25 | esptool.py --chip esp32s3 --port /dev/ttyACM0 write_flash -z 0 firmware.bin 26 | 27 | Power Cycle device 28 | -------------------------------------------------------------------------------- /firmware/GENERIC-7789/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/GENERIC-7789/firmware.bin -------------------------------------------------------------------------------- /firmware/GENERIC_C3/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/GENERIC_C3/firmware.bin -------------------------------------------------------------------------------- /firmware/GENERIC_C3_USB/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/GENERIC_C3_USB/firmware.bin -------------------------------------------------------------------------------- /firmware/GENERIC_S2/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/GENERIC_S2/firmware.bin -------------------------------------------------------------------------------- /firmware/GENERIC_S3_7789/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/GENERIC_S3_7789/firmware.bin -------------------------------------------------------------------------------- /firmware/GENERIC_S3_SPIRAM/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/GENERIC_S3_SPIRAM/firmware.bin -------------------------------------------------------------------------------- /firmware/GENERIC_S3_SPIRAM_OCT/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/GENERIC_S3_SPIRAM_OCT/firmware.bin -------------------------------------------------------------------------------- /firmware/GENERIC_SPIRAM-7789/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/GENERIC_SPIRAM-7789/firmware.bin -------------------------------------------------------------------------------- /firmware/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2022 Damien P. George 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- 24 | 25 | Unless specified otherwise (see below), the above license and copyright applies 26 | to all files in this repository. 27 | 28 | Individual files may include additional copyright holders. 29 | 30 | The various ports of MicroPython may include third-party software that is 31 | licensed under different terms. These licenses are summarised in the tree 32 | below, please refer to these files and directories for further license and 33 | copyright information. Note that (L)GPL-licensed code listed below is only 34 | used during the build process and is not part of the compiled source code. 35 | 36 | / (MIT) 37 | /drivers 38 | /cc3000 (BSD-3-clause) 39 | /cc3100 (BSD-3-clause) 40 | /wiznet5k (BSD-3-clause) 41 | /lib 42 | /asf4 (Apache-2.0) 43 | /axtls (BSD-3-clause) 44 | /config 45 | /scripts 46 | /config (GPL-2.0-or-later) 47 | /Rules.mak (GPL-2.0) 48 | /berkeley-db-1xx (BSD-4-clause) 49 | /btstack (See btstack/LICENSE) 50 | /cmsis (BSD-3-clause) 51 | /crypto-algorithms (NONE) 52 | /libhydrogen (ISC) 53 | /littlefs (BSD-3-clause) 54 | /lwip (BSD-3-clause) 55 | /mynewt-nimble (Apache-2.0) 56 | /nrfx (BSD-3-clause) 57 | /nxp_driver (BSD-3-Clause) 58 | /oofatfs (BSD-1-clause) 59 | /pico-sdk (BSD-3-clause) 60 | /re15 (BSD-3-clause) 61 | /stm32lib (BSD-3-clause) 62 | /tinytest (BSD-3-clause) 63 | /tinyusb (MIT) 64 | /uzlib (Zlib) 65 | /logo (uses OFL-1.1) 66 | /ports 67 | /cc3200 68 | /hal (BSD-3-clause) 69 | /simplelink (BSD-3-clause) 70 | /FreeRTOS (GPL-2.0 with FreeRTOS exception) 71 | /stm32 72 | /usbd*.c (MCD-ST Liberty SW License Agreement V2) 73 | /stm32_it.* (MIT + BSD-3-clause) 74 | /system_stm32*.c (MIT + BSD-3-clause) 75 | /boards 76 | /startup_stm32*.s (BSD-3-clause) 77 | /*/stm32*.h (BSD-3-clause) 78 | /usbdev (MCD-ST Liberty SW License Agreement V2) 79 | /usbhost (MCD-ST Liberty SW License Agreement V2) 80 | /teensy 81 | /core (PJRC.COM) 82 | /zephyr 83 | /src (Apache-2.0) 84 | /tools 85 | /dfu.py (LGPL-3.0-only) 86 | -------------------------------------------------------------------------------- /firmware/LOLIN_S2_MINI/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/LOLIN_S2_MINI/firmware.bin -------------------------------------------------------------------------------- /firmware/M5CORE/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/M5CORE/firmware.bin -------------------------------------------------------------------------------- /firmware/M5CORE2/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/M5CORE2/firmware.bin -------------------------------------------------------------------------------- /firmware/PYBV11/firmware.dfu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/PYBV11/firmware.dfu -------------------------------------------------------------------------------- /firmware/RP2/firmware.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/RP2/firmware.uf2 -------------------------------------------------------------------------------- /firmware/RP2W/firmware.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/RP2W/firmware.uf2 -------------------------------------------------------------------------------- /firmware/T-DISPLAY-ESP32/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/T-DISPLAY-ESP32/firmware.bin -------------------------------------------------------------------------------- /firmware/T-DISPLAY-RP2040/firmware.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/T-DISPLAY-RP2040/firmware.uf2 -------------------------------------------------------------------------------- /firmware/T-DONGLE-S3/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/T-DONGLE-S3/firmware.bin -------------------------------------------------------------------------------- /firmware/TWATCH-2020/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/TWATCH-2020/firmware.bin -------------------------------------------------------------------------------- /firmware/WIO_TERMINAL/firmware.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/firmware/WIO_TERMINAL/firmware.uf2 -------------------------------------------------------------------------------- /fonts/bitmap/README.md: -------------------------------------------------------------------------------- 1 | # Included Font Files 2 | 3 | Frozen font files are included in the firmware. 4 | 5 | ## Bit mapped fonts for use with Text method 6 | 7 | The font_from_romfont utility can convert fonts from the font-bin directory of 8 | spacerace's https://github.com/spacerace/romfont repo. 9 | 10 | ### 128 Character Bit Mapped Fonts 11 | 12 | Frozen | Font | Example 13 | ------ | ------------------------------------------------------ | ----------------------------- 14 | Yes | [vga1_8x8.py](/fonts/bitmap/vga1_8x8.py) | ![Image](/docs/vga1_8x8.png) 15 | Yes | [vga1_16x16.py](/fonts/bitmap/vga1_16x16.py) | ![Image](/docs/vga1_16x16.png) 16 | Yes | [vga1_16x32.py](/fonts/bitmap/vga1_16x32.py) | ![Image](/docs/vga1_16x32.png) 17 | Yes | [vga1_bold_16x16.py](/fonts/bitmap/vga1_bold_16x16.py) | ![Image](/docs/vga1_bold_16x16.png) 18 | Yes | [vga1_bold_16x32.py](/fonts/bitmap/vga1_bold_16x32.py) | ![Image](/docs/vga1_bold_16x32.png) 19 | 20 | 21 | ### 256 Character Bit Mapped Fonts 22 | 23 | Frozen | Font | Example 24 | ------ | ------------------------------------------------------ | -------------------------- 25 | No | [vga2_8x8.py](/fonts/bitmap/vga2_8x8.py) | ![Image](/docs/vga2_8x8.png) 26 | No | [vga2_8x16.py](/fonts/bitmap/vga2_8x16.py) | ![Image](/docs/vga2_8x16.png) 27 | No | [vga2_16x16.py](/fonts/bitmap/vga2_16x16.py) | ![Image](/docs/vga2_16x16.png) 28 | No | [vga2_16x32.py](/fonts/bitmap/vga2_16x32.py) | ![Image](/docs/vga2_16x32.png) 29 | No | [vga2_bold_16x16.py](/fonts/bitmap/vga2_bold_16x16.py) | ![Image](/docs/vga2_bold_16x16.png) 30 | No | [vga2_bold_16x32.py](/fonts/bitmap/vga2_bold_16x32.py) | ![Image](/docs/vga2_bold_16x32.png) 31 | 32 | -------------------------------------------------------------------------------- /fonts/bitmap/vga1_8x8.py: -------------------------------------------------------------------------------- 1 | """converted from vga_8x8.bin """ 2 | WIDTH = 8 3 | HEIGHT = 8 4 | FIRST = 0x20 5 | LAST = 0x7f 6 | _FONT =\ 7 | b'\x00\x00\x00\x00\x00\x00\x00\x00'\ 8 | b'\x18\x3c\x3c\x18\x18\x00\x18\x00'\ 9 | b'\x66\x66\x24\x00\x00\x00\x00\x00'\ 10 | b'\x6c\x6c\xfe\x6c\xfe\x6c\x6c\x00'\ 11 | b'\x18\x3e\x60\x3c\x06\x7c\x18\x00'\ 12 | b'\x00\xc6\xcc\x18\x30\x66\xc6\x00'\ 13 | b'\x38\x6c\x38\x76\xdc\xcc\x76\x00'\ 14 | b'\x18\x18\x30\x00\x00\x00\x00\x00'\ 15 | b'\x0c\x18\x30\x30\x30\x18\x0c\x00'\ 16 | b'\x30\x18\x0c\x0c\x0c\x18\x30\x00'\ 17 | b'\x00\x66\x3c\xff\x3c\x66\x00\x00'\ 18 | b'\x00\x18\x18\x7e\x18\x18\x00\x00'\ 19 | b'\x00\x00\x00\x00\x00\x18\x18\x30'\ 20 | b'\x00\x00\x00\x7e\x00\x00\x00\x00'\ 21 | b'\x00\x00\x00\x00\x00\x18\x18\x00'\ 22 | b'\x06\x0c\x18\x30\x60\xc0\x80\x00'\ 23 | b'\x38\x6c\xc6\xd6\xc6\x6c\x38\x00'\ 24 | b'\x18\x38\x18\x18\x18\x18\x7e\x00'\ 25 | b'\x7c\xc6\x06\x1c\x30\x66\xfe\x00'\ 26 | b'\x7c\xc6\x06\x3c\x06\xc6\x7c\x00'\ 27 | b'\x1c\x3c\x6c\xcc\xfe\x0c\x1e\x00'\ 28 | b'\xfe\xc0\xc0\xfc\x06\xc6\x7c\x00'\ 29 | b'\x38\x60\xc0\xfc\xc6\xc6\x7c\x00'\ 30 | b'\xfe\xc6\x0c\x18\x30\x30\x30\x00'\ 31 | b'\x7c\xc6\xc6\x7c\xc6\xc6\x7c\x00'\ 32 | b'\x7c\xc6\xc6\x7e\x06\x0c\x78\x00'\ 33 | b'\x00\x18\x18\x00\x00\x18\x18\x00'\ 34 | b'\x00\x18\x18\x00\x00\x18\x18\x30'\ 35 | b'\x06\x0c\x18\x30\x18\x0c\x06\x00'\ 36 | b'\x00\x00\x7e\x00\x00\x7e\x00\x00'\ 37 | b'\x60\x30\x18\x0c\x18\x30\x60\x00'\ 38 | b'\x7c\xc6\x0c\x18\x18\x00\x18\x00'\ 39 | b'\x7c\xc6\xde\xde\xde\xc0\x78\x00'\ 40 | b'\x38\x6c\xc6\xfe\xc6\xc6\xc6\x00'\ 41 | b'\xfc\x66\x66\x7c\x66\x66\xfc\x00'\ 42 | b'\x3c\x66\xc0\xc0\xc0\x66\x3c\x00'\ 43 | b'\xf8\x6c\x66\x66\x66\x6c\xf8\x00'\ 44 | b'\xfe\x62\x68\x78\x68\x62\xfe\x00'\ 45 | b'\xfe\x62\x68\x78\x68\x60\xf0\x00'\ 46 | b'\x3c\x66\xc0\xc0\xce\x66\x3a\x00'\ 47 | b'\xc6\xc6\xc6\xfe\xc6\xc6\xc6\x00'\ 48 | b'\x3c\x18\x18\x18\x18\x18\x3c\x00'\ 49 | b'\x1e\x0c\x0c\x0c\xcc\xcc\x78\x00'\ 50 | b'\xe6\x66\x6c\x78\x6c\x66\xe6\x00'\ 51 | b'\xf0\x60\x60\x60\x62\x66\xfe\x00'\ 52 | b'\xc6\xee\xfe\xfe\xd6\xc6\xc6\x00'\ 53 | b'\xc6\xe6\xf6\xde\xce\xc6\xc6\x00'\ 54 | b'\x7c\xc6\xc6\xc6\xc6\xc6\x7c\x00'\ 55 | b'\xfc\x66\x66\x7c\x60\x60\xf0\x00'\ 56 | b'\x7c\xc6\xc6\xc6\xc6\xce\x7c\x0e'\ 57 | b'\xfc\x66\x66\x7c\x6c\x66\xe6\x00'\ 58 | b'\x3c\x66\x30\x18\x0c\x66\x3c\x00'\ 59 | b'\x7e\x7e\x5a\x18\x18\x18\x3c\x00'\ 60 | b'\xc6\xc6\xc6\xc6\xc6\xc6\x7c\x00'\ 61 | b'\xc6\xc6\xc6\xc6\xc6\x6c\x38\x00'\ 62 | b'\xc6\xc6\xc6\xd6\xd6\xfe\x6c\x00'\ 63 | b'\xc6\xc6\x6c\x38\x6c\xc6\xc6\x00'\ 64 | b'\x66\x66\x66\x3c\x18\x18\x3c\x00'\ 65 | b'\xfe\xc6\x8c\x18\x32\x66\xfe\x00'\ 66 | b'\x3c\x30\x30\x30\x30\x30\x3c\x00'\ 67 | b'\xc0\x60\x30\x18\x0c\x06\x02\x00'\ 68 | b'\x3c\x0c\x0c\x0c\x0c\x0c\x3c\x00'\ 69 | b'\x10\x38\x6c\xc6\x00\x00\x00\x00'\ 70 | b'\x00\x00\x00\x00\x00\x00\x00\xff'\ 71 | b'\x30\x18\x0c\x00\x00\x00\x00\x00'\ 72 | b'\x00\x00\x78\x0c\x7c\xcc\x76\x00'\ 73 | b'\xe0\x60\x7c\x66\x66\x66\xdc\x00'\ 74 | b'\x00\x00\x7c\xc6\xc0\xc6\x7c\x00'\ 75 | b'\x1c\x0c\x7c\xcc\xcc\xcc\x76\x00'\ 76 | b'\x00\x00\x7c\xc6\xfe\xc0\x7c\x00'\ 77 | b'\x3c\x66\x60\xf8\x60\x60\xf0\x00'\ 78 | b'\x00\x00\x76\xcc\xcc\x7c\x0c\xf8'\ 79 | b'\xe0\x60\x6c\x76\x66\x66\xe6\x00'\ 80 | b'\x18\x00\x38\x18\x18\x18\x3c\x00'\ 81 | b'\x06\x00\x06\x06\x06\x66\x66\x3c'\ 82 | b'\xe0\x60\x66\x6c\x78\x6c\xe6\x00'\ 83 | b'\x38\x18\x18\x18\x18\x18\x3c\x00'\ 84 | b'\x00\x00\xec\xfe\xd6\xd6\xd6\x00'\ 85 | b'\x00\x00\xdc\x66\x66\x66\x66\x00'\ 86 | b'\x00\x00\x7c\xc6\xc6\xc6\x7c\x00'\ 87 | b'\x00\x00\xdc\x66\x66\x7c\x60\xf0'\ 88 | b'\x00\x00\x76\xcc\xcc\x7c\x0c\x1e'\ 89 | b'\x00\x00\xdc\x76\x60\x60\xf0\x00'\ 90 | b'\x00\x00\x7e\xc0\x7c\x06\xfc\x00'\ 91 | b'\x30\x30\xfc\x30\x30\x36\x1c\x00'\ 92 | b'\x00\x00\xcc\xcc\xcc\xcc\x76\x00'\ 93 | b'\x00\x00\xc6\xc6\xc6\x6c\x38\x00'\ 94 | b'\x00\x00\xc6\xd6\xd6\xfe\x6c\x00'\ 95 | b'\x00\x00\xc6\x6c\x38\x6c\xc6\x00'\ 96 | b'\x00\x00\xc6\xc6\xc6\x7e\x06\xfc'\ 97 | b'\x00\x00\x7e\x4c\x18\x32\x7e\x00'\ 98 | b'\x0e\x18\x18\x70\x18\x18\x0e\x00'\ 99 | b'\x18\x18\x18\x18\x18\x18\x18\x00'\ 100 | b'\x70\x18\x18\x0e\x18\x18\x70\x00'\ 101 | b'\x76\xdc\x00\x00\x00\x00\x00\x00'\ 102 | b'\x00\x10\x38\x6c\xc6\xc6\xfe\x00'\ 103 | 104 | FONT = memoryview(_FONT) 105 | -------------------------------------------------------------------------------- /fonts/bitmap/vga_8x16.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/fonts/bitmap/vga_8x16.bin -------------------------------------------------------------------------------- /fonts/bitmap/vga_8x8.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/fonts/bitmap/vga_8x8.bin -------------------------------------------------------------------------------- /fonts/truetype/Chango-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/fonts/truetype/Chango-Regular.ttf -------------------------------------------------------------------------------- /fonts/truetype/LICENSE_OFL.txt: -------------------------------------------------------------------------------- 1 | This Font Software is licensed under the SIL Open Font License, 2 | Version 1.1. 3 | 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | ----------------------------------------------------------- 8 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 9 | ----------------------------------------------------------- 10 | 11 | PREAMBLE 12 | The goals of the Open Font License (OFL) are to stimulate worldwide 13 | development of collaborative font projects, to support the font 14 | creation efforts of academic and linguistic communities, and to 15 | provide a free and open framework in which fonts may be shared and 16 | improved in partnership with others. 17 | 18 | The OFL allows the licensed fonts to be used, studied, modified and 19 | redistributed freely as long as they are not sold by themselves. The 20 | fonts, including any derivative works, can be bundled, embedded, 21 | redistributed and/or sold with any software provided that any reserved 22 | names are not used by derivative works. The fonts and derivatives, 23 | however, cannot be released under any other type of license. The 24 | requirement for fonts to remain under this license does not apply to 25 | any document created using the fonts or their derivatives. 26 | 27 | DEFINITIONS 28 | "Font Software" refers to the set of files released by the Copyright 29 | Holder(s) under this license and clearly marked as such. This may 30 | include source files, build scripts and documentation. 31 | 32 | "Reserved Font Name" refers to any names specified as such after the 33 | copyright statement(s). 34 | 35 | "Original Version" refers to the collection of Font Software 36 | components as distributed by the Copyright Holder(s). 37 | 38 | "Modified Version" refers to any derivative made by adding to, 39 | deleting, or substituting -- in part or in whole -- any of the 40 | components of the Original Version, by changing formats or by porting 41 | the Font Software to a new environment. 42 | 43 | "Author" refers to any designer, engineer, programmer, technical 44 | writer or other person who contributed to the Font Software. 45 | 46 | PERMISSION & CONDITIONS 47 | Permission is hereby granted, free of charge, to any person obtaining 48 | a copy of the Font Software, to use, study, copy, merge, embed, 49 | modify, redistribute, and sell modified and unmodified copies of the 50 | Font Software, subject to the following conditions: 51 | 52 | 1) Neither the Font Software nor any of its individual components, in 53 | Original or Modified Versions, may be sold by itself. 54 | 55 | 2) Original or Modified Versions of the Font Software may be bundled, 56 | redistributed and/or sold with any software, provided that each copy 57 | contains the above copyright notice and this license. These can be 58 | included either as stand-alone text files, human-readable headers or 59 | in the appropriate machine-readable metadata fields within text or 60 | binary files as long as those fields can be easily viewed by the user. 61 | 62 | 3) No Modified Version of the Font Software may use the Reserved Font 63 | Name(s) unless explicit written permission is granted by the 64 | corresponding Copyright Holder. This restriction only applies to the 65 | primary font name as presented to the users. 66 | 67 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 68 | Software shall not be used to promote, endorse or advertise any 69 | Modified Version, except to acknowledge the contribution(s) of the 70 | Copyright Holder(s) and the Author(s) or with their explicit written 71 | permission. 72 | 73 | 5) The Font Software, modified or unmodified, in part or in whole, 74 | must be distributed entirely under this license, and must not be 75 | distributed under any other license. The requirement for fonts to 76 | remain under this license does not apply to any document created using 77 | the Font Software. 78 | 79 | TERMINATION 80 | This license becomes null and void if any of the above conditions are 81 | not met. 82 | 83 | DISCLAIMER 84 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 85 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 86 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 87 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 88 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 89 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 90 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 91 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 92 | OTHER DEALINGS IN THE FONT SOFTWARE. 93 | -------------------------------------------------------------------------------- /fonts/truetype/NotoSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/fonts/truetype/NotoSans-Regular.ttf -------------------------------------------------------------------------------- /fonts/truetype/NotoSansMono-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/fonts/truetype/NotoSansMono-Regular.ttf -------------------------------------------------------------------------------- /fonts/truetype/NotoSerif-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/fonts/truetype/NotoSerif-Regular.ttf -------------------------------------------------------------------------------- /fonts/truetype/README.md: -------------------------------------------------------------------------------- 1 | # SIL Open Font License fonts 2 | 3 | Here are a few of the SIL Open Font Licensed fonts I used for testing the 4 | `monofont2bitmap` and `font2bitmap` utilies. 5 | 6 | ## Proportional fonts 7 | 8 | These are suitable for use with `font2bitmap` utility and the drivers `write` 9 | method. 10 | 11 | - Chango-Regular.ttf 12 | - NotoSans-Regular.ttf 13 | - NotoSerif-Regular.ttf 14 | 15 | ## Monospaced fonts 16 | 17 | This font is suitable for use with `font2bitmap` utility and the drivers `write` 18 | method. It can also be used with the `monofont2bitmap` utility and the drivers 19 | `bitmap` method. 20 | 21 | - inconsolata-700.ttf 22 | - NotoSansMono-Regular.ttf 23 | 24 | -------------------------------------------------------------------------------- /fonts/truetype/inconsolata-700.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/fonts/truetype/inconsolata-700.ttf -------------------------------------------------------------------------------- /fonts/vector/README.md: -------------------------------------------------------------------------------- 1 | # Included Font Files 2 | 3 | Frozen font files are included in the firmware. 4 | 5 | ## Vector fonts for use with the Draw method 6 | 7 | ### Hershey Vector Fonts 8 | 9 | Frozen | Font | Example 10 | ------ | ---------------------------------------- | ---------------------- 11 | No | [astrol.py](/fonts/vector/astrol.py) | ![Image](/docs/astrol.svg) 12 | Yes | [cyrilc.py](/fonts/vector/cyrilc.py) | ![Image](/docs/cyrilc.svg) 13 | Yes | [gotheng.py](/fonts/vector/gotheng.py) | ![Image](/docs/gotheng.svg) 14 | Yes | [gothger.py](/fonts/vector/gothger.py) | ![Image](/docs/gothger.svg) 15 | Yes | [gothita.py](/fonts/vector/gothita.py) | ![Image](/docs/gothita.svg) 16 | Yes | [greekc.py](/fonts/vector/greekc.py) | ![Image](/docs/greekc.svg) 17 | Yes | [greekcs.py](/fonts/vector/greekcs.py) | ![Image](/docs/greekcs.svg) 18 | Yes | [greekp.py](/fonts/vector/greekp.py) | ![Image](/docs/greekp.svg) 19 | Yes | [greeks.py](/fonts/vector/greeks.py) | ![Image](/docs/greeks.svg) 20 | Yes | [italicc.py](/fonts/vector/italicc.py) | ![Image](/docs/italicc.svg) 21 | Yes | [italiccs.py](/fonts/vector/italiccs.py) | ![Image](/docs/italiccs.svg) 22 | Yes | [italict.py](/fonts/vector/italict.py) | ![Image](/docs/italict.svg) 23 | Yes | [lowmat.py](/fonts/vector/lowmat.py) | ![Image](/docs/lowmat.svg) 24 | Yes | [marker.py](/fonts/vector/marker.py) | ![Image](/docs/marker.svg) 25 | Yes | [meteo.py](/fonts/vector/meteo.py) | ![Image](/docs/meteo.svg) 26 | Yes | [music.py](/fonts/vector/music.py) | ![Image](/docs/music.svg) 27 | Yes | [romanc.py](/fonts/vector/romanc.py) | ![Image](/docs/romanc.svg) 28 | Yes | [romancs.py](/fonts/vector/romancs.py) | ![Image](/docs/romancs.svg) 29 | Yes | [romand.py](/fonts/vector/romand.py) | ![Image](/docs/romand.svg) 30 | Yes | [romanp.py](/fonts/vector/romanp.py) | ![Image](/docs/romanp.svg) 31 | Yes | [romans.py](/fonts/vector/romans.py) | ![Image](/docs/romans.svg) 32 | Yes | [romant.py](/fonts/vector/romant.py) | ![Image](/docs/romant.svg) 33 | Yes | [scriptc.py](/fonts/vector/scriptc.py) | ![Image](/docs/scriptc.svg) 34 | Yes | [scripts.py](/fonts/vector/scripts.py) | ![Image](/docs/scripts.svg) 35 | Yes | [symbol.py](/fonts/vector/symbol.py) | ![Image](/docs/symbol.svg) 36 | Yes | [uppmat.py](/fonts/vector/uppmat.py) | ![Image](/docs/uppmat.svg) 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 | -------------------------------------------------------------------------------- /micropython.cmake: -------------------------------------------------------------------------------- 1 | # This top-level micropython.cmake is responsible for listing 2 | # the individual modules we want to include. 3 | # Paths are absolute, and ${CMAKE_CURRENT_LIST_DIR} can be 4 | # used to prefix subdirectories. 5 | 6 | include(${CMAKE_CURRENT_LIST_DIR}/st7789/micropython.cmake) 7 | -------------------------------------------------------------------------------- /st7789/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | # BasedOnStyle: LLVM 3 | AccessModifierOffset: -2 4 | ConstructorInitializerIndentWidth: 4 5 | AlignEscapedNewlinesLeft: false 6 | AlignTrailingComments: true 7 | AllowAllParametersOfDeclarationOnNextLine: true 8 | AllowShortIfStatementsOnASingleLine: false 9 | AllowShortLoopsOnASingleLine: false 10 | AlwaysBreakTemplateDeclarations: false 11 | AlwaysBreakBeforeMultilineStrings: false 12 | BreakBeforeBinaryOperators: false 13 | BreakBeforeTernaryOperators: true 14 | BreakConstructorInitializersBeforeComma: false 15 | BinPackParameters: true 16 | ColumnLimit: 0 17 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 18 | DerivePointerBinding: false 19 | ExperimentalAutoDetectBinPacking: false 20 | IndentCaseLabels: true 21 | MaxEmptyLinesToKeep: 1 22 | NamespaceIndentation: None 23 | ObjCSpaceBeforeProtocolList: true 24 | PenaltyBreakBeforeFirstCallParameter: 19 25 | PenaltyBreakComment: 60 26 | PenaltyBreakString: 1000 27 | PenaltyBreakFirstLessLess: 120 28 | PenaltyExcessCharacter: 1000000 29 | PenaltyReturnTypeOnItsOwnLine: 60 30 | PointerBindsToType: false 31 | SpacesBeforeTrailingComments: 1 32 | Cpp11BracedListStyle: true 33 | Standard: Cpp03 34 | IndentWidth: 4 35 | TabWidth: 4 36 | UseTab: Always 37 | BreakBeforeBraces: WebKit 38 | IndentFunctionDeclarationAfterType: false 39 | SpacesInParentheses: false 40 | SpacesInAngles: false 41 | SpaceInEmptyParentheses: false 42 | SpacesInCStyleCastParentheses: false 43 | SpaceAfterControlStatementKeyword: true 44 | SpaceBeforeAssignmentOperators: true 45 | ContinuationIndentWidth: 4 46 | IndentWrappedFunctionNames: true 47 | KeepEmptyLinesAtTheStartOfBlocks: false 48 | SortIncludes: false 49 | SpaceAfterCStyleCast: true 50 | SpacesInSquareBrackets: false 51 | AlignConsecutiveAssignments: true 52 | AlignConsecutiveDeclarations: true 53 | ... 54 | 55 | -------------------------------------------------------------------------------- /st7789/jpg/tjpgd565.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------/ 2 | / TJpgDec - Tiny JPEG Decompressor include file (C)ChaN, 2020 3 | /----------------------------------------------------------------------------*/ 4 | #ifndef DEF_TJPGDEC 5 | #define DEF_TJPGDEC 6 | /*---------------------------------------------------------------------------*/ 7 | /* System Configurations */ 8 | 9 | #define JD_SZBUF 512 /* Size of stream input buffer */ 10 | #define JD_FORMAT 1 /* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */ 11 | #define JD_USE_SCALE 1 /* Use descaling feature for output */ 12 | #define JD_TBLCLIP 1 /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */ 13 | 14 | /*---------------------------------------------------------------------------*/ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "stdint.h" 21 | 22 | /* Error code */ 23 | typedef enum { 24 | JDR_OK = 0, /* 0: Succeeded */ 25 | JDR_INTR, /* 1: Interrupted by output function */ 26 | JDR_INP, /* 2: Device error or wrong termination of input stream */ 27 | JDR_MEM1, /* 3: Insufficient memory pool for the image */ 28 | JDR_MEM2, /* 4: Insufficient stream input buffer */ 29 | JDR_PAR, /* 5: Parameter error */ 30 | JDR_FMT1, /* 6: Data format error (may be damaged data) */ 31 | JDR_FMT2, /* 7: Right format but not supported */ 32 | JDR_FMT3 /* 8: Not supported JPEG standard */ 33 | } JRESULT; 34 | 35 | 36 | 37 | /* Rectangular structure */ 38 | typedef struct { 39 | uint16_t left, right, top, bottom; 40 | } JRECT; 41 | 42 | 43 | 44 | /* Decompressor object structure */ 45 | typedef struct JDEC JDEC; 46 | struct JDEC { 47 | unsigned int dctr; /* Number of bytes available in the input buffer */ 48 | uint8_t* dptr; /* Current data read ptr */ 49 | uint8_t* inbuf; /* Bit stream input buffer */ 50 | uint8_t dmsk; /* Current bit in the current read byte */ 51 | uint8_t scale; /* Output scaling ratio */ 52 | uint8_t msx, msy; /* MCU size in unit of block (width, height) */ 53 | uint8_t qtid[3]; /* Quantization table ID of each component */ 54 | int16_t dcv[3]; /* Previous DC element of each component */ 55 | uint16_t nrst; /* Restart inverval */ 56 | uint16_t width, height; /* Size of the input image (pixel) */ 57 | uint8_t* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */ 58 | uint16_t* huffcode[2][2]; /* Huffman code word tables [id][dcac] */ 59 | uint8_t* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */ 60 | int32_t* qttbl[4]; /* Dequantizer tables [id] */ 61 | void* workbuf; /* Working buffer for IDCT and RGB output */ 62 | uint8_t* mcubuf; /* Working buffer for the MCU */ 63 | void* pool; /* Pointer to available memory pool */ 64 | unsigned int sz_pool; /* Size of momory pool (bytes available) */ 65 | unsigned int (*infunc)(JDEC*, uint8_t*, unsigned int); /* Pointer to jpeg stream input function */ 66 | void* device; /* Pointer to I/O device identifiler for the session */ 67 | uint16_t x_offs; /* x offset for slow method */ 68 | uint16_t y_offs; /* y offset for slow method */ 69 | }; 70 | 71 | 72 | /* TJpgDec API functions */ 73 | JRESULT jd_prepare (JDEC* jd, unsigned int (*infunc)(JDEC*,uint8_t*,unsigned int), void* pool, unsigned int sz_pool, void* dev); 74 | JRESULT jd_decomp (JDEC* jd, int (*outfunc)(JDEC*,void*,JRECT*), uint8_t scale); 75 | 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* _TJPGDEC */ 82 | -------------------------------------------------------------------------------- /st7789/micropython.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Create an INTERFACE library for our C module. 3 | add_library(usermod_st7789 INTERFACE) 4 | 5 | # Add our source files to the lib 6 | target_sources(usermod_st7789 INTERFACE 7 | ${CMAKE_CURRENT_LIST_DIR}/st7789.c 8 | ${CMAKE_CURRENT_LIST_DIR}/mpfile.c 9 | ${CMAKE_CURRENT_LIST_DIR}/jpg/tjpgd565.c 10 | ${CMAKE_CURRENT_LIST_DIR}/png/pngle.c 11 | ${CMAKE_CURRENT_LIST_DIR}/png/miniz.c) 12 | 13 | # Add the current directory as an include directory. 14 | target_include_directories(usermod_st7789 INTERFACE 15 | ${CMAKE_CURRENT_LIST_DIR}) 16 | 17 | # Link our INTERFACE library to the usermod target. 18 | target_link_libraries(usermod INTERFACE usermod_st7789) 19 | -------------------------------------------------------------------------------- /st7789/micropython.mk: -------------------------------------------------------------------------------- 1 | ST7789_MOD_DIR := $(USERMOD_DIR) 2 | 3 | CFLAGS_USERMOD += -I$(ST7789_MOD_DIR) 4 | 5 | SRC_USERMOD += $(addprefix $(ST7789_MOD_DIR)/, st7789.c) 6 | SRC_USERMOD += $(addprefix $(ST7789_MOD_DIR)/, mpfile.c) 7 | SRC_USERMOD += $(addprefix $(ST7789_MOD_DIR)/jpg/, tjpgd565.c) 8 | SRC_USERMOD += $(addprefix $(ST7789_MOD_DIR)/png/, pngle.c) 9 | SRC_USERMOD += $(addprefix $(ST7789_MOD_DIR)/png/, miniz.c) 10 | -------------------------------------------------------------------------------- /st7789/mpfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Micro Python project, http://micropython.org/ 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2016 Dave Hylands 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #include "py/builtin.h" 28 | #include "py/misc.h" 29 | #include "py/runtime.h" 30 | #include "mpfile.h" 31 | 32 | #include "extmod/vfs.h" 33 | 34 | #include 35 | #include 36 | 37 | 38 | static const mp_obj_type_t mp_file_type; 39 | static mp_obj_t mp___del__(mp_obj_t self); 40 | 41 | mp_file_t *mp_file_from_file_obj(mp_obj_t file_obj) { 42 | mp_file_t *file = m_new_obj(mp_file_t); 43 | memset(file, 0, sizeof(*file)); 44 | file->base.type = &mp_file_type; 45 | file->file_obj = file_obj; 46 | file->readinto_fn = mp_load_attr(file->file_obj, MP_QSTR_readinto); 47 | file->seek_fn = mp_load_attr(file->file_obj, MP_QSTR_seek); 48 | file->tell_fn = mp_load_attr(file->file_obj, MP_QSTR_tell); 49 | 50 | return file; 51 | } 52 | 53 | mp_file_t *mp_open(const char *filename, const char *mode) { 54 | mp_obj_t filename_obj = mp_obj_new_str(filename, strlen(filename)); 55 | mp_obj_t mode_obj = mp_obj_new_str(mode, strlen(mode)); 56 | mp_obj_t args[2] = { filename_obj, mode_obj }; 57 | return mp_file_from_file_obj(mp_vfs_open(2, args, (mp_map_t *)&mp_const_empty_map)); 58 | } 59 | 60 | mp_int_t mp_readinto(mp_file_t *file, void *buf, size_t num_bytes) { 61 | mp_int_t nread; 62 | 63 | mp_obj_t bytearray = mp_obj_new_bytearray_by_ref(num_bytes, buf); 64 | mp_obj_t bytes_read = mp_call_function_1(file->readinto_fn, bytearray); 65 | if (bytes_read == mp_const_none) { 66 | return 0; 67 | } 68 | nread = mp_obj_get_int(bytes_read); 69 | return nread; 70 | } 71 | 72 | off_t mp_seek(mp_file_t *file, off_t offset, int whence) { 73 | return mp_obj_get_int(mp_call_function_2(file->seek_fn, 74 | MP_OBJ_NEW_SMALL_INT(offset), 75 | MP_OBJ_NEW_SMALL_INT(whence))); 76 | } 77 | 78 | off_t mp_tell(mp_file_t *file) { 79 | return mp_obj_get_int(mp_call_function_0(file->tell_fn)); 80 | } 81 | 82 | void mp_close(mp_file_t *file) { 83 | 84 | mp_obj_t close_fn = mp_load_attr(file->file_obj, MP_QSTR_close); 85 | file->file_obj = mp_const_none; 86 | file->readinto_fn = mp_const_none; 87 | file->seek_fn = mp_const_none; 88 | file->tell_fn = mp_const_none; 89 | mp_call_function_0(close_fn); 90 | } 91 | 92 | static void mp_file_print(const mp_print_t *print, mp_obj_t self, mp_print_kind_t kind) { 93 | (void)kind; 94 | mp_printf(print, "", self); 95 | } 96 | 97 | static mp_obj_t mp___del__(mp_obj_t self) { 98 | mp_close(MP_OBJ_TO_PTR(self)); 99 | return mp_const_none; 100 | } 101 | static MP_DEFINE_CONST_FUN_OBJ_1(mp___del___obj, mp___del__); 102 | 103 | static const mp_rom_map_elem_t mp_file_locals_dict_table[] = { 104 | { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp___del___obj) }, 105 | }; 106 | static MP_DEFINE_CONST_DICT(mp_file_locals_dict, mp_file_locals_dict_table); 107 | 108 | #ifdef MP_OBJ_TYPE_GET_SLOT 109 | 110 | static MP_DEFINE_CONST_OBJ_TYPE( 111 | mp_file_type, 112 | MP_QSTR_mp_file, 113 | MP_TYPE_FLAG_NONE, 114 | print, mp_file_print, 115 | locals_dict, (mp_obj_dict_t *) &mp_file_locals_dict 116 | ); 117 | 118 | #else 119 | 120 | static const mp_obj_type_t mp_file_type = { 121 | .base = { &mp_type_type }, 122 | .name = MP_QSTR_mp_file, 123 | .print = mp_file_print, 124 | .locals_dict = (mp_obj_dict_t *)&mp_file_locals_dict, 125 | }; 126 | 127 | #endif -------------------------------------------------------------------------------- /st7789/mpfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Micro Python project, http://micropython.org/ 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2016 Dave Hylands 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #ifndef __MICROPY_INCLUDED_PY_MPFILE_H__ 28 | #define __MICROPY_INCLUDED_PY_MPFILE_H__ 29 | 30 | #include "py/obj.h" 31 | #include // for off_t 32 | 33 | // A C API for performing I/O on files or file-like objects. 34 | 35 | typedef struct { 36 | mp_obj_base_t base; 37 | mp_obj_t file_obj; 38 | mp_obj_t readinto_fn; 39 | mp_obj_t seek_fn; 40 | mp_obj_t tell_fn; 41 | } mp_file_t; 42 | 43 | #define MP_SEEK_SET 0 44 | #define MP_SEEK_CUR 1 45 | #define MP_SEEK_END 2 46 | 47 | mp_file_t *mp_file_from_file_obj(mp_obj_t file_obj); 48 | mp_file_t *mp_open(const char *filename, const char *mode); 49 | mp_int_t mp_readinto(mp_file_t *file, void *buf, size_t num_bytes); 50 | off_t mp_seek(mp_file_t *file, off_t offset, int whence); 51 | off_t mp_tell(mp_file_t *file); 52 | void mp_close(mp_file_t *file); 53 | 54 | 55 | #endif // __MICROPY_INCLUDED_PY_MPFILE_H__ 56 | -------------------------------------------------------------------------------- /st7789/png/miniz.h: -------------------------------------------------------------------------------- 1 | #define MINIZ_HEADER_FILE_ONLY 2 | #include "miniz.c" 3 | -------------------------------------------------------------------------------- /st7789/png/pngle.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * MIT License 3 | * 4 | * Copyright (c) 2019 kikuchan 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef __PNGLE_H__ 26 | #define __PNGLE_H__ 27 | 28 | #include 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | #define PNGLE_NO_GAMMA_CORRECTION 1 35 | 36 | // Main Pngle object 37 | typedef struct _pngle_t pngle_t; 38 | 39 | // Callback signatures 40 | typedef void (*pngle_init_callback_t)(pngle_t *pngle, uint32_t w, uint32_t h); 41 | typedef void (*pngle_draw_callback_t)(pngle_t *pngle, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t rgba[4]); 42 | typedef void (*pngle_done_callback_t)(pngle_t *pngle); 43 | 44 | // ---------------- 45 | // Basic interfaces 46 | // ---------------- 47 | pngle_t *pngle_new(); 48 | void pngle_destroy(pngle_t *pngle); 49 | void pngle_reset(pngle_t *pngle); // clear its internal state (not applied to pngle_set_* functions) 50 | const char *pngle_error(pngle_t *pngle); 51 | int pngle_feed(pngle_t *pngle, const void *buf, size_t len); // returns -1: On error, 0: Need more data, n: n bytes eaten 52 | 53 | uint32_t pngle_get_width(pngle_t *pngle); 54 | uint32_t pngle_get_height(pngle_t *pngle); 55 | 56 | void pngle_set_init_callback(pngle_t *png, pngle_init_callback_t callback); 57 | void pngle_set_draw_callback(pngle_t *png, pngle_draw_callback_t callback); 58 | void pngle_set_done_callback(pngle_t *png, pngle_done_callback_t callback); 59 | 60 | void pngle_set_display_gamma(pngle_t *pngle, double display_gamma); // enables gamma correction by specifying display gamma, typically 2.2. No effect when gAMA chunk is missing 61 | 62 | void pngle_set_user_data(pngle_t *pngle, void *user_data); 63 | void *pngle_get_user_data(pngle_t *pngle); 64 | 65 | 66 | // ---------------- 67 | // Debug interfaces 68 | // ---------------- 69 | 70 | typedef struct _pngle_ihdr_t { 71 | uint32_t width; 72 | uint32_t height; 73 | uint8_t depth; 74 | uint8_t color_type; 75 | uint8_t compression; 76 | uint8_t filter; 77 | uint8_t interlace; 78 | } pngle_ihdr_t; 79 | 80 | // Get IHDR information 81 | pngle_ihdr_t *pngle_get_ihdr(pngle_t *pngle); 82 | 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* __PNGLE_H__ */ 89 | -------------------------------------------------------------------------------- /st7789/st7789.h: -------------------------------------------------------------------------------- 1 | #ifndef __ST7789_H__ 2 | #define __ST7789_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | // color modes 9 | #define COLOR_MODE_65K 0x50 10 | #define COLOR_MODE_262K 0x60 11 | #define COLOR_MODE_12BIT 0x03 12 | #define COLOR_MODE_16BIT 0x05 13 | #define COLOR_MODE_18BIT 0x06 14 | #define COLOR_MODE_16M 0x07 15 | 16 | // commands 17 | #define ST7789_NOP 0x00 18 | #define ST7789_SWRESET 0x01 19 | #define ST7789_RDDID 0x04 20 | #define ST7789_RDDST 0x09 21 | 22 | #define ST7789_SLPIN 0x10 23 | #define ST7789_SLPOUT 0x11 24 | #define ST7789_PTLON 0x12 25 | #define ST7789_NORON 0x13 26 | 27 | #define ST7789_INVOFF 0x20 28 | #define ST7789_INVON 0x21 29 | #define ST7789_DISPOFF 0x28 30 | #define ST7789_DISPON 0x29 31 | #define ST7789_CASET 0x2A 32 | #define ST7789_RASET 0x2B 33 | #define ST7789_RAMWR 0x2C 34 | #define ST7789_RAMRD 0x2E 35 | 36 | #define ST7789_PTLAR 0x30 37 | #define ST7789_VSCRDEF 0x33 38 | #define ST7789_COLMOD 0x3A 39 | #define ST7789_MADCTL 0x36 40 | #define ST7789_VSCSAD 0x37 41 | 42 | #define ST7789_MADCTL_MY 0x80 // Page Address Order 43 | #define ST7789_MADCTL_MX 0x40 // Column Address Order 44 | #define ST7789_MADCTL_MV 0x20 // Page/Column Order 45 | #define ST7789_MADCTL_ML 0x10 // Line Address Order 46 | #define ST7789_MADCTL_MH 0x04 // Display Data Latch Order 47 | #define ST7789_MADCTL_RGB 0x00 48 | #define ST7789_MADCTL_BGR 0x08 49 | 50 | #define ST7789_RDID1 0xDA 51 | #define ST7789_RDID2 0xDB 52 | #define ST7789_RDID3 0xDC 53 | #define ST7789_RDID4 0xDD 54 | 55 | // Color definitions 56 | #define BLACK 0x0000 57 | #define BLUE 0x001F 58 | #define RED 0xF800 59 | #define GREEN 0x07E0 60 | #define CYAN 0x07FF 61 | #define MAGENTA 0xF81F 62 | #define YELLOW 0xFFE0 63 | #define WHITE 0xFFFF 64 | 65 | #define OPTIONS_WRAP_V 0x01 66 | #define OPTIONS_WRAP_H 0x02 67 | #define OPTIONS_WRAP 0x03 68 | 69 | typedef struct _Point { 70 | mp_float_t x; 71 | mp_float_t y; 72 | } Point; 73 | 74 | typedef struct _Polygon { 75 | int length; 76 | Point *points; 77 | } Polygon; 78 | 79 | typedef struct _st7789_rotation_t { 80 | uint8_t madctl; 81 | uint16_t width; 82 | uint16_t height; 83 | uint16_t colstart; 84 | uint16_t rowstart; 85 | } st7789_rotation_t; 86 | 87 | // this is the actual C-structure for our new object 88 | typedef struct _st7789_ST7789_obj_t { 89 | mp_obj_base_t base; 90 | mp_obj_base_t *spi_obj; 91 | mp_file_t *fp; // file object 92 | uint16_t *i2c_buffer; // resident buffer if buffer_size given 93 | 94 | // m_malloc'd pointers 95 | void *work; // work buffer for jpg & png decoding 96 | uint8_t *scanline_ringbuf; // png scanline_ringbuf 97 | uint8_t *palette; // png palette 98 | uint8_t *trans_palette; // png trans_palette 99 | uint8_t *gamma_table; // png gamma_table 100 | 101 | size_t buffer_size; // resident buffer size, 0=dynamic 102 | uint16_t display_width; // physical width 103 | uint16_t width; // logical width (after rotation) 104 | uint16_t display_height; // physical width 105 | uint16_t height; // logical height (after rotation) 106 | uint8_t colstart; 107 | uint8_t rowstart; 108 | uint8_t rotation; 109 | st7789_rotation_t *rotations; // list of rotation tuples [(madctl, colstart, rowstart)] 110 | uint8_t rotations_len; // number of rotations 111 | mp_obj_t custom_init; // custom init sequence 112 | uint8_t color_order; 113 | bool inversion; 114 | uint8_t madctl; 115 | uint8_t options; // options bit array 116 | mp_hal_pin_obj_t reset; 117 | mp_hal_pin_obj_t dc; 118 | mp_hal_pin_obj_t cs; 119 | mp_hal_pin_obj_t backlight; 120 | 121 | uint8_t bounding; 122 | uint16_t min_x; 123 | uint16_t min_y; 124 | uint16_t max_x; 125 | uint16_t max_y; 126 | 127 | } st7789_ST7789_obj_t; 128 | 129 | mp_obj_t st7789_ST7789_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); 130 | 131 | extern void draw_pixel(st7789_ST7789_obj_t *self, int16_t x, int16_t y, uint16_t color); 132 | extern void fast_hline(st7789_ST7789_obj_t *self, int16_t x, int16_t y, int16_t w, uint16_t color); 133 | 134 | #ifdef __cplusplus 135 | } 136 | #endif /* __cplusplus */ 137 | 138 | #endif /* __ST7789_H__ */ 139 | -------------------------------------------------------------------------------- /utils/font_from_romfont.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | Convert fonts from the font-bin directory of spacerace's 4 | https://github.com/spacerace/romfont repo. 5 | 6 | Reads all romfont bin files from the specified -input-directory (-i) and writes 7 | python font files to the specified -output-directory (-o). Optionally limiting 8 | characters included to -first-char (-f) thru -last-char (-l). 9 | 10 | Example: 11 | 12 | font_from_romfont -i font-bin -o pyfont -f 32 -l 127 13 | 14 | requires argparse 15 | """ 16 | import os 17 | import re 18 | import argparse 19 | 20 | def convert_font(file_in, file_out, width, height, first=0x0, last=0xff): 21 | chunk_size = height 22 | with open(file_in, "rb") as bin_file: 23 | bin_file.seek(first * height) 24 | current = first 25 | with open(file_out, 'wt') as font_file: 26 | print(f'"""converted from {file_in} """', file=font_file) 27 | print(f'WIDTH = {width}', file=font_file) 28 | print(f'HEIGHT = {height}', file=font_file) 29 | print(f'FIRST = 0x{first:02x}', file=font_file) 30 | print(f'LAST = 0x{last:02x}', file=font_file) 31 | print('_FONT =\\\n', sep='', end='', file=font_file) 32 | for chunk in iter(lambda: bin_file.read(chunk_size), b''): 33 | print('b\'', sep='', end='', file=font_file) 34 | for data in chunk: 35 | print(f'\\x{data:02x}', end='', file=font_file) 36 | print('\'\\', file=font_file) 37 | current += 1 38 | if current > last: 39 | break 40 | 41 | print('', file=font_file) 42 | print('FONT = memoryview(_FONT)', file=font_file) 43 | 44 | def auto_int(x): 45 | return int(x, 0) 46 | 47 | def main(): 48 | parser = argparse.ArgumentParser( 49 | description='Convert Romfont.bin font files in input to python in font_directory.') 50 | parser.add_argument('input', help='file or directory containing binary font file(s).') 51 | parser.add_argument('output', help='file or directory to contain python font file(s).') 52 | parser.add_argument('-f', '--first-char', type=auto_int, default=0x20) 53 | parser.add_argument('-l', '--last-char', type=auto_int, default=0x7f) 54 | args = parser.parse_args() 55 | 56 | file_re = re.compile(r'^(.*)(\d+)x(\d+)\.bin$') 57 | 58 | is_dir = os.path.isdir(args.input) 59 | bin_files = os.listdir(args.input) if is_dir else [args.input] 60 | for bin_file_name in bin_files: 61 | match = file_re.match(bin_file_name) 62 | if match: 63 | font_width = int(match.group(2)) 64 | font_height = int(match.group(3)) 65 | 66 | if is_dir: 67 | bin_file_name = args.input+'/'+bin_file_name 68 | 69 | if is_dir: 70 | font_file_name = ( 71 | args.font_directory + '/' + 72 | match.group(1).rstrip('_').lower()+ 73 | f'_{font_width}x{font_height}.py') 74 | else: 75 | font_file_name = args.output 76 | 77 | print("converting", bin_file_name, 'to', font_file_name) 78 | 79 | convert_font( 80 | bin_file_name, 81 | font_file_name, 82 | font_width, 83 | font_height, 84 | args.first_char, 85 | args.last_char) 86 | 87 | main() 88 | -------------------------------------------------------------------------------- /utils/howto-convert-to-jpg: -------------------------------------------------------------------------------- 1 | # 2 | # You can convert images to compatible jpg's by using ImageMagick's convert 3 | # utility by specifying the output type as TrueColor. ImageMagick downloads 4 | # are available from https://imagemagick.org/ for Linux, OSX, Windows and 5 | # other operating systems. 6 | # 7 | # The wi-alien.svg icon is from https://github.com/erikflowers/weather-icons 8 | # licensed under SIL OFL 1.1 9 | # 10 | 11 | convert wi-alien.svg -type TrueColor alien.jpg 12 | -------------------------------------------------------------------------------- /utils/imgtobitmap.py: -------------------------------------------------------------------------------- 1 | #!python3 2 | ''' 3 | Convert image file to python module for use with blit_bitmap. 4 | 5 | Usage imgtobitmap image_file bits_per_pixel >image.py 6 | ''' 7 | 8 | import sys 9 | from PIL import Image 10 | import argparse 11 | 12 | 13 | def main(): 14 | 15 | parser = argparse.ArgumentParser( 16 | prog='imgtobitmap', 17 | description='Convert image file to python module for use with bitmap method.') 18 | 19 | parser.add_argument( 20 | 'image_file', 21 | help='Name of file containing image to convert') 22 | 23 | parser.add_argument( 24 | 'bits_per_pixel', 25 | type=int, 26 | choices=range(1, 9), 27 | default=1, 28 | metavar='bits_per_pixel', 29 | help='The number of bits to use per pixel (1..8)') 30 | 31 | args = parser.parse_args() 32 | bits = args.bits_per_pixel 33 | colors_requested = 1 << bits 34 | img = Image.open(args.image_file) 35 | img = img.convert("P", palette=Image.Palette.ADAPTIVE, colors=colors_requested) 36 | palette = img.getpalette() # Make copy of palette colors 37 | palette_colors = len(palette) // 3 38 | bits_required = palette_colors.bit_length() 39 | if (bits_required < bits): 40 | print(f'\nNOTE: Quantization reduced colors to {palette_colors} from the {colors_requested} ' 41 | f'requested, reconverting using {bits_required} bit per pixel could save memory.\n''', file=sys.stderr) 42 | 43 | # For all the colors in the palette 44 | colors = [] 45 | 46 | for color in range(palette_colors): 47 | 48 | # get rgb values and convert to 565 49 | color565 = ( 50 | ((palette[color*3] & 0xF8) << 8) 51 | | ((palette[color*3+1] & 0xFC) << 3) 52 | | ((palette[color*3+2] & 0xF8) >> 3)) 53 | 54 | # swap bytes in 565 55 | color = ((color565 & 0xff) << 8) + ((color565 & 0xff00) >> 8) 56 | 57 | # append byte swapped 565 color to colors 58 | colors.append(f'{color:04x}') 59 | 60 | image_bitstring = '' 61 | max_colors = 1 << bits 62 | 63 | # Run through the image and create a string with the ascii binary 64 | # representation of the color of each pixel. 65 | for y in range(img.height): 66 | for x in range(img.width): 67 | pixel = img.getpixel((x, y)) 68 | color = pixel 69 | bstring = ''.join( 70 | '1' if (color & (1 << bit - 1)) else '0' 71 | for bit in range(bits, 0, -1) 72 | ) 73 | 74 | image_bitstring += bstring 75 | 76 | bitmap_bits = len(image_bitstring) 77 | 78 | # Create python source with image parameters 79 | print(f'HEIGHT = {img.height}') 80 | print(f'WIDTH = {img.width}') 81 | print(f'COLORS = {max_colors}') 82 | print(f'BITS = {bitmap_bits}') 83 | print(f'BPP = {bits}') 84 | print('PALETTE = [', sep='', end='') 85 | 86 | for color, rgb in enumerate(colors): 87 | if color: 88 | print(',', sep='', end='') 89 | print(f'0x{rgb}', sep='', end='') 90 | print("]") 91 | 92 | # Run though image bit string 8 bits at a time 93 | # and create python array source for memoryview 94 | 95 | print("_bitmap =\\", sep='') 96 | print("b'", sep='', end='') 97 | 98 | for i in range(0, bitmap_bits, 8): 99 | 100 | if i and i % (16*8) == 0: 101 | print("'\\\nb'", end='', sep='') 102 | 103 | value = image_bitstring[i:i+8] 104 | color = int(value, 2) 105 | print(f'\\x{color:02x}', sep='', end='') 106 | 107 | print("'\nBITMAP = memoryview(_bitmap)") 108 | 109 | 110 | main() 111 | -------------------------------------------------------------------------------- /utils/maketoast: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # grab sprites from spritesheet using ImageMagick and convert to bitmap format. 5 | # 6 | # spritesheet from CircuitPython_Flying_Toasters 7 | # https://learn.adafruit.com/circuitpython-sprite-animation-pendant-mario-clouds-flying-toasters 8 | # 9 | 10 | convert toasters.bmp -crop 64x64+64+0 t1.png 11 | convert toasters.bmp -crop 64x64+128+0 t2.png 12 | convert toasters.bmp -crop 64x64+192+0 t3.png 13 | convert toasters.bmp -crop 64x64+256+0 t4.png 14 | convert toasters.bmp -crop 64x64+320+0 t5.png 15 | 16 | # use 3 bits per pixel / 8 colors 17 | 18 | ./imgtobits.py t1.png 3 >t1.py 19 | ./imgtobits.py t2.png 3 >t2.py 20 | ./imgtobits.py t3.png 3 >t3.py 21 | ./imgtobits.py t4.png 3 >t4.py 22 | ./imgtobits.py t5.png 3 >t5.py 23 | 24 | cp -v t[12345].py ../examples 25 | 26 | -------------------------------------------------------------------------------- /utils/png_from_font.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Imports all the python font files from the specified -input-directory (-i) and 5 | creates png samples of each font in the specified -output-directory (-o). 6 | 7 | Example: 8 | png_from_font.py font_directory png_directory 9 | 10 | Requires argparse, importlib and pypng 11 | """ 12 | 13 | import os 14 | import importlib 15 | import png 16 | import argparse 17 | 18 | def create_png(font_file_name, png_file_name): 19 | 20 | module_spec = importlib.util.spec_from_file_location('font', font_file_name) 21 | font = importlib.util.module_from_spec(module_spec) 22 | module_spec.loader.exec_module(font) 23 | char_count = font.LAST - font.FIRST 24 | column_count = 16 25 | row_count = (char_count // column_count) 26 | 27 | with open(png_file_name, 'wb') as png_file: 28 | image = png.Writer((16+2) * font.WIDTH, (row_count+3) * font.HEIGHT, bitdepth=1) 29 | image_data = [[0 for j in range((16+2) * font.WIDTH)] for i in range((row_count+3)* font.HEIGHT)] 30 | for chart_row in range(row_count+2): 31 | for chart_col in range(16): 32 | chart_idx = chart_row * 16 + chart_col 33 | for char_line in range(font.HEIGHT): 34 | for char_byte in range(font.WIDTH//8): 35 | ch_idx = chart_idx * font.HEIGHT * font.WIDTH//8 + char_byte + char_line * font.WIDTH//8 36 | print(chart_idx, char_count) 37 | if (chart_idx <= char_count): 38 | data = font.FONT[ch_idx] 39 | else: 40 | data = 0 41 | 42 | for bit in range(8): 43 | png_row = (chart_row+1)*font.HEIGHT+char_line 44 | png_col = (chart_col+1)*font.WIDTH+char_byte*8+bit 45 | if data & 1 << 7-bit: 46 | image_data[png_row][png_col] = 1 47 | else: 48 | image_data[png_row][png_col] = 0 49 | 50 | print("Creating", png_file_name) 51 | image.write(png_file, image_data) 52 | 53 | def main(): 54 | parser = argparse.ArgumentParser( 55 | description='Convert 8bit font-bin.bin font files in bin_directory to python in font_directory.') 56 | parser.add_argument( 57 | 'font_directory', help='directory containing python font files. (input)') 58 | parser.add_argument( 59 | 'png_directory', help='directory to contain binary font files. (output)') 60 | args = parser.parse_args() 61 | 62 | for file_name in os.listdir(args.font_directory): 63 | if file_name.endswith('.py'): 64 | font_file_name = args.font_directory+'/'+file_name 65 | png_file_name = args.png_directory+'/'+os.path.splitext(file_name)[0]+'.png' 66 | create_png(font_file_name, png_file_name) 67 | 68 | main() 69 | -------------------------------------------------------------------------------- /utils/requirements.txt: -------------------------------------------------------------------------------- 1 | Pillow==10.3.0 2 | pypng==0.0.20 3 | freetype-py==2.2.0 -------------------------------------------------------------------------------- /utils/sprites2bitmap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ''' 4 | Convert a sprite sheet image to python a module for use with indexed bitmap method. 5 | Sprite sheet width and height should be a multiple of sprite width and height. There 6 | should be no extra pixels between sprites. All sprites will share the same palette. 7 | 8 | Usage: 9 | sprites2bitmap image_file spite_width sprite_height bits_per_pixel >sprites.py 10 | 11 | MicroPython: 12 | import sprites 13 | ... tft config and init code ... 14 | tft.bitmap(sprites, x, y, index) 15 | 16 | ''' 17 | 18 | from os import setpriority 19 | from PIL import Image 20 | import argparse 21 | 22 | def main(): 23 | 24 | parser = argparse.ArgumentParser( 25 | prog='imgtobitmap', 26 | description='Convert image file to python module for use with bitmap method.') 27 | 28 | parser.add_argument( 29 | 'image_file', 30 | help='Name of file containing image to convert') 31 | 32 | parser.add_argument( 33 | 'sprite_width', 34 | type=int, 35 | help='width of sprites in pixels') 36 | 37 | parser.add_argument( 38 | 'sprite_height', 39 | type=int, 40 | help='height of sprites in pixels') 41 | 42 | parser.add_argument( 43 | 'bits_per_pixel', 44 | type=int, 45 | choices=range(1, 9), 46 | default=1, 47 | metavar='bits_per_pixel', 48 | help='The number of bits to use per pixel (1..8)') 49 | 50 | args = parser.parse_args() 51 | 52 | bits = args.bits_per_pixel 53 | img = Image.open(args.image_file) 54 | img = img.convert("P", palette=Image.ADAPTIVE, colors=2**bits) 55 | palette = img.getpalette() # Make copy of palette colors 56 | 57 | # For all the colors in the palette 58 | colors = [] 59 | for color in range(1 << bits): 60 | 61 | # get rgb values and convert to 565 62 | color565 = ( 63 | ((palette[color*3] & 0xF8) << 8) | 64 | ((palette[color*3+1] & 0xFC) << 3) | 65 | ((palette[color*3+2] & 0xF8) >> 3)) 66 | 67 | # swap bytes in 565 68 | color = ((color565 & 0xff) << 8) + ((color565 & 0xff00) >> 8) 69 | 70 | # append byte swapped 565 color to colors 71 | colors.append(f'{color:04x}') 72 | 73 | image_bitstring = '' 74 | max_colors = 1 << bits 75 | bitmaps = 0 76 | # Run through the image and create a string with the ascii binary 77 | # representation of the color of each pixel. 78 | for y in range(0, img.height, args.sprite_height): 79 | for x in range(0, img.width, args.sprite_width): 80 | bitmaps += 1 81 | for yy in range(y, y + args.sprite_height): 82 | for xx in range(x, x + args.sprite_width): 83 | pixel = img.getpixel((xx, yy)) 84 | color = pixel 85 | image_bitstring += ''.join( 86 | '1' if (color & (1 << bit - 1)) else '0' for bit in range(bits, 0, -1)) 87 | 88 | bitmap_bits = len(image_bitstring) 89 | 90 | # Create python source with image parameters 91 | print(f'BITMAPS = {bitmaps}') 92 | print(f'HEIGHT = {args.sprite_height}') 93 | print(f'WIDTH = {args.sprite_width}') 94 | print(f'COLORS = {max_colors}') 95 | print(f'BITS = {bitmap_bits}') 96 | print(f'BPP = {bits}') 97 | print('PALETTE = [', sep='', end='') 98 | 99 | for color, rgb in enumerate(colors): 100 | if color: 101 | print(',', sep='', end='') 102 | print(f'0x{rgb}', sep='', end='') 103 | print("]") 104 | 105 | # Run though image bit string 8 bits at a time 106 | # and create python array source for memoryview 107 | 108 | print("_bitmap =\\", sep='') 109 | print("b'", sep='', end='') 110 | 111 | for i in range(0, bitmap_bits, 8): 112 | 113 | if i and i % (16*8) == 0: 114 | print("'\\\nb'", end='', sep='') 115 | 116 | value = image_bitstring[i:i+8] 117 | color = int(value, 2) 118 | print(f'\\x{color:02x}', sep='', end='') 119 | 120 | print("'\nBITMAP = memoryview(_bitmap)") 121 | 122 | 123 | main() 124 | -------------------------------------------------------------------------------- /utils/t1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/utils/t1.png -------------------------------------------------------------------------------- /utils/t2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/utils/t2.png -------------------------------------------------------------------------------- /utils/t3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/utils/t3.png -------------------------------------------------------------------------------- /utils/t4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/utils/t4.png -------------------------------------------------------------------------------- /utils/t5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/utils/t5.png -------------------------------------------------------------------------------- /utils/toasters.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/russhughes/st7789_mpy/f629308d586e18c68cb7f952817d38dd094147b1/utils/toasters.bmp -------------------------------------------------------------------------------- /utils/wi-alien.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 16 | 17 | --------------------------------------------------------------------------------