6 changed files with 116 additions and 90 deletions
@ -1,15 +1,20 @@
@@ -1,15 +1,20 @@
|
||||
# Makefile for the board
|
||||
NAME=esp32-20220117-v1.18.bin
|
||||
|
||||
NAME=esp32-20180222-v1.9.3-347-g6e675c1b.bin
|
||||
all: flash upload console |
||||
|
||||
all: flash console |
||||
bin/${NAME}: |
||||
mkdir -p bin
|
||||
wget https://micropython.org/resources/firmware/${NAME} -O bin/${NAME}
|
||||
|
||||
flash: |
||||
esptool.py -p /dev/ttyUSB0 -b 921600 erase_flash
|
||||
flash: bin/${NAME} |
||||
esptool.py -p /dev/ttyUSB0 -b 921600 write_flash --flash_mode dio 0x1000 bin/${NAME}
|
||||
sleep 5
|
||||
ampy -p /dev/ttyUSB0 put ssd1306.py
|
||||
|
||||
upload: |
||||
ampy -p /dev/ttyUSB0 put boot.py
|
||||
ampy -p /dev/ttyUSB0 put main.py
|
||||
|
||||
console: |
||||
echo "Ctrl-A + Ctrl-Q to close Picocom"
|
||||
picocom -b115200 /dev/ttyUSB0
|
||||
|
Binary file not shown.
@ -1,5 +1,13 @@
@@ -1,5 +1,13 @@
|
||||
# Give time to cancel this boot script |
||||
import time |
||||
print("Press Ctrl-C to stop boot script...") |
||||
time.sleep(2) |
||||
|
||||
# Connect to wireless network as client |
||||
import network |
||||
wlan = network.WLAN(network.STA_IF) |
||||
wlan.active(True) |
||||
wlan.connect("k-space.ee guest") |
||||
wlan.connect("k-space.ee legacy") |
||||
|
||||
while not wlan.isconnected(): |
||||
pass |
||||
|
@ -1,18 +1,36 @@
@@ -1,18 +1,36 @@
|
||||
from time import sleep_ms |
||||
from machine import Pin, I2C |
||||
from ssd1306 import SSD1306_I2C |
||||
import ntptime |
||||
ntptime.settime() |
||||
|
||||
i2c = I2C(-1, Pin(4),Pin(5),freq=400000) # Bitbanged I2C bus |
||||
assert 60 in i2c.scan(), "No OLED display detected!" |
||||
oled = SSD1306_I2C(128, 64, i2c) |
||||
buf = "wubba lubba dub dub " |
||||
oled.invert(0) # White text on black background |
||||
oled.contrast(255) # Maximum contrast |
||||
j = 0 |
||||
from flipdisc import DisplayBuffer, Font |
||||
from time import sleep, localtime |
||||
from machine import UART |
||||
|
||||
TIMEZONE = 3 |
||||
weekdays = "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" |
||||
|
||||
port = UART(2, baudrate=4800, tx=17, rx=16) |
||||
disp = DisplayBuffer(0x06, 128, 16) |
||||
while True: |
||||
oled.fill(0) |
||||
oled.text(buf[j%len(buf):]+buf, 10, 10) |
||||
oled.show() |
||||
sleep_ms(20) |
||||
j += 1 |
||||
for j in range(0,10): |
||||
year, month, day, hour, minute, second, dow, _ = localtime() |
||||
hour = (hour + TIMEZONE) % 24 |
||||
i = " %02d:%02d:%02d" % (hour, minute, second) |
||||
j = " %04d-%02d-%02d %s" % (year, month, day, weekdays[dow]) |
||||
disp.put_text(i.encode("ascii"),0, 0, Font.F6) |
||||
disp.put_text(j.encode("ascii"),0, 15, Font.F6) |
||||
buf = disp.finalize_buffer() |
||||
port.write(buf) |
||||
sleep(1) |
||||
for j in range(0, 2): |
||||
disp.put_text(b"MicroPython",0, 0, Font.F13_F) |
||||
buf = disp.finalize_buffer() |
||||
port.write(buf) |
||||
sleep(2) |
||||
disp.put_text(b"... is awesome",0, 0, Font.F13_F) |
||||
buf = disp.finalize_buffer() |
||||
port.write(buf) |
||||
sleep(2) |
||||
|
||||
port.close() |
||||
|
||||
|
||||
|
Loading…
Reference in new issue