Added getTemperature()

This commit is contained in:
Kristian Lauszus 2012-06-01 18:47:15 +02:00
parent 053786b125
commit d251a48fb1
4 changed files with 17 additions and 15 deletions

View file

@ -521,6 +521,19 @@ double PS3BT::getAngle(Angle a) {
return angle;
}
}
String PS3BT::getTemperature() {
if(PS3MoveConnected) {
int16_t input = getSensor(tempMove);
String output = String(input/100);
output += ".";
if(input%100 < 10)
output += "0";
output += String(input%100);
return output;
}
}
bool PS3BT::getStatus(Status c)
{
if (l2capinbuf == NULL)

View file

@ -353,6 +353,7 @@ public:
double getAngle(Angle a);
bool getStatus(Status c);
String getStatusString();
String getTemperature();
void disconnect(); // use this void to disconnect any of the controllers
/* HID Commands */

View file

@ -189,21 +189,8 @@ void loop()
Serial.println(PS3.getAngle(Roll));
}
else if(printTemperature) {
String templow;
String temphigh;
String input = String(PS3.getSensor(tempMove));
if (input.length() > 3) {
temphigh = input.substring(0, 2);
templow = input.substring(2);
} else {
temphigh = input.substring(0, 1);
templow = input.substring(1);
}
Serial.print(F("Temperature: "));
Serial.print(temphigh);
Serial.print(F("."));
Serial.println(templow);
Serial.print(F("Temperature: "));
Serial.println(PS3.getTemperature());
}
}
delay(1);

View file

@ -22,6 +22,7 @@ getSensor KEYWORD2
getAngle KEYWORD2
getStatus KEYWORD2
getStatusString KEYWORD2
getTemperature KEYWORD2
disconnect KEYWORD2
setAllOff KEYWORD2