diff --git a/makeblock/src/MePS2.cpp b/makeblock/src/MePS2.cpp index a7e8a807..d8f66694 100644 --- a/makeblock/src/MePS2.cpp +++ b/makeblock/src/MePS2.cpp @@ -54,7 +54,7 @@ * None */ MePS2::MePS2() : MeSerial(0) -{ +{ _isReady = false; _isAvailable = false; _isStart = false; @@ -69,7 +69,7 @@ MePS2::MePS2() : MeSerial(0) */ MePS2::MePS2(uint8_t port) : MeSerial(port) { - _isReady = false; + _isReady = false; _isAvailable = false; _isStart = false; _lasttime = millis(); @@ -175,7 +175,7 @@ void MePS2::readSerial(void) * None */ boolean MePS2::readjoystick(void) -{ +{ if(millis() - _lasttime > 100) { _isReady = false; @@ -219,7 +219,7 @@ boolean MePS2::readjoystick(void) return true; } else - { + { _isStart = false; _index = 0; return false; @@ -244,7 +244,7 @@ boolean MePS2::readjoystick(void) * None */ int MePS2::MeAnalog(uint8_t button) -{ +{ if (!_isReady) { return (-999); @@ -277,7 +277,7 @@ int MePS2::MeAnalog(uint8_t button) * None */ boolean MePS2::ButtonPressed(uint8_t button) -{ +{ return ps2_data_list[button]; } @@ -298,7 +298,7 @@ boolean MePS2::ButtonPressed(uint8_t button) void MePS2::loop(void) { if (readjoystick() ) - { + { ps2_data_list[MePS2_LX] = buffer[2]; ps2_data_list[MePS2_LY] = buffer[4]; ps2_data_list[MePS2_RX] = buffer[6]; diff --git a/makeblock/src/MePS2.h b/makeblock/src/MePS2.h index 60bebf59..b22813a0 100644 --- a/makeblock/src/MePS2.h +++ b/makeblock/src/MePS2.h @@ -53,7 +53,7 @@ #include "MePort.h" #endif -#define MePS2_RX 6 +#define MePS2_RX 6 #define MePS2_RY 8 #define MePS2_LX 2 #define MePS2_LY 4 @@ -83,9 +83,9 @@ */ #ifndef ME_PORT_DEFINED class MePS2 -#else /* !ME_PORT_DEFINED */ +#else /* !ME_PORT_DEFINED */ class MePS2 : public MeSerial -#endif /* !ME_PORT_DEFINED */ +#endif /* !ME_PORT_DEFINED */ { public: @@ -106,7 +106,7 @@ * port - RJ25 port from PORT_1 to M2 */ MePS2(uint8_t port); -#else // ME_PORT_DEFINED +#else // ME_PORT_DEFINED /** * Alternate Constructor which can call your own function to map the MePS2 to arduino port, @@ -183,7 +183,7 @@ * \par Others * None */ - boolean MePS2::readjoystick(void); + boolean readjoystick(void); /** * \par Function @@ -199,7 +199,7 @@ * \par Others * None */ - int MePS2::MeAnalog(uint8_t button); + int16_t MeAnalog(uint8_t button); /** * \par Function @@ -215,7 +215,7 @@ * \par Others * None */ - boolean MePS2::ButtonPressed(uint8_t button); + boolean ButtonPressed(uint8_t button); /** * \par Function @@ -232,7 +232,7 @@ * None */ void MePS2::loop(void); - + private: uint8_t _serialRead; uint8_t _dataLen;