From e75fb7c47b640ea329984d95fc9f4b2d7cd3efe4 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sat, 9 Apr 2016 10:56:10 +0200 Subject: because arduino is sooooooo frustrating Signed-off-by: Olivier Gayot --- sketch_apr09a/logs.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 sketch_apr09a/logs.cpp (limited to 'sketch_apr09a/logs.cpp') diff --git a/sketch_apr09a/logs.cpp b/sketch_apr09a/logs.cpp new file mode 100644 index 0000000..901fd25 --- /dev/null +++ b/sketch_apr09a/logs.cpp @@ -0,0 +1,61 @@ +#include +#include + +int serial_write(uint8_t val) +{ + Serial.write(&val, 1); +} + +int serial_put_string(const char *str) +{ + while (*str) { + serial_write(*str++); + } + + return 0; +} + +int serial_puts(const char *str) +{ + serial_put_string(str); + + serial_write('\n'); + + return 0; +} + +int serial_printf(const char *fmt, ...) +{ + va_list ap; + + static char buf[256]; + + va_start(ap, fmt); + + vsnprintf(buf, sizeof(buf), fmt, ap); + + serial_put_string(buf); + + va_end(ap); + + return 0; +} + +#if 0 +int serial_print_dec(uint8_t opcode, int32_t integer) +{ + Serial.write(&opcode, 1); + Serial.println(integer, DEC); + return 0; +} + +int serial_print_hex(uint8_t opcode, int32_t integer) +{ + Serial.write(&opcode, 1); + Serial.println(integer, HEX); + return 0; +} +#endif + + + -- cgit v1.2.3