Renamed getStatusString() to printStatusString()

This commit is contained in:
Kristian Lauszus 2014-01-04 14:14:22 +01:00
parent 257c96f5c1
commit 1f33f2bd08
9 changed files with 40 additions and 55 deletions

View file

@ -160,18 +160,17 @@ bool PS3BT::getStatus(StatusEnum c) {
return (l2capinbuf[(uint16_t)c >> 8] == ((uint8_t)c & 0xff)); return (l2capinbuf[(uint16_t)c >> 8] == ((uint8_t)c & 0xff));
} }
String PS3BT::getStatusString() { void PS3BT::printStatusString() {
char statusOutput[100]; // Max string length plus null character
if(PS3Connected || PS3NavigationConnected) { if(PS3Connected || PS3NavigationConnected) {
char statusOutput[100]; // Max string length plus null character
strcpy_P(statusOutput, PSTR("ConnectionStatus: ")); strcpy_P(statusOutput, PSTR("ConnectionStatus: "));
if(getStatus(Plugged)) strcat_P(statusOutput, PSTR("Plugged")); if(getStatus(Plugged)) strcat_P(statusOutput, PSTR("Plugged"));
else if(getStatus(Unplugged)) strcat_P(statusOutput, PSTR("Unplugged")); else if(getStatus(Unplugged)) strcat_P(statusOutput, PSTR("Unplugged"));
else strcat_P(statusOutput, PSTR("Error")); else strcat_P(statusOutput, PSTR("Error"));
strcat_P(statusOutput, PSTR(" - PowerRating: ")); strcat_P(statusOutput, PSTR(" - PowerRating: "));
if(getStatus(Charging)) strcat_P(statusOutput, PSTR("Charging")); if(getStatus(Charging)) strcat_P(statusOutput, PSTR("Charging"));
else if(getStatus(NotCharging)) strcat_P(statusOutput, PSTR("Not Charging")); else if(getStatus(NotCharging)) strcat_P(statusOutput, PSTR("Not Charging"));
else if(getStatus(Shutdown)) strcat_P(statusOutput, PSTR("Shutdown")); else if(getStatus(Shutdown)) strcat_P(statusOutput, PSTR("Shutdown"));
@ -188,12 +187,7 @@ String PS3BT::getStatusString() {
else if(getStatus(BluetoothRumble)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is on")); else if(getStatus(BluetoothRumble)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is on"));
else if(getStatus(Bluetooth)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is off")); else if(getStatus(Bluetooth)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is off"));
else strcat_P(statusOutput, PSTR("Error")); else strcat_P(statusOutput, PSTR("Error"));
return statusOutput;
} else if(PS3MoveConnected) { } else if(PS3MoveConnected) {
char statusOutput[26]; // Max string length plus null character
strcpy_P(statusOutput, PSTR("PowerRating: ")); strcpy_P(statusOutput, PSTR("PowerRating: "));
if(getStatus(MoveCharging)) strcat_P(statusOutput, PSTR("Charging")); if(getStatus(MoveCharging)) strcat_P(statusOutput, PSTR("Charging"));
@ -204,10 +198,10 @@ String PS3BT::getStatusString() {
else if(getStatus(MoveHigh)) strcat_P(statusOutput, PSTR("High")); else if(getStatus(MoveHigh)) strcat_P(statusOutput, PSTR("High"));
else if(getStatus(MoveFull)) strcat_P(statusOutput, PSTR("Full")); else if(getStatus(MoveFull)) strcat_P(statusOutput, PSTR("Full"));
else strcat_P(statusOutput, PSTR("Error")); else strcat_P(statusOutput, PSTR("Error"));
return statusOutput;
} else } else
return "Error"; strcpy_P(statusOutput, PSTR("Error"));
USB_HOST_SERIAL.write((uint8_t*)statusOutput, strlen(statusOutput));
} }
void PS3BT::Reset() { void PS3BT::Reset() {

View file

@ -111,11 +111,8 @@ public:
* @return True if correct and false if not. * @return True if correct and false if not.
*/ */
bool getStatus(StatusEnum c); bool getStatus(StatusEnum c);
/** /** Read all the available statuses from the controller and prints it as a nice formated string. */
* Read all the available ::StatusEnum from the controller. void printStatusString();
* @return One large string with all the information.
*/
String getStatusString();
/** /**
* Read the temperature from the Move controller. * Read the temperature from the Move controller.
* @return The temperature in degrees Celsius. * @return The temperature in degrees Celsius.

View file

@ -362,39 +362,37 @@ bool PS3USB::getStatus(StatusEnum c) {
return (readBuf[((uint16_t)c >> 8) - 9] == ((uint8_t)c & 0xff)); return (readBuf[((uint16_t)c >> 8) - 9] == ((uint8_t)c & 0xff));
} }
String PS3USB::getStatusString() { void PS3USB::printStatusString() {
char statusOutput[100]; // Max string length plus null character
if(PS3Connected || PS3NavigationConnected) { if(PS3Connected || PS3NavigationConnected) {
char statusOutput[100]; strcpy_P(statusOutput, PSTR("ConnectionStatus: "));
strcpy(statusOutput, "ConnectionStatus: "); if(getStatus(Plugged)) strcat_P(statusOutput, PSTR("Plugged"));
else if(getStatus(Unplugged)) strcat_P(statusOutput, PSTR("Unplugged"));
else strcat_P(statusOutput, PSTR("Error"));
if(getStatus(Plugged)) strcat(statusOutput, "Plugged"); strcat_P(statusOutput, PSTR(" - PowerRating: "));
else if(getStatus(Unplugged)) strcat(statusOutput, "Unplugged");
else strcat(statusOutput, "Error");
if(getStatus(Charging)) strcat_P(statusOutput, PSTR("Charging"));
else if(getStatus(NotCharging)) strcat_P(statusOutput, PSTR("Not Charging"));
else if(getStatus(Shutdown)) strcat_P(statusOutput, PSTR("Shutdown"));
else if(getStatus(Dying)) strcat_P(statusOutput, PSTR("Dying"));
else if(getStatus(Low)) strcat_P(statusOutput, PSTR("Low"));
else if(getStatus(High)) strcat_P(statusOutput, PSTR("High"));
else if(getStatus(Full)) strcat_P(statusOutput, PSTR("Full"));
else strcat_P(statusOutput, PSTR("Error"));
strcat(statusOutput, " - PowerRating: "); strcat_P(statusOutput, PSTR(" - WirelessStatus: "));
if(getStatus(Charging)) strcat(statusOutput, "Charging"); if(getStatus(CableRumble)) strcat_P(statusOutput, PSTR("Cable - Rumble is on"));
else if(getStatus(NotCharging)) strcat(statusOutput, "Not Charging"); else if(getStatus(Cable)) strcat_P(statusOutput, PSTR("Cable - Rumble is off"));
else if(getStatus(Shutdown)) strcat(statusOutput, "Shutdown"); else if(getStatus(BluetoothRumble)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is on"));
else if(getStatus(Dying)) strcat(statusOutput, "Dying"); else if(getStatus(Bluetooth)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is off"));
else if(getStatus(Low)) strcat(statusOutput, "Low"); else strcat_P(statusOutput, PSTR("Error"));
else if(getStatus(High)) strcat(statusOutput, "High");
else if(getStatus(Full)) strcat(statusOutput, "Full");
else strcat(statusOutput, "Error");
strcat(statusOutput, " - WirelessStatus: ");
if(getStatus(CableRumble)) strcat(statusOutput, "Cable - Rumble is on");
else if(getStatus(Cable)) strcat(statusOutput, "Cable - Rumble is off");
else if(getStatus(BluetoothRumble)) strcat(statusOutput, "Bluetooth - Rumble is on");
else if(getStatus(Bluetooth)) strcat(statusOutput, "Bluetooth - Rumble is off");
else strcat(statusOutput, "Error");
return statusOutput;
} else } else
return "Error"; strcpy_P(statusOutput, PSTR("Error"));
USB_HOST_SERIAL.write((uint8_t*)statusOutput, strlen(statusOutput));
} }
/* Playstation Sixaxis Dualshock and Navigation Controller commands */ /* Playstation Sixaxis Dualshock and Navigation Controller commands */

View file

@ -193,11 +193,8 @@ public:
* @return True if correct and false if not. * @return True if correct and false if not.
*/ */
bool getStatus(StatusEnum c); bool getStatus(StatusEnum c);
/** /** Read all the available statuses from the controller and prints it as a nice formated string. */
* Read all the available ::StatusEnum from the controller. void printStatusString();
* @return One large string with all the information.
*/
String getStatusString();
/** Used to set all LEDs and rumble off. */ /** Used to set all LEDs and rumble off. */
void setAllOff(); void setAllOff();

View file

@ -111,7 +111,7 @@ void loop() {
if (PS3.getButtonClick(SELECT)) { if (PS3.getButtonClick(SELECT)) {
Serial.print(F("\r\nSelect - ")); Serial.print(F("\r\nSelect - "));
Serial.print(PS3.getStatusString()); PS3.printStatusString();
} }
if (PS3.getButtonClick(START)) { if (PS3.getButtonClick(START)) {
Serial.print(F("\r\nStart")); Serial.print(F("\r\nStart"));
@ -163,7 +163,7 @@ void loop() {
PS3.moveSetBulb(Off); PS3.moveSetBulb(Off);
Serial.print(F("\r\nMove")); Serial.print(F("\r\nMove"));
Serial.print(F(" - ")); Serial.print(F(" - "));
Serial.print(PS3.getStatusString()); PS3.printStatusString();
} }
} }
if (printAngle) { if (printAngle) {

View file

@ -116,7 +116,7 @@ void loop() {
if (PS3[i]->getButtonClick(SELECT)) { if (PS3[i]->getButtonClick(SELECT)) {
Serial.print(F("\r\nSelect - ")); Serial.print(F("\r\nSelect - "));
Serial.print(PS3[i]->getStatusString()); PS3[i]->printStatusString();
} }
if (PS3[i]->getButtonClick(START)) { if (PS3[i]->getButtonClick(START)) {
Serial.print(F("\r\nStart")); Serial.print(F("\r\nStart"));

View file

@ -141,8 +141,7 @@ void loop() {
output += " - R3"; output += " - R3";
if (PS3.getButtonClick(SELECT)) { if (PS3.getButtonClick(SELECT)) {
output += " - Select - "; output += " - Select";
output += PS3.getStatusString();
} }
if (PS3.getButtonClick(START)) if (PS3.getButtonClick(START))
output += " - Start"; output += " - Start";

View file

@ -96,7 +96,7 @@ void loop() {
if (PS3.getButtonClick(SELECT)) { if (PS3.getButtonClick(SELECT)) {
Serial.print(F("\r\nSelect - ")); Serial.print(F("\r\nSelect - "));
Serial.print(PS3.getStatusString()); PS3.printStatusString();
} }
if (PS3.getButtonClick(START)) { if (PS3.getButtonClick(START)) {
Serial.print(F("\r\nStart")); Serial.print(F("\r\nStart"));

View file

@ -52,7 +52,7 @@ getSensor KEYWORD2
getAngle KEYWORD2 getAngle KEYWORD2
get9DOFValues KEYWORD2 get9DOFValues KEYWORD2
getStatus KEYWORD2 getStatus KEYWORD2
getStatusString KEYWORD2 printStatusString KEYWORD2
getTemperature KEYWORD2 getTemperature KEYWORD2
disconnect KEYWORD2 disconnect KEYWORD2