2 #| Jacob Alexander 2014
4 #| 1 - size binary (e.g. avr-size)
5 #| 2 - measurement type (flash or ram)
6 #| 3 - binary file (e.g. kiibohd.hex)
7 #| 4 - total available (flash/ram) in bytes
13 USED=$("$1" "$3" | tail -n-1 | awk '{ print $1+$2 }')
16 USED=$("$1" "$3" | tail -n-1 | awk '{ print $2+$3 }')
19 echo "INVALID Measurement type: $2"
24 # Calculates the total flash/ram used
26 PERCENTAGE=$((USED * 100 / TOTAL))
29 # Red/Flashing - Almost full
30 if (( PERCENTAGE > 95 )); then
31 COLOR="\t\033[1;5;31m"
33 elif (( PERCENTAGE > 90 )); then
36 # Yellow - Starting to fill up
37 elif (( PERCENTAGE > 50 )); then
40 # Green - Lots of room
47 echo -e "\t\033[1m${NAME}\033[m: ${COLOR}${PERCENTAGE}%\033[m \t${USED}/${TOTAL}\tbytes"