mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Added intToString(int32_t input, char* output) function
This commit is contained in:
parent
09c5b6c5a3
commit
734f004671
2 changed files with 16 additions and 12 deletions
21
SPP.cpp
21
SPP.cpp
|
@ -809,26 +809,23 @@ void SPP::printNumberln(uint32_t n) {
|
||||||
|
|
||||||
void SPP::printNumber(int32_t n) {
|
void SPP::printNumber(int32_t n) {
|
||||||
char output[12];
|
char output[12];
|
||||||
if(n < 0) {
|
intToString(n,output);
|
||||||
char buf[11];
|
|
||||||
intToString(n*-1,buf);
|
|
||||||
strcpy(output,"-");
|
|
||||||
strcat(output,buf);
|
|
||||||
} else
|
|
||||||
intToString(n,output);
|
|
||||||
print(output);
|
print(output);
|
||||||
}
|
}
|
||||||
void SPP::printNumberln(int32_t n) {
|
void SPP::printNumberln(int32_t n) {
|
||||||
char output[14];
|
char output[14];
|
||||||
if(n < 0) {
|
intToString(n,output);
|
||||||
|
strcat(output,"\r\n");
|
||||||
|
print(output);
|
||||||
|
}
|
||||||
|
void SPP::intToString(int32_t input, char* output) {
|
||||||
|
if(input < 0) {
|
||||||
char buf[11];
|
char buf[11];
|
||||||
intToString(n*-1,buf);
|
intToString((uint32_t)(input*-1),buf);
|
||||||
strcpy(output,"-");
|
strcpy(output,"-");
|
||||||
strcat(output,buf);
|
strcat(output,buf);
|
||||||
} else
|
} else
|
||||||
intToString(n,output);
|
intToString((uint32_t)input,output);
|
||||||
strcat(output,"\r\n");
|
|
||||||
print(output);
|
|
||||||
}
|
}
|
||||||
void SPP::intToString(uint32_t input, char* output) {
|
void SPP::intToString(uint32_t input, char* output) {
|
||||||
uint32_t temp = input;
|
uint32_t temp = input;
|
||||||
|
|
7
SPP.h
7
SPP.h
|
@ -236,6 +236,13 @@ public:
|
||||||
* @param n Signed integer to send.
|
* @param n Signed integer to send.
|
||||||
*/
|
*/
|
||||||
void printNumberln(int32_t n);
|
void printNumberln(int32_t n);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to convert from an unsigned integer to a string.
|
||||||
|
* @param input Unsigned integer to convert.
|
||||||
|
* @param output Output buffer.
|
||||||
|
*/
|
||||||
|
void intToString(int32_t input, char* output);
|
||||||
/**
|
/**
|
||||||
* Helper function to convert from a signed integer to a string.
|
* Helper function to convert from a signed integer to a string.
|
||||||
* @param input Signed integer to convert.
|
* @param input Signed integer to convert.
|
||||||
|
|
Loading…
Reference in a new issue