#!/bin/bash if [ "$1" == "" ]; then echo "Give one of the targets: build, clean, upload" echo "If you want to use a project directory different" echo "than the current directory, give it as a second" echo "argument." exit 1 fi if [ "$2" != "" ]; then PROJECT_DIR=$2 else PROJECT_DIR=$PWD fi if [ "$1" == "build" ]; then pushd $PROJECT_DIR/libraries/esp8266boilerplate/ConfigGenerator && ./configGen.sh && popd env ARDUINO_SKETCHBOOK_DIR=$PROJECT_DIR arduino-cli compile --fqbn=esp8266:esp8266:nodemcu $PROJECT_DIR/sketch cp sketch/sketch.esp8266.esp8266.nodemcu.* . elif [ "$1" == "clean" ]; then for D in libraries/includes/configuration.h libraries/includes/configuration.cpp sketch/sketch.esp8266.esp8266.nodemcu.bin sketch/sketch.esp8266.esp8266.nodemcu.elf sketch.esp8266.esp8266.nodemcu.bin sketch.esp8266.esp8266.nodemcu.elf; do echo -n "About to delete $D ... " rm $PROJECT_DIR/$D && echo "done" done elif [ "$1" == "upload" ]; then echo "About to upload to device" esptool.py --port /dev/ttyUSB1 write_flash 0 sketch.esp8266.esp8266.nodemcu.bin else echo "Unknown subcommand '$1'" exit 1 fi