mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Updated getAngle() function
This commit is contained in:
parent
b07aac63e1
commit
053786b125
2 changed files with 5 additions and 18 deletions
21
PS3BT.cpp
21
PS3BT.cpp
|
@ -465,7 +465,7 @@ uint8_t PS3BT::getAnalogHat(AnalogHat a)
|
||||||
return 0;
|
return 0;
|
||||||
return (uint8_t)(l2capinbuf[(uint16_t)a]);
|
return (uint8_t)(l2capinbuf[(uint16_t)a]);
|
||||||
}
|
}
|
||||||
int32_t PS3BT::getSensor(Sensor a)
|
int16_t PS3BT::getSensor(Sensor a)
|
||||||
{
|
{
|
||||||
if (l2capinbuf == NULL)
|
if (l2capinbuf == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -505,22 +505,9 @@ double PS3BT::getAngle(Angle a) {
|
||||||
} else if(PS3MoveConnected) {
|
} else if(PS3MoveConnected) {
|
||||||
// It's a Kionix KXSC4 inside the Motion controller
|
// It's a Kionix KXSC4 inside the Motion controller
|
||||||
const uint16_t zeroG = 0x8000;
|
const uint16_t zeroG = 0x8000;
|
||||||
accXval = getSensor(aXmove);
|
accXval = -(int16_t)(getSensor(aXmove)-zeroG);
|
||||||
accYval = getSensor(aYmove);
|
accYval = (int16_t)(getSensor(aYmove)-zeroG);
|
||||||
accZval = getSensor(aZmove);
|
accZval = (int16_t)(getSensor(aZmove)-zeroG);
|
||||||
|
|
||||||
if(accXval < 0)
|
|
||||||
accXval += zeroG;
|
|
||||||
else
|
|
||||||
accXval -= zeroG;
|
|
||||||
if(accYval < 0)
|
|
||||||
accYval += zeroG;
|
|
||||||
else
|
|
||||||
accYval -= zeroG;
|
|
||||||
if(accZval < 0)
|
|
||||||
accZval += zeroG;
|
|
||||||
else
|
|
||||||
accZval -= zeroG;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to 360 degrees resolution
|
// Convert to 360 degrees resolution
|
||||||
|
|
2
PS3BT.h
2
PS3BT.h
|
@ -349,7 +349,7 @@ public:
|
||||||
bool getButton(Button b);
|
bool getButton(Button b);
|
||||||
uint8_t getAnalogButton(AnalogButton a);
|
uint8_t getAnalogButton(AnalogButton a);
|
||||||
uint8_t getAnalogHat(AnalogHat a);
|
uint8_t getAnalogHat(AnalogHat a);
|
||||||
int32_t getSensor(Sensor a);
|
int16_t getSensor(Sensor a);
|
||||||
double getAngle(Angle a);
|
double getAngle(Angle a);
|
||||||
bool getStatus(Status c);
|
bool getStatus(Status c);
|
||||||
String getStatusString();
|
String getStatusString();
|
||||||
|
|
Loading…
Reference in a new issue