Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

sizeCalculator 963B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. #| Jacob Alexander 2014
  3. #| Arg List
  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
  8. #| 5 - flash/ram text
  9. case "$2" in
  10. "flash")
  11. USED=$("$1" "$3" | tail -n-1 | awk '{ print $1+$2 }')
  12. ;;
  13. "ram")
  14. USED=$("$1" "$3" | tail -n-1 | awk '{ print $2+$3 }')
  15. ;;
  16. *)
  17. echo "INVALID Measurement type: $2"
  18. exit 1
  19. esac
  20. # Calculates the total flash/ram used
  21. TOTAL="$4"
  22. PERCENTAGE=$((USED * 100 / TOTAL))
  23. # Size Colours
  24. # Red/Flashing - Almost full
  25. if (( PERCENTAGE > 95 )); then
  26. COLOR="\t\033[1;5;31m"
  27. # Red - Getting full
  28. elif (( PERCENTAGE > 90 )); then
  29. COLOR="\t\033[1;31m"
  30. # Yellow - Starting to fill up
  31. elif (( PERCENTAGE > 50 )); then
  32. COLOR="\t\033[1;33m"
  33. # Green - Lots of room
  34. else
  35. COLOR="\t\033[1;32m"
  36. fi
  37. # Displays Results
  38. NAME="$5"
  39. echo -e "\t\033[1m${NAME}\033[m: ${COLOR}${PERCENTAGE}%\033[m \t${USED}/${TOTAL}\tbytes"
  40. exit 0