VENV = poetry run ESP_TOOL = $(VENV) esptool.py MPYCROSS = $(VENV) mpy-cross AMPY = $(VENV) ampy # Downloaded from https://micropython.org/download/ESP8266_GENERIC/ MICRO_PYTHON_FIRMWARE = ESP8266_GENERIC-20240222-v1.22.2.bin ESP_PORT = /dev/ttyUSB0 src/%.mpy: src/%.py @for f in $(filter-out src/main.py,$?); do \ echo Compile $$f; \ $(MPYCROSS) $$f; \ done check: src/*.mpy $(VENV) python3 -m py_compile src/*.py erase_flash: $(ESP_TOOL) --port $(ESP_PORT) erase_flash flash_esp: erase_flash $(ESP_TOOL) --port $(ESP_PORT) --baud 460800 write_flash --flash_size=detect 0 $(MICRO_PYTHON_FIRMWARE) install: check src/*.mpy $(AMPY) --port $(ESP_PORT) put src/main.py @for f in $(filter-out check,$?); do \ echo Uploading $$f; \ $(AMPY) --port $(ESP_PORT) put $$f; \ done uninstall: @echo $(filter-out /boot.py,$(shell $(AMPY) --port $(ESP_PORT) ls)) @for f in $(filter-out /boot.py,$(shell $(AMPY) --port $(ESP_PORT) ls)); do \ echo Deleting $$f; \ $(AMPY) --port $(ESP_PORT) rm $$f; \ done clean: rm -rf src/__pycache__ rm -f src/*.pyc rm -f src/*.mpy