diff --git a/PS3BT.cpp b/PS3BT.cpp index a694eec4..d23adb76 100644 --- a/PS3BT.cpp +++ b/PS3BT.cpp @@ -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) diff --git a/PS3BT.h b/PS3BT.h index 618747ec..ae038dad 100644 --- a/PS3BT.h +++ b/PS3BT.h @@ -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 */ diff --git a/examples/PS3/PS3BT/PS3BT.ino b/examples/PS3/PS3BT/PS3BT.ino index 74d911f9..122d984a 100644 --- a/examples/PS3/PS3BT/PS3BT.ino +++ b/examples/PS3/PS3BT/PS3BT.ino @@ -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); diff --git a/keywords.txt b/keywords.txt index 20afc467..de987ded 100644 --- a/keywords.txt +++ b/keywords.txt @@ -22,6 +22,7 @@ getSensor KEYWORD2 getAngle KEYWORD2 getStatus KEYWORD2 getStatusString KEYWORD2 +getTemperature KEYWORD2 disconnect KEYWORD2 setAllOff KEYWORD2