From 4013d38a313e6f4f1f498ba71bc28930c46133fa Mon Sep 17 00:00:00 2001 From: Julien Cabillot Date: Sat, 9 May 2020 13:03:13 -0400 Subject: [PATCH] First import --- color/main.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ wifi/.gitignore | 1 + wifi/README.md | 8 ++++++++ wifi/creds.example | 0 wifi/main.py | 15 +++++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 color/main.py create mode 100644 wifi/.gitignore create mode 100644 wifi/README.md create mode 100644 wifi/creds.example create mode 100644 wifi/main.py diff --git a/color/main.py b/color/main.py new file mode 100644 index 0000000..3e4f27b --- /dev/null +++ b/color/main.py @@ -0,0 +1,44 @@ +import random +from machine import Pin, SPI +import st7789 +#from fonts import vga1_8x8 as font +from fonts import vga2_bold_16x32 as font + +def main(): + spi = SPI(2, baudrate=30000000, polarity=1, sck=Pin(18), mosi=Pin(19)) + tft = st7789.ST7789( + spi, + 135, + 240, + reset=Pin(23, Pin.OUT), + cs=Pin(5, Pin.OUT), + dc=Pin(16, Pin.OUT), + backlight=Pin(4, Pin.OUT), + rotation=3 + ) + tft.init() + + while True: + for rotation in range(4): + tft.rotation(rotation) + tft.fill(0) + col_max = tft.width() - font.WIDTH*6 + row_max = tft.height() - font.HEIGHT + + for _ in range(250): + tft.text( + font, + "Hello!", + random.randint(0, col_max), + random.randint(0, row_max), + st7789.color565( + random.getrandbits(8), + random.getrandbits(8), + random.getrandbits(8)), + st7789.color565( + random.getrandbits(8), + random.getrandbits(8), + random.getrandbits(8)) + ) + +main() diff --git a/wifi/.gitignore b/wifi/.gitignore new file mode 100644 index 0000000..99a84b3 --- /dev/null +++ b/wifi/.gitignore @@ -0,0 +1 @@ +creds diff --git a/wifi/README.md b/wifi/README.md new file mode 100644 index 0000000..687f0bf --- /dev/null +++ b/wifi/README.md @@ -0,0 +1,8 @@ +# README.md + +To deploy : + +```bash +mipy cp creds.ini +mipy -ir cp main.py +``` \ No newline at end of file diff --git a/wifi/creds.example b/wifi/creds.example new file mode 100644 index 0000000..e69de29 diff --git a/wifi/main.py b/wifi/main.py new file mode 100644 index 0000000..8f87a52 --- /dev/null +++ b/wifi/main.py @@ -0,0 +1,15 @@ +import network + +file = open('creds', 'r') +wifi_ssid = file.readline().rstrip("\n") +wifi_pass = file.readline().rstrip("\n") +file.close() + +wlan = network.WLAN(network.STA_IF) +wlan.active(True) +if not wlan.isconnected(): + print('connecting to network...') + wlan.connect(wifi_ssid, wifi_pass) + while not wlan.isconnected(): + pass +print('network config:', wlan.ifconfig()) \ No newline at end of file