Mac OS X ambilight
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.

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. # The serialHelper115200 file is my own SerialHelper Utility compiled
  3. # with 115200 baud. Get it from here:
  4. # https://github.com/xythobuz/SerialHelper
  5. DATA_FILE=led_data_file
  6. if [ $# -ne 3 ]; then
  7. echo "Usage: three hex bytes for color"
  8. echo "$0 rr gg bb"
  9. exit
  10. fi
  11. PORTFILE=`ls /dev/tty.wchusbserial* | head -n 1`
  12. echo "Using $PORTFILE as serial port..."
  13. echo "Preparing data to send..."
  14. echo -n "xythobuzRGBled" > $DATA_FILE
  15. for i in {1..156}; do
  16. echo -n -e "\x$1\x$2\x$3" >> $DATA_FILE
  17. done
  18. echo "Opening serial port..."
  19. serialHelper115200 -rw $PORTFILE >/dev/null 2>/dev/null &
  20. TERM_PID=$!
  21. echo "PID is $TERM_PID"
  22. echo "Waiting for Arduino to be ready..."
  23. sleep 3
  24. echo "Sending data..."
  25. cat $DATA_FILE > $PORTFILE
  26. echo "Waiting for data to appear..."
  27. sleep 1
  28. echo "Closing serial port..."
  29. kill $TERM_PID
  30. echo "Deleting created data file..."
  31. rm -rf $DATA_FILE