Skip to content

Commit

Permalink
correct the MePS2
Browse files Browse the repository at this point in the history
  • Loading branch information
Makeblock-official committed Sep 19, 2016
1 parent a06abd8 commit 2c543a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions makeblock/src/MePS2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* None
*/
MePS2::MePS2() : MeSerial(0)
{
{
_isReady = false;
_isAvailable = false;
_isStart = false;
Expand All @@ -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();
Expand Down Expand Up @@ -175,7 +175,7 @@ void MePS2::readSerial(void)
* None
*/
boolean MePS2::readjoystick(void)
{
{
if(millis() - _lasttime > 100)
{
_isReady = false;
Expand Down Expand Up @@ -219,7 +219,7 @@ boolean MePS2::readjoystick(void)
return true;
}
else
{
{
_isStart = false;
_index = 0;
return false;
Expand All @@ -244,7 +244,7 @@ boolean MePS2::readjoystick(void)
* None
*/
int MePS2::MeAnalog(uint8_t button)
{
{
if (!_isReady)
{
return (-999);
Expand Down Expand Up @@ -277,7 +277,7 @@ int MePS2::MeAnalog(uint8_t button)
* None
*/
boolean MePS2::ButtonPressed(uint8_t button)
{
{
return ps2_data_list[button];
}

Expand All @@ -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];
Expand Down
16 changes: 8 additions & 8 deletions makeblock/src/MePS2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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,
Expand Down Expand Up @@ -183,7 +183,7 @@
* \par Others
* None
*/
boolean MePS2::readjoystick(void);
boolean readjoystick(void);

/**
* \par Function
Expand All @@ -199,7 +199,7 @@
* \par Others
* None
*/
int MePS2::MeAnalog(uint8_t button);
int16_t MeAnalog(uint8_t button);

/**
* \par Function
Expand All @@ -215,7 +215,7 @@
* \par Others
* None
*/
boolean MePS2::ButtonPressed(uint8_t button);
boolean ButtonPressed(uint8_t button);

/**
* \par Function
Expand All @@ -232,7 +232,7 @@
* None
*/
void MePS2::loop(void);

private:
uint8_t _serialRead;
uint8_t _dataLen;
Expand Down

0 comments on commit 2c543a7

Please sign in to comment.