From 44358d6a9315634fe65d4a58ae50208e3a9957bf Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 16 Nov 2018 07:59:42 +0100 Subject: esp8266: Use os_printf where applicable --- include/arch/esp8266/driver/stdout.h | 2 +- src/arch/esp8266/driver/stdout.cc | 22 +++++++--------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/include/arch/esp8266/driver/stdout.h b/include/arch/esp8266/driver/stdout.h index 038de2e..95135ad 100644 --- a/include/arch/esp8266/driver/stdout.h +++ b/include/arch/esp8266/driver/stdout.h @@ -8,7 +8,7 @@ class StandardOutput { unsigned char base; public: - StandardOutput (); + StandardOutput() : base(10) {}; void setup(); void put(char c); diff --git a/src/arch/esp8266/driver/stdout.cc b/src/arch/esp8266/driver/stdout.cc index 2064b38..4471672 100644 --- a/src/arch/esp8266/driver/stdout.cc +++ b/src/arch/esp8266/driver/stdout.cc @@ -21,37 +21,37 @@ StandardOutput & StandardOutput::operator<<(char c) StandardOutput & StandardOutput::operator<<(unsigned short number) { - *this << (unsigned long long)number; + os_printf("%u", number); return *this; } StandardOutput & StandardOutput::operator<<(short number) { - *this << (long long)number; + os_printf("%d", number); return *this; } StandardOutput & StandardOutput::operator<<(unsigned int number) { - *this << (unsigned long long)number; + os_printf("%u", number); return *this; } StandardOutput & StandardOutput::operator<<(int number) { - *this << (long long)number; + os_printf("%d", number); return *this; } StandardOutput & StandardOutput::operator<<(unsigned long number) { - *this << (unsigned long long)number; + os_printf("%lu", number); return *this; } StandardOutput & StandardOutput::operator<<(long number) { - *this << (long long)number; + os_printf("%ld", number); return *this; } @@ -122,10 +122,7 @@ StandardOutput & StandardOutput::operator<<(void *pointer) StandardOutput & StandardOutput::operator<<(const char *text) { - int i = 0; - while (text[i] != '\0') { - put(text[i++]); - } + write(text); return *this; } @@ -227,11 +224,6 @@ StandardOutput & term(StandardOutput & os) return os; } -StandardOutput::StandardOutput() -{ - base = 10; -} - void StandardOutput::setup() { uart_div_modify(0, UART_CLK_FREQ / 115200); -- cgit v1.2.3