From 8e81f1eb817d5c3157b828bf1431e56a5a6afc38 Mon Sep 17 00:00:00 2001 From: rdagger Date: Fri, 21 May 2021 21:52:47 -0700 Subject: [PATCH] Add orientation demo --- demo_orientation.py | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 demo_orientation.py diff --git a/demo_orientation.py b/demo_orientation.py new file mode 100644 index 0000000..aae9f26 --- /dev/null +++ b/demo_orientation.py @@ -0,0 +1,52 @@ +"""ILI9341 demo (orientation).""" +from time import sleep +from ili9341 import Display, color565 +from machine import Pin, SPI +from xglcd_font import XglcdFont + + +def test(): + """Test code.""" + print('Loading Espresso Dolce font...') + espresso_dolce = XglcdFont('fonts/EspressoDolce18x24.c', 18, 24) + print('Font loaded.') + # Baud rate of 40000000 seems about the max + spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13)) + + display = Display(spi, dc=Pin(4), cs=Pin(5), rst=Pin(19), + width=240, height=320, rotation=0) + display.draw_text(0, 0, 'Espresso Dolce 18x24', espresso_dolce, + color565(0, 255, 255)) + display.draw_text(0, 319, 'Espresso Dolce 18x24', espresso_dolce, + color565(255, 255, 0), landscape=True) + sleep(5) + + display = Display(spi, dc=Pin(4), cs=Pin(5), rst=Pin(19), + width=320, height=240, rotation=90) + display.draw_text(0, 215, 'Espresso Dolce 18x24', espresso_dolce, + color565(255, 0, 255)) + display.draw_text(295, 239, 'Espresso Dolce 18x24', espresso_dolce, + color565(255, 255, 255), landscape=True) + sleep(5) + + display = Display(spi, dc=Pin(4), cs=Pin(5), rst=Pin(19), + width=240, height=320, rotation=180) + display.draw_text(0, 0, 'Espresso Dolce 18x24', espresso_dolce, + color565(0, 0, 255)) + display.draw_text(0, 319, 'Espresso Dolce 18x24', espresso_dolce, + color565(255, 0, 0), landscape=True) + sleep(5) + + display = Display(spi, dc=Pin(4), cs=Pin(5), rst=Pin(19), + width=320, height=240, rotation=270) + display.draw_text(0, 215, 'Espresso Dolce 18x24', espresso_dolce, + color565(225, 0, 128)) + display.draw_text(295, 239, 'Espresso Dolce 18x24', espresso_dolce, + color565(0, 255, 0), landscape=True) + sleep(5) + display.cleanup() + +test() + + +