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.

exampleAPI.bash 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. # STLcd
  3. # Virtual Serial Port API Example
  4. # Jacob Alexander 2015
  5. if [ $# -eq 0 ]; then
  6. echo "You must specify your virtual serialport. (/dev/ttyACM0 on linux, /dev/cu.usbmodemXXXX on OSX)"
  7. echo " ex: $0 /dev/ttyACM0"
  8. exit 1
  9. fi
  10. # XXX Set this to match your virtual serialport
  11. # TODO Show example for Cygwin/Windows
  12. # For Mac OSX it will be something like /dev/cu.usbmodem1413 (number may differ)
  13. SERIALPORT=$1
  14. # NOTE: Make sure you don't write too quickly to the serial port, it can get overwhelmed by a modern computer
  15. # Generally this just means commands will get ignored
  16. # I'm using 100 ms sleeps here, but much smaller are probably sufficient
  17. # Clear out cli buffer
  18. printf "\r" > $SERIALPORT
  19. # Change backlight color
  20. # 3 16-bit numbers (hex or decimal) Red, Green and Blue
  21. sleep 0.1
  22. printf "lcdColor 0x100 0x2000 0x4000\r" > $SERIALPORT # Light blue
  23. # Change the lcd image
  24. # Arguments:
  25. # - page
  26. # - starting address
  27. # - pixels (1 bit per pixel)
  28. #
  29. # There are 9 total pages of display memory, but only 4 are visable at time (it is possible to scroll though)
  30. # Each page is 128 bits wide (16 bytes)
  31. # See the datasheet for full details http://www.newhavendisplay.com/specs/NHD-C12832A1Z-FSRGB-FBW-3V.pdf
  32. sleep 0.1
  33. printf "lcdDisp 0x0 0x0 0xFF 0x13 0xFF 0x11 0xFF\r" > $SERIALPORT
  34. sleep 0.1
  35. printf "lcdDisp 0x1 0x10 0xFF 0x13 0xFF 0x11 0xFF 0x44\r" > $SERIALPORT
  36. sleep 0.1
  37. printf "lcdDisp 0x2 0x20 0xFF 0x13 0xFF 0x11 0xFF\r" > $SERIALPORT
  38. sleep 0.1
  39. printf "lcdDisp 0x3 0x30 0xFF 0x13 0xFF 0x11 0xFF\r" > $SERIALPORT
  40. # Send command directly to the lcd
  41. # See the datasheet for full details http://www.newhavendisplay.com/specs/NHD-C12832A1Z-FSRGB-FBW-3V.pdf
  42. sleep 0.1
  43. printf "lcdCmd 0xA7\r" > $SERIALPORT # Reverse display (0xA6 is Normal)