napoleon leoni / joystickAppBoard
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers joystickAppBoard.h Source File

joystickAppBoard.h

00001 //joystickAppBoard class
00002 //Written by Napoleon Leoni; February 2014
00003 //Simple class object to handle joystick state for the mbed application board
00004 //5 way Joystick    ALPS SKRHADE010
00005 //Down:p12; Left:p13 Centre:p14 Up:p15 Right:p16
00006 
00007 #include "mbed.h"
00008 #include <BusIn.h>
00009 
00010 #ifndef JOYAPPPCB
00011 #define JOYAPPPCB
00012 // Joystick state definitions
00013 #define JOYSTICKDOWN    0x01            //0b00001  d1
00014 #define JOYSTICKLEFT    0x02            //0b00010  d2 
00015 #define JOYSTICKCENTER  0x04            //0b00100  d4
00016 #define JOYSTICKUP      0x08            //0b01000  d8
00017 #define JOYSTICKRIGHT   0x10            //0b10000  d16
00018 
00019 //***************************** TESTING ********************************************************//
00020 //  TEST        TEST DESCRIPTION                                                STATUS          //
00021 //  1           getJoystickState yields the right hex value as shown above      PASS            //
00022 //  2           Joystick posistion (up, down center, leff, right) are all       PASS            //
00023 //              properly identified when the Joystick is actuated                               //
00024 //**********************************************************************************************//
00025 
00026 class joystickAppBoard{
00027   //members    
00028   private:
00029   BusIn *joystickPins;//this will be defined using all 5 pins fo joystick Busin(12,13,14,15,16)
00030   int joystickState;
00031   //methods
00032   
00033   public:
00034   joystickAppBoard();
00035   void readJoystick();
00036   int getJoystickState(void);
00037   bool isJoystickUp();
00038   bool isJoystickDown();
00039   bool isJoystickLeft();
00040   bool isJoystickRight();
00041   bool isJoystickCenter();
00042       
00043 };
00044 
00045 #endif