feat: inital commit
This commit is contained in:
5
boot.py
Normal file
5
boot.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# This file is executed on every boot (including wake-boot from deepsleep)
|
||||||
|
#import esp
|
||||||
|
#esp.osdebug(None)
|
||||||
|
#import webrepl
|
||||||
|
#webrepl.start()
|
||||||
95
display_program.py
Normal file
95
display_program.py
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import gc
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
from time import sleep, time_ns
|
||||||
|
|
||||||
|
from machine import SPI, Pin
|
||||||
|
|
||||||
|
from ili9341 import Display, color565
|
||||||
|
|
||||||
|
colors = {
|
||||||
|
"RED": (255, 0, 0),
|
||||||
|
"GREEN": (0, 255, 0),
|
||||||
|
"BLUE": (0, 0, 255),
|
||||||
|
"YELLOW": (255, 255, 0),
|
||||||
|
"AQUA": (0, 255, 255),
|
||||||
|
"MAROON": (128, 0, 0),
|
||||||
|
"DARK_GREEN": (0, 128, 0),
|
||||||
|
"NAVY": (0, 0, 128),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def display():
|
||||||
|
bg = Pin(33, Pin.OUT)
|
||||||
|
spi = SPI(1, baudrate=40000000, sck=Pin(14), mosi=Pin(13))
|
||||||
|
display = Display(spi, dc=Pin(27), cs=Pin(25), rst=Pin(26))
|
||||||
|
|
||||||
|
bg.on()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
display.draw_text8x8(
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
"ILI9341 Display Test",
|
||||||
|
color565(255, 255, 255),
|
||||||
|
color565(0, 0, 0),
|
||||||
|
270,
|
||||||
|
)
|
||||||
|
display.draw_text8x8(
|
||||||
|
10,
|
||||||
|
280,
|
||||||
|
"PPAP",
|
||||||
|
color565(255, 255, 255),
|
||||||
|
color565(0, 0, 0),
|
||||||
|
270,
|
||||||
|
)
|
||||||
|
sleep(1)
|
||||||
|
# Calculate valid hlines parameters for display clear method
|
||||||
|
valid_hlines = []
|
||||||
|
for i in range(1, display.height):
|
||||||
|
if display.height % i == 0:
|
||||||
|
valid_hlines.append(i)
|
||||||
|
# Ensure only 13 entries, truncate or repeat the last one
|
||||||
|
valid_hlines = valid_hlines[:8]
|
||||||
|
if len(valid_hlines) < 8:
|
||||||
|
valid_hlines += [valid_hlines[-1]] * (8 - len(valid_hlines))
|
||||||
|
# Ensure only 13 entries, truncate or repeat the last one
|
||||||
|
valid_hlines = valid_hlines[:8]
|
||||||
|
if len(valid_hlines) < 8:
|
||||||
|
valid_hlines += [valid_hlines[-1]] * (8 - len(valid_hlines))
|
||||||
|
|
||||||
|
print("Clearing to black...")
|
||||||
|
start = time_ns()
|
||||||
|
display.clear()
|
||||||
|
end = time_ns()
|
||||||
|
print(f"Display cleared in {end - start} ms.")
|
||||||
|
sleep(2)
|
||||||
|
|
||||||
|
print("Clearing to white...")
|
||||||
|
start = time_ns()
|
||||||
|
display.clear(color565(255, 255, 255))
|
||||||
|
end = time_ns()
|
||||||
|
print(f"Display cleared in {end - start} ms.")
|
||||||
|
sleep(2)
|
||||||
|
|
||||||
|
for hlines, (color, rgb) in zip(valid_hlines, colors.items()):
|
||||||
|
display.draw_text8x8(
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
f"Next color: {color}",
|
||||||
|
color565(255, 255, 255),
|
||||||
|
color565(0, 0, 0),
|
||||||
|
270,
|
||||||
|
)
|
||||||
|
sleep(1)
|
||||||
|
print(f"Clearing display to {color}, hlines={hlines}...")
|
||||||
|
try:
|
||||||
|
start = time_ns()
|
||||||
|
display.clear(hlines=hlines, color=color565(*rgb))
|
||||||
|
end = time_ns()
|
||||||
|
print(f"Display cleared in {end - start} ms.")
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
|
sleep(5)
|
||||||
1088
ili9341.py
Normal file
1088
ili9341.py
Normal file
File diff suppressed because it is too large
Load Diff
13
led_program.py
Normal file
13
led_program.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import time
|
||||||
|
|
||||||
|
from machine import Pin
|
||||||
|
|
||||||
|
led_pin = Pin(32, Pin.OUT)
|
||||||
|
|
||||||
|
|
||||||
|
def boostrap():
|
||||||
|
while True:
|
||||||
|
led_pin.on()
|
||||||
|
time.sleep(0.5)
|
||||||
|
led_pin.off()
|
||||||
|
time.sleep(0.5)
|
||||||
Reference in New Issue
Block a user