From 00442ce2e5f3999c19dd9b40cf1ed0dae1c13949 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Sat, 7 Dec 2013 00:32:21 +0100 Subject: [PATCH] Updated max_LCD to inherit the standard Print class Works both in Arduino < 1.0.0 and newer versions of Arduino --- max_LCD.cpp | 7 +++++++ max_LCD.h | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/max_LCD.cpp b/max_LCD.cpp index 71c2247a..ce7ad683 100644 --- a/max_LCD.cpp +++ b/max_LCD.cpp @@ -223,9 +223,16 @@ inline void Max_LCD::command(uint8_t value) { delayMicroseconds(100); } +#if defined(ARDUINO) && ARDUINO >=100 +inline size_t Max_LCD::write(uint8_t value) { + LCD_sendchar(value); + return 1; // Assume success +} +#else inline void Max_LCD::write(uint8_t value) { LCD_sendchar(value); } +#endif void Max_LCD::sendbyte(uint8_t val) { lcdPins &= 0x0f; //prepare place for the upper nibble diff --git a/max_LCD.h b/max_LCD.h index be9f2615..668ebb2d 100644 --- a/max_LCD.h +++ b/max_LCD.h @@ -62,7 +62,7 @@ e-mail : support@circuitsathome.com #define LCD_5x10DOTS 0x04 #define LCD_5x8DOTS 0x00 -class Max_LCD //: public Print +class Max_LCD : public Print { USB *pUsb; @@ -86,9 +86,15 @@ public: void noAutoscroll(); void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - virtual void write(uint8_t); void command(uint8_t); +#if defined(ARDUINO) && ARDUINO >=100 + virtual size_t write(uint8_t); + using Print::write; +#else + virtual void write(uint8_t); +#endif + private: void sendbyte(uint8_t val); uint8_t _displayfunction; //tokill