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 946B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. #| Jacob Alexander 2014
  3. #| Arg List
  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
  8. #| 5 - flash/ram
  9. # Looks for the data column, to get the flash/ram used (in bytes)
  10. # <size binary> --target=<target binary> <binary file> | cut -f2 | tail -n 1
  11. USED=$("$1" --target="$2" "$3" | cut -f2 | tail -n 1)
  12. # Calculates the total flash/ram used
  13. TOTAL="$4"
  14. PERCENTAGE=$((USED * 100 / TOTAL))
  15. # Size Colours
  16. # Red/Flashing - Almost full
  17. if (( PERCENTAGE > 95 )); then
  18. COLOR="\t\033[1;5;31m"
  19. # Red - Getting full
  20. elif (( PERCENTAGE > 90 )); then
  21. COLOR="\t\033[1;31m"
  22. # Yellow - Starting to fill up
  23. elif (( PERCENTAGE > 50 )); then
  24. COLOR="\t\033[1;33m"
  25. # Green - Lots of room
  26. else
  27. COLOR="\t\033[1;32m"
  28. fi
  29. # Displays Results
  30. NAME="$5"
  31. echo -e "\t\033[1m${NAME}\033[m: ${COLOR}${PERCENTAGE}%\033[m ${USED}/${TOTAL}\tbytes"
  32. exit 0