Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

Commit

Permalink
Added progress indicator to upload script
Browse files Browse the repository at this point in the history
  • Loading branch information
cmpadden committed Jul 1, 2019
1 parent 743fff0 commit 86290d0
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions bin/upload
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,44 @@ if [ "$(basename "$PWD")" = "bin" ]; then
cd .. || exit
fi

###############################################################################
# Helper Functions #
###############################################################################

# Display a spinning icon while the process specified by pid argument $1 is
# running, with an optional message $2
display_spinner()
{
pid="$1"
message="$2"

i=0
spin='-\|/'
while kill -0 "$pid" 2>/dev/null
do
i=$(( (i+1) %4 ))
printf "\r[%s] %s" "${spin:$i:1}" "$message"
sleep .1
done
printf "\r[*] %s\n" "$message"
}

###############################################################################
# MicroPython Flash #
###############################################################################

esptool.py --port $port erase_flash 1>/dev/null &
display_spinner $! "Erasing ESP32 Flash Storage"

echo "Erasing ESP32 Flash Storage"
esptool.py --port $port erase_flash 1>/dev/null

echo "Flashing Micropython Binary"
esptool.py --chip esp32 \
--port $port \
--baud 460800 \
write_flash \
--compress \
--flash_mode dio \
--flash_freq 40m 0x1000 bin/build/esp32-v1.10-194-g41e7ad6.bin \
1>/dev/null
1>/dev/null &
display_spinner $! "Flashing Micropython Binary"


###############################################################################
Expand All @@ -40,14 +60,14 @@ esptool.py --chip esp32 \
# Create directories (excluding hidden files using the `-not` switch)
echo "Creating Directories"
for dir in $(find . -not -path '*/\.*' -type d \( ! -iname ".*" \)); do
echo " > ${dir}"
echo " ${dir}"
ampy -d 0.5 --port $port mkdir "$dir"
done

# Copy all Python files
echo "Copying Python Files..."
for file in $(find . -name \*.py); do
echo " > ${file}"
echo " ${file}"
ampy -d 0.5 --port $port put "$file" "$file"
done

Expand Down

0 comments on commit 86290d0

Please sign in to comment.