/************ CarControllerPC *PC Side program to send commands over serial to control the RC Car *RC Car controlled by attached arduino contianing code that admits serial commands and changes pwm values for pins attached to the control tranisistors of the Motor H-Bridges *The arduino is expecting a command of the following sturcture: -2 Bytes of Data, sent serially. | 0 0 0 0 0 0 0 0 | | 0 0 0 0 0 0 0 0 | Forward/Back Left/Right -'Signed' for determining direction, so the first bit in each byte will determine the direction. - 1 = Forward/Left 0 = Back/Right ******************************/ boolean forward; boolean back; boolean left; boolean right; void setup() { size(640, 360); } void draw() { reactToPressedKeys(); /* -Check the array storing the boolean values for whether or not the keys I care about are down (WASD) -If they are down, change variables for drawing buttons/display -Might have to track the time they have been pressed, or increment a counter to see how many cycles its been pressed *Will be used to 'ramp up' the speed when W/S are pressed *Wont really matter for A/D because the turning motor is hella-fast */ drawButtons(); /* -Draw a WASD diamond -If a button is being pressed, change its colors to inversions of its not pressed state */ drawDisplay(); /* For Forward/Back (W/S): -Draw a slim, vertical rectangle -Draw a line in the middle of it ('0-Point') -Do some math with "HowLongHaveIBeenDown" (from above) to determine the posistion of a line representing the speed of the F/B (W/S) motor *Only needs to show 'relative' speed, as in, a % of the max PWM value For Left/Right (A/D): -Draw a semi circle -Draw a point at the 'center' of the semi circle -If left, draw a line segment from center to left most semicircle point -If right, draw a line segment from center to right most semicircle point -If notPressed, draw a line segment from center to center semicircle point */ //sendCommand(); //for later - once i can push buttons, i'll worry about comm } void keyPressed() { /* When a key is pressed, ill check if its one i care about, and if it is, ill set its boolean to true. */ setKeytoPressed(key); } void keyReleased() { /* When a key is released, ill check to see if its one i care about, then i'll set its boolean to false */ setKeytoNotPressed(key); }