From 3de3a8cec8c8b102c590bfea9f9e2e80c5d9812c Mon Sep 17 00:00:00 2001 From: peterhinch Date: Sat, 6 May 2023 17:06:40 +0100 Subject: [PATCH] Add feather_s3 setup examples. Update date.py --- gui/demos/date.py | 4 ++- setup_examples/ili9486_feather_s3_encoder.py | 33 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 setup_examples/ili9486_feather_s3_encoder.py diff --git a/gui/demos/date.py b/gui/demos/date.py index 2601ee0..80efe30 100644 --- a/gui/demos/date.py +++ b/gui/demos/date.py @@ -12,6 +12,7 @@ def leap(year): class Date: def __init__(self, lt=None): + self.callback = lambda : None # No callback until set self.now(lt) def now(self, lt=None): @@ -23,6 +24,7 @@ class Date: self._lt[3] = 6 self._cur = mktime(self._lt) // _SECS_PER_DAY self._lt = list(localtime(self._cur * _SECS_PER_DAY)) + self.callback() def _mlen(self, d=bytearray((31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31))): days = d[self._lt[1] - 1] @@ -68,7 +70,7 @@ class Date: return self._cur @day.setter - def day(self, v): # Usuge: d.day += 7 or date_1.day = d.day. + def day(self, v): # Usage: d.day += 7 or date_1.day = d.day. self._cur = v self._update(False) # Flag _cur change diff --git a/setup_examples/ili9486_feather_s3_encoder.py b/setup_examples/ili9486_feather_s3_encoder.py new file mode 100644 index 0000000..c74aa00 --- /dev/null +++ b/setup_examples/ili9486_feather_s3_encoder.py @@ -0,0 +1,33 @@ +# ili9341_FeatherS3.py Customise for your hardware config + +# Released under the MIT License (MIT). See LICENSE. +# Copyright (c) 2023 Peter Hinch + +# As written, supports: +# ili9486 320x480 displays on ESP32-S3 FeatherS3 board. + + +from machine import Pin, SPI +import gc + +from drivers.ili94xx.ili9486 import ILI9486 as SSD +# Create and export an SSD instance +pdc = Pin(17, Pin.OUT, value=0) # Arbitrary pins borrowed from st7735r_esp32.py +prst = Pin(18, Pin.OUT, value=1) +pcs = Pin(14, Pin.OUT, value=1) +gc.collect() # Precaution before instantiating framebuf +spi = SPI(1, 30_000_000, sck=Pin(36), mosi=Pin(35), miso=Pin(37)) # No need to wire MISO. +gc.collect() # Precaution before instantiating framebuf +ssd = SSD(spi, cs=pcs, dc=pdc, rst=prst) +from gui.core.ugui import Display, Screen # Must perform this import after instantiating SSD (see other examples) +gc.collect() # Precaution before instantiating framebuf + +# Create and export a Display instance +# Define control buttons +nxt = Pin(8, Pin.IN, Pin.PULL_UP) # Move to next control +sel = Pin(33, Pin.IN, Pin.PULL_UP) # Operate current control +prev = Pin(9, Pin.IN, Pin.PULL_UP) # Move to previous control +increase = Pin(38, Pin.IN, Pin.PULL_UP) # Increase control's value +decrease = Pin(1, Pin.IN, Pin.PULL_UP) # Decrease control's value +display = Display(ssd, nxt, sel, prev, increase, decrease, 4) +Screen.do_gc = False