Skip to content

Commit 53fbdd5

Browse files
authored
Improvements to Timer Firmware (#9)
Refactored timer.
1 parent 226e1d0 commit 53fbdd5

30 files changed

+667
-336
lines changed

README.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,24 @@ TBC.
2424

2525
### Flashing
2626

27-
1. Install dependencies
27+
1. Flash board with micropython
2828
```bash
29-
pip install -r requirements-dev.txt
29+
cd src/micropython/timer
30+
make reflash
3031
```
3132

32-
2. Set Environment
33-
```bash
34-
export AMPY_PORT=/dev/ttyUSB0
35-
export AMPY_BAUD=115200
36-
```
37-
38-
3. Flash ESP32 with esptool:
39-
```bash
40-
esptool.py --chip esp32 --port $AMPY_PORT --baud 460800 write_flash -z 0x1000 firmware/esp32-20220117-v1.18.bin
41-
```
42-
43-
4. Upload source:
44-
```bash
45-
./upload.sh
46-
```
33+
2. Upload source
34+
```bash
35+
make sync
36+
```
37+
38+
3. Edit wifi config
39+
```
40+
mpremote edit wifi.json
41+
```
42+
43+
```
44+
[
45+
{"ssid": "YOUR_SSID", "key": "WIFI PASSWORD", "mqtt": "mqtt.server.here"}
46+
]
47+
```

build-support/mosquitto

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4+
5+
exec podman run --name mqtt \
6+
--rm \
7+
-v "${SCRIPT_DIR}/mosquitto.conf:/mosquitto/config/mosquitto.conf:z" \
8+
-p 1883:1883 -p 9001:9001 eclipse-mosquitto

build-support/mosquitto.conf

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
listener 1883 0.0.0.0
2+
allow_anonymous true

docs/tenstar-esp32-c3/pinout.jpg

248 KB
Loading
1.59 MB
Binary file not shown.
2.98 MB
Binary file not shown.

pants.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ backend_packages = [
1414
[source]
1515
root_patterns = [
1616
"/src/python",
17-
"/src/micropython",
1817
]
1918

2019
[flake8]
@@ -36,6 +35,8 @@ interpreter_constraints = ["CPython==3.10.*"]
3635
[python-infer]
3736
string_imports = true
3837

38+
[tailor]
39+
ignore_paths = ["src/micropython/**"]
3940

4041
[docker.registries.ghcr]
4142
address = "ghcr.io/xlevus/gymkhana"
@@ -44,4 +45,4 @@ default = true
4445
[docker]
4546
env_vars = [
4647
"DOCKER_HOST",
47-
]
48+
]

shell.nix

+5
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@
77
python310
88
ansible
99
glibcLocales
10+
esptool
11+
mpy-utils
12+
picocom
13+
mpremote
14+
micropython
1015
];
1116
}

src/micropython/BUILD

-1
This file was deleted.

src/micropython/boot.py

-12
This file was deleted.

src/micropython/display/Makefile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PORT := "/dev/ttyACM0"
2+
BAUD := "115200"
3+
4+
.PHONY: repl
5+
6+
repl:
7+
picocom -b $(BAUD) $(PORT)
8+
9+
sync:
10+
mpy-sync --baud $(BAUD) --port $(PORT) --reset .
11+
12+
watch:
13+
mpy-watch --baud $(BAUD) --port $(PORT) --reset .
14+
15+
reset:
16+
mpy-reset --baud $(BAUD) --port $(PORT)
17+
18+
reflash:
19+
esptool.py --chip esp32s3 --port $(PORT) erase_flash
20+
esptool.py --chip esp32s3 --port $(PORT) --baud 460800 write_flash -z 0x0 ../../../firmware/ESP32_GENERIC_S3-20240222-v1.22.2.uf2
21+
mpremote mip install logging
22+
mpremote mip install github:peterhinch/micropython-mqtt

src/micropython/display/net.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import mqtt_as
2+
3+
def configure_mqtt():
4+
import network
5+
import json
6+
7+
wlan = network.WLAN(network.STA_IF)
8+
wlan.active(True)
9+
10+
try:
11+
defined_networks = json.load(open("wifi.json", "r"))
12+
except OSError:
13+
return None
14+
15+
available_networks = {x[0].decode() for x in wlan.scan()}
16+
17+
for row in defined_networks:
18+
if row['ssid'] in available_networks:
19+
print(f"Network: {row['ssid']}")
20+
mqtt_as.config['ssid'] = row['ssid']
21+
mqtt_as.config['wifi_pw'] = row['key']
22+
mqtt_as.config['server'] = row['mqtt']
23+
return

src/micropython/gk/BUILD

-1
This file was deleted.

src/micropython/gk/fsm.py

-42
This file was deleted.

src/micropython/gk/logging.py

-16
This file was deleted.

src/micropython/main.py

-171
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)