Using std::ostream with TextLCD
Dependencies: ACM1602NI TextLCD
Dependents: TextLCD_ostream_sample
This is class library inherited std::ostream for TextLCD
Because a large amount of memory is needed, do not work in low memory MPU
Sample program is here. And notebook page is here (sorry notebook page is only in Japanese)
Revision 6:2494d76a38b0, committed 2016-07-30
- Comitter:
- jk1lot
- Date:
- Sat Jul 30 06:59:22 2016 +0000
- Parent:
- 5:6c1109b4dfb8
- Commit message:
- bug fixed
Changed in this revision
diff -r 6c1109b4dfb8 -r 2494d76a38b0 Nucleo_streamfix.cpp --- a/Nucleo_streamfix.cpp Fri Jul 29 16:13:36 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -#include "mbed.h" - -#ifdef TARGET_STM -#ifdef __MICROLIB /*__CC_ARM*/ -/// To suppress MDK-ARM Linker Error: L6218E: Undefined symbol __fread_bytes_avail (referred from ios.o). -size_t std::__fread_bytes_avail(void * __restrict ptr, - size_t count, FILE * __restrict stream) //__attribute__((__nonnull__(1,3))) -{ - return 0; -} - - -#include <wchar.h> -/// To suppress MDK-ARM Linker Error: L6218E: Undefined symbol mbsinit (referred from ios.o). -int std::mbsinit(const mbstate_t * ps) -{ - return -1; -} - -/// To suppress MDK-ARM Linker Error: L6218E: Undefined symbol mbsinit (referred from ios.o). -wchar_t *std::wmemmove(wchar_t * __restrict s1, - const wchar_t * __restrict s2, size_t n) //__attribute__((__nonnull__(1,2))) -{ - return NULL; -} -#endif /*__MICROLIB*/ /*__CC_ARM*/ -#endif
diff -r 6c1109b4dfb8 -r 2494d76a38b0 TextLCD_ostream.h --- a/TextLCD_ostream.h Fri Jul 29 16:13:36 2016 +0000 +++ b/TextLCD_ostream.h Sat Jul 30 06:59:22 2016 +0000 @@ -4,21 +4,6 @@ #include <ostream> #include <streambuf> -/* -template <class LCDCLASS> -class TextLCD_streambuf : public std::streambuf { -public: - TextLCD_streambuf(LCDCLASS *p) : lcdp(p) {} - virtual int_type overflow( int_type c = EOF ) { - if( c != EOF ) lcdp->putc(c); - return c; - } - -private: - LCDCLASS *lcdp; -}; -*/ - /** ostream wrapper for TextLCD. LCDCLASS(TextLCD) need to have putc(),locate(),cls() function. @code @@ -70,13 +55,12 @@ private: LCDCLASS *lcdp; } lcd_buf; -// TextLCD_streambuf<LCDCLASS> lcd_buf; }; #ifndef NOTextLCD_h //for compatibility to previous version #include "TextLCD.h" -/// specialized version +// specialized version typedef TextLCD_ostream<TextLCD_Base> lcd_ostream; #endif
diff -r 6c1109b4dfb8 -r 2494d76a38b0 microlib_streamfix.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/microlib_streamfix.cpp Sat Jul 30 06:59:22 2016 +0000 @@ -0,0 +1,27 @@ +// Dummy functions to avoid compile error. +// In fact, malfunctions Once these functions are called. +#include "mbed.h" + +#ifdef __MICROLIB /*__CC_ARM*/ +/// To suppress MDK-ARM Linker Error: L6218E: Undefined symbol __fread_bytes_avail (referred from ios.o). +size_t std::__fread_bytes_avail(void * __restrict ptr, + size_t count, FILE * __restrict stream) //__attribute__((__nonnull__(1,3))) +{ + return 1; +} + + +#include <wchar.h> +/// To suppress MDK-ARM Linker Error: L6218E: Undefined symbol mbsinit (referred from ios.o). +int std::mbsinit(const mbstate_t * ps) +{ + return -1; +} + +/// To suppress MDK-ARM Linker Error: L6218E: Undefined symbol mbsinit (referred from ios.o). +wchar_t *std::wmemmove(wchar_t * __restrict s1, + const wchar_t * __restrict s2, size_t n) //__attribute__((__nonnull__(1,2))) +{ + return NULL; +} +#endif /*__MICROLIB*/ /*__CC_ARM*/