Skip to content

Commit 1f33f2b

Browse files
committed
Renamed getStatusString() to printStatusString()
1 parent 257c96f commit 1f33f2b

File tree

9 files changed

+45
-60
lines changed

9 files changed

+45
-60
lines changed

PS3BT.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,17 @@ bool PS3BT::getStatus(StatusEnum c) {
160160
return (l2capinbuf[(uint16_t)c >> 8] == ((uint8_t)c & 0xff));
161161
}
162162

163-
String PS3BT::getStatusString() {
163+
void PS3BT::printStatusString() {
164+
char statusOutput[100]; // Max string length plus null character
164165
if(PS3Connected || PS3NavigationConnected) {
165-
char statusOutput[100]; // Max string length plus null character
166-
167166
strcpy_P(statusOutput, PSTR("ConnectionStatus: "));
168167

169168
if(getStatus(Plugged)) strcat_P(statusOutput, PSTR("Plugged"));
170169
else if(getStatus(Unplugged)) strcat_P(statusOutput, PSTR("Unplugged"));
171170
else strcat_P(statusOutput, PSTR("Error"));
172171

173-
174172
strcat_P(statusOutput, PSTR(" - PowerRating: "));
173+
175174
if(getStatus(Charging)) strcat_P(statusOutput, PSTR("Charging"));
176175
else if(getStatus(NotCharging)) strcat_P(statusOutput, PSTR("Not Charging"));
177176
else if(getStatus(Shutdown)) strcat_P(statusOutput, PSTR("Shutdown"));
@@ -188,12 +187,7 @@ String PS3BT::getStatusString() {
188187
else if(getStatus(BluetoothRumble)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is on"));
189188
else if(getStatus(Bluetooth)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is off"));
190189
else strcat_P(statusOutput, PSTR("Error"));
191-
192-
return statusOutput;
193-
194190
} else if(PS3MoveConnected) {
195-
char statusOutput[26]; // Max string length plus null character
196-
197191
strcpy_P(statusOutput, PSTR("PowerRating: "));
198192

199193
if(getStatus(MoveCharging)) strcat_P(statusOutput, PSTR("Charging"));
@@ -204,10 +198,10 @@ String PS3BT::getStatusString() {
204198
else if(getStatus(MoveHigh)) strcat_P(statusOutput, PSTR("High"));
205199
else if(getStatus(MoveFull)) strcat_P(statusOutput, PSTR("Full"));
206200
else strcat_P(statusOutput, PSTR("Error"));
207-
208-
return statusOutput;
209201
} else
210-
return "Error";
202+
strcpy_P(statusOutput, PSTR("Error"));
203+
204+
USB_HOST_SERIAL.write((uint8_t*)statusOutput, strlen(statusOutput));
211205
}
212206

213207
void PS3BT::Reset() {

PS3BT.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,8 @@ class PS3BT : public BluetoothService {
111111
* @return True if correct and false if not.
112112
*/
113113
bool getStatus(StatusEnum c);
114-
/**
115-
* Read all the available ::StatusEnum from the controller.
116-
* @return One large string with all the information.
117-
*/
118-
String getStatusString();
114+
/** Read all the available statuses from the controller and prints it as a nice formated string. */
115+
void printStatusString();
119116
/**
120117
* Read the temperature from the Move controller.
121118
* @return The temperature in degrees Celsius.

PS3USB.cpp

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -362,39 +362,37 @@ bool PS3USB::getStatus(StatusEnum c) {
362362
return (readBuf[((uint16_t)c >> 8) - 9] == ((uint8_t)c & 0xff));
363363
}
364364

365-
String PS3USB::getStatusString() {
365+
void PS3USB::printStatusString() {
366+
char statusOutput[100]; // Max string length plus null character
366367
if(PS3Connected || PS3NavigationConnected) {
367-
char statusOutput[100];
368-
369-
strcpy(statusOutput, "ConnectionStatus: ");
370-
371-
if(getStatus(Plugged)) strcat(statusOutput, "Plugged");
372-
else if(getStatus(Unplugged)) strcat(statusOutput, "Unplugged");
373-
else strcat(statusOutput, "Error");
374-
375-
376-
strcat(statusOutput, " - PowerRating: ");
377-
378-
if(getStatus(Charging)) strcat(statusOutput, "Charging");
379-
else if(getStatus(NotCharging)) strcat(statusOutput, "Not Charging");
380-
else if(getStatus(Shutdown)) strcat(statusOutput, "Shutdown");
381-
else if(getStatus(Dying)) strcat(statusOutput, "Dying");
382-
else if(getStatus(Low)) strcat(statusOutput, "Low");
383-
else if(getStatus(High)) strcat(statusOutput, "High");
384-
else if(getStatus(Full)) strcat(statusOutput, "Full");
385-
else strcat(statusOutput, "Error");
386-
387-
strcat(statusOutput, " - WirelessStatus: ");
388-
389-
if(getStatus(CableRumble)) strcat(statusOutput, "Cable - Rumble is on");
390-
else if(getStatus(Cable)) strcat(statusOutput, "Cable - Rumble is off");
391-
else if(getStatus(BluetoothRumble)) strcat(statusOutput, "Bluetooth - Rumble is on");
392-
else if(getStatus(Bluetooth)) strcat(statusOutput, "Bluetooth - Rumble is off");
393-
else strcat(statusOutput, "Error");
394-
395-
return statusOutput;
368+
strcpy_P(statusOutput, PSTR("ConnectionStatus: "));
369+
370+
if(getStatus(Plugged)) strcat_P(statusOutput, PSTR("Plugged"));
371+
else if(getStatus(Unplugged)) strcat_P(statusOutput, PSTR("Unplugged"));
372+
else strcat_P(statusOutput, PSTR("Error"));
373+
374+
strcat_P(statusOutput, PSTR(" - PowerRating: "));
375+
376+
if(getStatus(Charging)) strcat_P(statusOutput, PSTR("Charging"));
377+
else if(getStatus(NotCharging)) strcat_P(statusOutput, PSTR("Not Charging"));
378+
else if(getStatus(Shutdown)) strcat_P(statusOutput, PSTR("Shutdown"));
379+
else if(getStatus(Dying)) strcat_P(statusOutput, PSTR("Dying"));
380+
else if(getStatus(Low)) strcat_P(statusOutput, PSTR("Low"));
381+
else if(getStatus(High)) strcat_P(statusOutput, PSTR("High"));
382+
else if(getStatus(Full)) strcat_P(statusOutput, PSTR("Full"));
383+
else strcat_P(statusOutput, PSTR("Error"));
384+
385+
strcat_P(statusOutput, PSTR(" - WirelessStatus: "));
386+
387+
if(getStatus(CableRumble)) strcat_P(statusOutput, PSTR("Cable - Rumble is on"));
388+
else if(getStatus(Cable)) strcat_P(statusOutput, PSTR("Cable - Rumble is off"));
389+
else if(getStatus(BluetoothRumble)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is on"));
390+
else if(getStatus(Bluetooth)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is off"));
391+
else strcat_P(statusOutput, PSTR("Error"));
396392
} else
397-
return "Error";
393+
strcpy_P(statusOutput, PSTR("Error"));
394+
395+
USB_HOST_SERIAL.write((uint8_t*)statusOutput, strlen(statusOutput));
398396
}
399397

400398
/* Playstation Sixaxis Dualshock and Navigation Controller commands */

PS3USB.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,8 @@ class PS3USB : public USBDeviceConfig {
193193
* @return True if correct and false if not.
194194
*/
195195
bool getStatus(StatusEnum c);
196-
/**
197-
* Read all the available ::StatusEnum from the controller.
198-
* @return One large string with all the information.
199-
*/
200-
String getStatusString();
196+
/** Read all the available statuses from the controller and prints it as a nice formated string. */
197+
void printStatusString();
201198

202199
/** Used to set all LEDs and rumble off. */
203200
void setAllOff();

examples/Bluetooth/PS3BT/PS3BT.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void loop() {
111111

112112
if (PS3.getButtonClick(SELECT)) {
113113
Serial.print(F("\r\nSelect - "));
114-
Serial.print(PS3.getStatusString());
114+
PS3.printStatusString();
115115
}
116116
if (PS3.getButtonClick(START)) {
117117
Serial.print(F("\r\nStart"));
@@ -163,7 +163,7 @@ void loop() {
163163
PS3.moveSetBulb(Off);
164164
Serial.print(F("\r\nMove"));
165165
Serial.print(F(" - "));
166-
Serial.print(PS3.getStatusString());
166+
PS3.printStatusString();
167167
}
168168
}
169169
if (printAngle) {

examples/Bluetooth/PS3Multi/PS3Multi.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void loop() {
116116

117117
if (PS3[i]->getButtonClick(SELECT)) {
118118
Serial.print(F("\r\nSelect - "));
119-
Serial.print(PS3[i]->getStatusString());
119+
PS3[i]->printStatusString();
120120
}
121121
if (PS3[i]->getButtonClick(START)) {
122122
Serial.print(F("\r\nStart"));

examples/Bluetooth/PS3SPP/PS3SPP.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ void loop() {
141141
output += " - R3";
142142

143143
if (PS3.getButtonClick(SELECT)) {
144-
output += " - Select - ";
145-
output += PS3.getStatusString();
144+
output += " - Select";
146145
}
147146
if (PS3.getButtonClick(START))
148147
output += " - Start";

examples/PS3USB/PS3USB.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void loop() {
9696

9797
if (PS3.getButtonClick(SELECT)) {
9898
Serial.print(F("\r\nSelect - "));
99-
Serial.print(PS3.getStatusString());
99+
PS3.printStatusString();
100100
}
101101
if (PS3.getButtonClick(START)) {
102102
Serial.print(F("\r\nStart"));

keywords.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ getSensor KEYWORD2
5252
getAngle KEYWORD2
5353
get9DOFValues KEYWORD2
5454
getStatus KEYWORD2
55-
getStatusString KEYWORD2
55+
printStatusString KEYWORD2
5656
getTemperature KEYWORD2
5757
disconnect KEYWORD2
5858

0 commit comments

Comments
 (0)