mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Renamed getStatusString() to printStatusString()
This commit is contained in:
parent
257c96f5c1
commit
1f33f2bd08
9 changed files with 40 additions and 55 deletions
18
PS3BT.cpp
18
PS3BT.cpp
|
@ -160,18 +160,17 @@ bool PS3BT::getStatus(StatusEnum c) {
|
|||
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) {
|
||||
char statusOutput[100]; // Max string length plus null character
|
||||
|
||||
strcpy_P(statusOutput, PSTR("ConnectionStatus: "));
|
||||
|
||||
if(getStatus(Plugged)) strcat_P(statusOutput, PSTR("Plugged"));
|
||||
else if(getStatus(Unplugged)) strcat_P(statusOutput, PSTR("Unplugged"));
|
||||
else strcat_P(statusOutput, PSTR("Error"));
|
||||
|
||||
|
||||
strcat_P(statusOutput, PSTR(" - PowerRating: "));
|
||||
|
||||
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"));
|
||||
|
@ -188,12 +187,7 @@ String PS3BT::getStatusString() {
|
|||
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 strcat_P(statusOutput, PSTR("Error"));
|
||||
|
||||
return statusOutput;
|
||||
|
||||
} else if(PS3MoveConnected) {
|
||||
char statusOutput[26]; // Max string length plus null character
|
||||
|
||||
strcpy_P(statusOutput, PSTR("PowerRating: "));
|
||||
|
||||
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(MoveFull)) strcat_P(statusOutput, PSTR("Full"));
|
||||
else strcat_P(statusOutput, PSTR("Error"));
|
||||
|
||||
return statusOutput;
|
||||
} else
|
||||
return "Error";
|
||||
strcpy_P(statusOutput, PSTR("Error"));
|
||||
|
||||
USB_HOST_SERIAL.write((uint8_t*)statusOutput, strlen(statusOutput));
|
||||
}
|
||||
|
||||
void PS3BT::Reset() {
|
||||
|
|
7
PS3BT.h
7
PS3BT.h
|
@ -111,11 +111,8 @@ public:
|
|||
* @return True if correct and false if not.
|
||||
*/
|
||||
bool getStatus(StatusEnum c);
|
||||
/**
|
||||
* Read all the available ::StatusEnum from the controller.
|
||||
* @return One large string with all the information.
|
||||
*/
|
||||
String getStatusString();
|
||||
/** Read all the available statuses from the controller and prints it as a nice formated string. */
|
||||
void printStatusString();
|
||||
/**
|
||||
* Read the temperature from the Move controller.
|
||||
* @return The temperature in degrees Celsius.
|
||||
|
|
50
PS3USB.cpp
50
PS3USB.cpp
|
@ -362,39 +362,37 @@ bool PS3USB::getStatus(StatusEnum c) {
|
|||
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) {
|
||||
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");
|
||||
else if(getStatus(Unplugged)) strcat(statusOutput, "Unplugged");
|
||||
else strcat(statusOutput, "Error");
|
||||
strcat_P(statusOutput, PSTR(" - PowerRating: "));
|
||||
|
||||
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");
|
||||
else if(getStatus(NotCharging)) strcat(statusOutput, "Not Charging");
|
||||
else if(getStatus(Shutdown)) strcat(statusOutput, "Shutdown");
|
||||
else if(getStatus(Dying)) strcat(statusOutput, "Dying");
|
||||
else if(getStatus(Low)) strcat(statusOutput, "Low");
|
||||
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;
|
||||
if(getStatus(CableRumble)) strcat_P(statusOutput, PSTR("Cable - Rumble is on"));
|
||||
else if(getStatus(Cable)) strcat_P(statusOutput, PSTR("Cable - Rumble is off"));
|
||||
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 strcat_P(statusOutput, PSTR("Error"));
|
||||
} else
|
||||
return "Error";
|
||||
strcpy_P(statusOutput, PSTR("Error"));
|
||||
|
||||
USB_HOST_SERIAL.write((uint8_t*)statusOutput, strlen(statusOutput));
|
||||
}
|
||||
|
||||
/* Playstation Sixaxis Dualshock and Navigation Controller commands */
|
||||
|
|
7
PS3USB.h
7
PS3USB.h
|
@ -193,11 +193,8 @@ public:
|
|||
* @return True if correct and false if not.
|
||||
*/
|
||||
bool getStatus(StatusEnum c);
|
||||
/**
|
||||
* Read all the available ::StatusEnum from the controller.
|
||||
* @return One large string with all the information.
|
||||
*/
|
||||
String getStatusString();
|
||||
/** Read all the available statuses from the controller and prints it as a nice formated string. */
|
||||
void printStatusString();
|
||||
|
||||
/** Used to set all LEDs and rumble off. */
|
||||
void setAllOff();
|
||||
|
|
|
@ -111,7 +111,7 @@ void loop() {
|
|||
|
||||
if (PS3.getButtonClick(SELECT)) {
|
||||
Serial.print(F("\r\nSelect - "));
|
||||
Serial.print(PS3.getStatusString());
|
||||
PS3.printStatusString();
|
||||
}
|
||||
if (PS3.getButtonClick(START)) {
|
||||
Serial.print(F("\r\nStart"));
|
||||
|
@ -163,7 +163,7 @@ void loop() {
|
|||
PS3.moveSetBulb(Off);
|
||||
Serial.print(F("\r\nMove"));
|
||||
Serial.print(F(" - "));
|
||||
Serial.print(PS3.getStatusString());
|
||||
PS3.printStatusString();
|
||||
}
|
||||
}
|
||||
if (printAngle) {
|
||||
|
|
|
@ -116,7 +116,7 @@ void loop() {
|
|||
|
||||
if (PS3[i]->getButtonClick(SELECT)) {
|
||||
Serial.print(F("\r\nSelect - "));
|
||||
Serial.print(PS3[i]->getStatusString());
|
||||
PS3[i]->printStatusString();
|
||||
}
|
||||
if (PS3[i]->getButtonClick(START)) {
|
||||
Serial.print(F("\r\nStart"));
|
||||
|
|
|
@ -141,8 +141,7 @@ void loop() {
|
|||
output += " - R3";
|
||||
|
||||
if (PS3.getButtonClick(SELECT)) {
|
||||
output += " - Select - ";
|
||||
output += PS3.getStatusString();
|
||||
output += " - Select";
|
||||
}
|
||||
if (PS3.getButtonClick(START))
|
||||
output += " - Start";
|
||||
|
|
|
@ -96,7 +96,7 @@ void loop() {
|
|||
|
||||
if (PS3.getButtonClick(SELECT)) {
|
||||
Serial.print(F("\r\nSelect - "));
|
||||
Serial.print(PS3.getStatusString());
|
||||
PS3.printStatusString();
|
||||
}
|
||||
if (PS3.getButtonClick(START)) {
|
||||
Serial.print(F("\r\nStart"));
|
||||
|
|
|
@ -52,7 +52,7 @@ getSensor KEYWORD2
|
|||
getAngle KEYWORD2
|
||||
get9DOFValues KEYWORD2
|
||||
getStatus KEYWORD2
|
||||
getStatusString KEYWORD2
|
||||
printStatusString KEYWORD2
|
||||
getTemperature KEYWORD2
|
||||
disconnect KEYWORD2
|
||||
|
||||
|
|
Loading…
Reference in a new issue