
# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# install avrdude
brew install avrdude

# get upload port
FDS_ALTI_UPLOAD_PORT="$(find /dev/cu.usbmodem* | head -n 1)"

# reset 
stty -f "${FDS_ALTI_UPLOAD_PORT}" 1200

# wait for it...
while :; do
  sleep 0.5
  [ -c "${FDS_ALTI_UPLOAD_PORT}" ] && break
done

# overwrite firmware
avrdude -C $(pwd)/Desktop/avrdude.conf -v -patmega32u4 -cavr109 -P${FDS_ALTI_UPLOAD_PORT} -b57600 -D -U flash:w:$(pwd)/Desktop/SonoAlti_1.5.hex:i 

