kopia lustrzana https://github.com/peterhinch/micropython-micro-gui
Add feather_s3 setup examples. Update date.py
rodzic
19b369e6e7
commit
3de3a8cec8
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
Ładowanie…
Reference in New Issue