TSensorModes /* * Spooler_10-21.c ~ * Alex Jones for team 5105 Buffalo Wings * * Description: a simple unit test for the spooler that Raj has created * * Uses: to test the gear config on the test equipment. * * Dependancies: NONE * * ~licensed under the MIT license included in this repositiory */ #include "JoystickDriver.c" #include "../motors/SetMotor.fn" #include "../controller/GetJoystick.fn" task main() { while(true) { getJoystickSettings(joystick); setMotor(spoolLeft, getJoystick(1, 1, 'y')/1.28); setMotor(spoolRight, getJoystick(1, 1, 'y')/1.28); } }
/** * Get the Z value of the current joystick. * This depends on the mapping of the joystick connected to the current port. * * @param port The USB port for this joystick. */ float GetZ(UINT32 port) { Joystick *stick = getJoystick(port); if (stick == NULL) return 0; return stick->GetZ(); }
/** * Set the channel associated with a specified axis. * * @param port The USB port for this joystick. * @param axis The axis to set the channel for. * @param channel The channel to set the axis to. */ void SetAxisChannel(UINT32 port, AxisType axis, UINT32 channel) { Joystick *stick = getJoystick(port); if (stick == NULL) return; stick->SetAxisChannel((Joystick::AxisType) axis, channel); }
/** * Get the Y value of the joystick. * This depends on the mapping of the joystick connected to the current port. * * @param port The USB port for this joystick. */ float GetY(UINT32 port, JoystickHand hand) { Joystick *stick = getJoystick(port); if (stick == NULL) return 0; return stick->GetY((Joystick::JoystickHand) hand); }
/** * Get the button value for buttons 1 through 12. * * The buttons are returned in a single 16 bit value with one bit representing the state * of each button. The appropriate button is returned as a boolean value. * * @param port The USB port for this joystick. * @param button The button number to be read. * @return The state of the button. **/ bool GetRawButton(UINT32 port, UINT32 button) { Joystick *stick = getJoystick(port); if (stick == NULL) return 0; return stick->GetRawButton(button); }
/** * Get the channel currently associated with the specified axis. * * @param port The USB port for this joystick. * @param axis The axis to look up the channel for. * @return The channel fr the axis. */ UINT32 GetAxisChannel(UINT32 port, AxisType axis) { Joystick *stick = getJoystick(port); if (stick == NULL) return 0; return stick->GetAxisChannel((Joystick::AxisType) axis); }
/** * Get buttons based on an enumerated type. * * The button type will be looked up in the list of buttons and then read. * * @param port The USB port for this joystick. * @param button The type of button to read. * @return The state of the button. */ bool GetButton(UINT32 port, ButtonType button) { Joystick *stick = getJoystick(port); if (stick == NULL) return 0; return stick->GetButton((Joystick::ButtonType) button); }
/** * This is not supported for the Joystick. * This method is only here to complete the GenericHID interface. * * @param port The USB port for this joystick. */ bool GetBumper(UINT32 port, JoystickHand hand) { Joystick *stick = getJoystick(port); if (stick == NULL) return 0; return stick->GetBumper((Joystick::JoystickHand) hand); }
/** * Get the value of the axis. * * @param port The USB port for this joystick. * @param axis The axis to read [1-6]. * @return The value of the axis. */ float GetRawAxis(UINT32 port, UINT32 axis) { Joystick *stick = getJoystick(port); if (stick == NULL) return 0; return stick->GetRawAxis(axis); }
/************************************************************************* Function: main() **************************************************************************/ int main(void){ init_wyvern(); LED_green_on(); LED_ucgreen_on(); char input; menuScreen = 'a'; for( ; ; ){ printMenu(); input = '0'; outgoing.command = input; if(DataInReceiveBuffer()){ input = ReceiveByte(); } getJoystick(); controllerCommand(input); controllerTransmit(); _delay_ms(5); if(incoming.battery < 100){ LED_red_toggle(); LED_ucred_toggle(); LED_blue_toggle(); LED_yellow_toggle(); LED_green_toggle(); } } return 0; }
uintf initJoysticks(void) { uintf numJoysticks = 0; joystick = joystickData; while (numJoysticks<maxJoysticks) { joystick[numJoysticks].Connected = true; getJoystick(numJoysticks); if (!joystick[numJoysticks].Connected) return numJoysticks; else numJoysticks++; } return numJoysticks; }