]> vault307.fbx.one Git - m5Atom.git/blob - m5htmlServer.py
m5Atom with LED matrix specific code
[m5Atom.git] / m5htmlServer.py
1 import network, socket, time
2 from neopixel import NeoPixel
3 from machine import Pin
4
5 LED_GPIO = const(27)
6 matrix_size_x = const(5)
7 matrix_size_y = const(5)
8 is_atom_matrix = True
9
10 np = NeoPixel(Pin(LED_GPIO), matrix_size_x * matrix_size_y)
11
12 ssid=[SSID]
13 password=[PASSWORD]
14
15 def connect():
16 wlan=network.WLAN(network.STA_IF)
17 wlan.active(True)
18 wlan.connect(ssid,password)
19 while wlan.isconnected() == False:
20 print('Waiting for connection...')
21 time.sleep(1)
22 ip=wlan.ifconfig()[0]
23 print(f'Connected on {ip}')
24 return ip
25
26 def open_socket(ip):
27 address=(ip,80)
28 connection=socket.socket()
29 connection.bind(address)
30 connection.listen(1)
31 return connection
32
33 def get_html(html_name):
34 with open(html_name, 'r') as file:
35 html=file.read()
36 return html
37
38 def serve(connection):