1. /************ CarControllerPC
  2.  
  3. *PC Side program to send commands over serial to control the RC Car
  4.  
  5. *RC Car controlled by attached arduino contianing code that admits
  6.  serial commands and changes pwm values for pins attached to
  7.  the control tranisistors of the Motor H-Bridges
  8.  
  9. *The arduino is expecting a command of the following sturcture:
  10.  
  11.     -2 Bytes of Data, sent serially.  
  12.  
  13.   | 0 0 0 0 0 0 0 0 | | 0 0 0 0 0 0 0 0 |
  14.      Forward/Back         Left/Right
  15.      
  16.     -'Signed' for determining direction, so the first bit in each byte
  17.      will determine the direction.  
  18.  
  19.     - 1 = Forward/Left  0 = Back/Right
  20.  
  21. ******************************/
  22.  
  23. boolean forward;
  24. boolean back;
  25. boolean left;
  26. boolean right;
  27.  
  28. void setup() {
  29.  
  30.   size(640, 360);
  31.  
  32. }
  33.  
  34.  
  35. void draw() {
  36.    
  37.    
  38.   reactToPressedKeys();
  39.     /*
  40.       -Check the array storing the boolean values for whether or not
  41.        the keys I care about are down (WASD)
  42.       -If they are down, change variables for drawing buttons/display
  43.       -Might have to track the time they have been pressed, or increment a
  44.        counter to see how many cycles its been pressed
  45.            *Will be used to 'ramp up' the speed when W/S are pressed
  46.            *Wont really matter for A/D because the turning motor is hella-fast
  47.     */
  48.   drawButtons();
  49.     /*
  50.       -Draw a WASD diamond
  51.       -If a button is being pressed, change its colors to inversions of its not
  52.        pressed state
  53.     */
  54.   drawDisplay();
  55.     /*
  56.       For Forward/Back (W/S):
  57.         -Draw a slim, vertical rectangle
  58.         -Draw a line in the middle of it ('0-Point')
  59.         -Do some math with "HowLongHaveIBeenDown" (from above) to determine
  60.          the posistion of a line representing the speed of the F/B (W/S) motor
  61.              *Only needs to show 'relative' speed, as in, a % of the max PWM value
  62.       For Left/Right (A/D):
  63.         -Draw a semi circle
  64.         -Draw a point at the 'center' of the semi circle
  65.         -If left, draw a line segment from center to left most semicircle point
  66.         -If right, draw a line segment from center to right most semicircle point
  67.         -If notPressed, draw a line segment from center to center semicircle point
  68.      
  69.      */
  70.      
  71.   //sendCommand();  //for later - once i can push buttons, i'll worry about comm
  72. }
  73.  
  74. void keyPressed() {
  75.   /*
  76.     When a key is pressed, ill check if its one i care about, and if it is, ill set its
  77.     boolean to true.
  78.   */  
  79.   setKeytoPressed(key);
  80. }
  81.  
  82. void keyReleased() {
  83.  /*
  84.     When a key is released, ill check to see if its one i care about, then i'll set its
  85.     boolean to false
  86.  */
  87.  setKeytoNotPressed(key);
  88. }