From 3e5e8480f3f2f0af56731471cc967404efe0c921 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 6 Oct 2021 00:52:14 -0400 Subject: andy cleanup --- Makefile | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..481382a --- /dev/null +++ b/Makefile @@ -0,0 +1,60 @@ +# Optionally some environment variables can be set: +# +# FQBN Fully Qualified Board Name; if not set in the environment +# it will be assigned a value in this makefile +# +# SERIAL_DEV Serial device to upload the sketch; if not set in the +# environment it will be assigned: +# /dev/ttyUSB0 if it exists, or +# /dev/ttyACM0 if it exists, or +# unknown +# +# MDNS_NAME Hostname of the Arduino; if not set in the environment +# it will be assigned a value in this makefile. This is +# needed for OTA update, the device will be searched +# on the local subnet using this name +# +# OTA_PORT Port used by OTA update; if not set in the environment +# it will be assigned the default value of 8266 in this +# makefile +# +# OTA_PASS Password used for OTA update; if not set in the environment +# it will be assigned the default value of an empty string + +PROGNAME = mush + +FQBN = esp8266:esp8266:espmxdevkit +MDNS_NAME = $(PROGNAME) +OTA_PORT = 8266 +OTA_PASS = + +SERIAL_DEV = $(firstword $(wildcard /dev/ttyUSB* /dev/ttyACM*)) + +cli = arduino-cli -b "$(FQBN)" + +BUILD_DIR != $(cli) compile --show-properties | sed -ne 's/^build.path=//p' + +SRC := CCS811.cpp $(PROGNAME).ino +HDRS := CCS811.h ota.h wifiinfo.h +BIN := $(BUILD_DIR)/$(PROGNAME).ino.bin +ELF := $(BUILD_DIR)/$(PROGNAME).ino.elf + +all: $(ELF) +.PHONY: all + +compile: $(ELF) +.PHONY: compile + +$(BIN) $(ELF): $(SRC) $(HDRS) + $(cli) compile --warnings all + +upload: + $(cli) upload -p "$(SERIAL_DEV)" + +PLAT_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.platform.path=//p' +PY_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.tools.python3.path=//p' +MDNS_IP != getent ahostsv4 $(MDNS_NAME).local | (read ip _; echo $$ip) + +ota: $(BIN) + "$(PY_PATH)/python3" "$(PLAT_PATH)/tools/espota.py" -i "$(MDNS_IP)" -p "$(OTA_PORT)" --auth="$(OTA_PASS)" -f "$(BIN)" + -- cgit v1.2.3