mirror of
https://github.com/avem-labs/Avem.git
synced 2023-09-01 15:18:49 +08:00
style: (uart_showData) Use array to stored the bit values, that will be a little bit enhancements
This commit is contained in:
parent
910ae06185
commit
08ba81338b
@ -101,19 +101,14 @@ void uart_sendData(unsigned char data) {
|
||||
}
|
||||
|
||||
void uart_showData(short k) {
|
||||
char tem[] = "00000";
|
||||
char *result = tem;
|
||||
char cache[] = "00000";
|
||||
int i = 4;
|
||||
unsigned short bit[] = {10000, 1000, 100, 10, 1};
|
||||
|
||||
uart_sendData(k<0 ? '-':'+');
|
||||
if(k<0)
|
||||
k = -k;
|
||||
unsigned short bit = 1;
|
||||
while(*result) {
|
||||
(*result++) = (char)(k / bit % 10 + '0');
|
||||
bit *= 10;
|
||||
}
|
||||
for(unsigned char i = 0; i < 5; i++)
|
||||
uart_sendData(tem[4-i]);
|
||||
do {
|
||||
cache[i] += (char)(k / bit[i] % 10);
|
||||
} while(i--);
|
||||
uart_sendStr(cache);
|
||||
}
|
||||
|
||||
unsigned char uart_Float2Char(float value) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user