#include "Main.h" void OperatorControl ( void ) { char rampstop; unsigned char joystick_y; unsigned char rampstopturn; unsigned char joystick_x; while ( 1==1 ) { joystick_y = GetOIAInput ( 1 , 2 ) ; joystick_x = GetOIAInput ( 1 , 1 ) ; if ( rampstop==1 ) { ramp ( joystick_y ) ; } else if ( joystick_x>127 || joystick_x<127 ) { turnramp ( joystick_x ) ; } else { drive ( joystick_y, joystick_x ) ; } if ( joystick_y == 127 ) { rampstop = 1 ; } else { rampstop = 0 ; } } #include "Main.h" void drive ( unsigned char joystick_y, unsigned char joystick_x ) { if ( joystick_y!=127 ) { SetPWM ( 1 , joystick_y ) ; SetPWM ( 2 , joystick_y ) ; } else if ( joystick_x!= 127&&joystick_x<127 ) { SetPWM ( 1 , 127 ) ; SetPWM ( 2 , joystick_x ) ; } else if ( joystick_x !=127&&joystick_x>127 ) { SetPWM ( 1 , joystick_x ) ; SetPWM ( 2 , 127 ) ; } else { SetPWM ( 1 , 127 ) ; SetPWM ( 2 , 127 ) ; } } } #include "Main.h" void ramp ( unsigned char joystick_y ) { int rampup; unsigned int rampspeed; if ( joystick_y>126 && joystick_y<128 ) { SetPWM ( 1 , 127 ) ; SetPWM ( 2 , 127 ) ; } if ( joystick_y>127 ) { rampspeed = 127 ; for ( rampup = 0 ; rampup<=joystick_y ; rampup=rampup+20 ) { SetPWM ( 1 , rampspeed+=30 ) ; SetPWM ( 2 , rampspeed+=30 ) ; } } else if ( joystick_y<127 ) { rampspeed = 127 ; for ( rampup = 0 ; rampup>=joystick_y ; rampup = rampup-20 ) { SetPWM ( 1 , rampspeed-=30 ) ; SetPWM ( 2 , rampspeed-=30 ) ; } } } #include "Main.h" void turnramp ( unsigned char joystick_x ) { int rampup; unsigned int rampspeed; if ( joystick_x>127 ) { rampspeed = 127 ; for ( rampup = 0 ; rampup<=joystick_x ; rampup++ ) { SetPWM ( 1 , rampspeed+=10 ) ; SetPWM ( 2 , rampspeed+=10 ) ; } } else if ( joystick_x<127 ) { rampspeed = 127 ; for ( rampup = 0 ; rampup>=joystick_x ; rampup -- ) { SetPWM ( 1 , rampspeed-=10 ) ; SetPWM ( 2 , rampspeed-=10 ) ; } } }