2 #| Jacob Alexander 2014
4 #| 1 - size binary (e.g. avr-size)
5 #| 2 - target binary (e.g. ihex)
6 #| 3 - binary file (e.g. kiibohd.hex)
7 #| 4 - total available (flash/ram) in bytes
11 # Looks for the data column, to get the flash/ram used (in bytes)
12 # <size binary> --target=<target binary> <binary file> | cut -f2 | tail -n 1
13 USED=$("$1" --target="$2" "$3" | cut -f2 | tail -n 1)
15 # Calculates the total flash/ram used
17 PERCENTAGE=$((USED * 100 / TOTAL))
20 # Red/Flashing - Almost full
21 if (( PERCENTAGE > 95 )); then
22 COLOR="\t\033[1;5;31m"
24 elif (( PERCENTAGE > 90 )); then
27 # Yellow - Starting to fill up
28 elif (( PERCENTAGE > 50 )); then
31 # Green - Lots of room
38 echo -e "\t\033[1m${NAME}\033[m: ${COLOR}${PERCENTAGE}%\033[m ${USED}/${TOTAL}\tbytes"