Improved version of Simon Ford's TextDisplay library, with addressing and timing fixes. Supports up to 20x4 text displays.
Diff: TextDisplay.h
- Revision:
- 0:2c5bba968d7c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TextDisplay.h Sun Feb 14 00:28:08 2010 +0000
@@ -0,0 +1,52 @@
+/* mbed TextDisplay Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * A common base class for Text displays
+ * To port a new display, derive from this class and implement
+ * the constructor (setup the display), character (put a character
+ * at a location), rows and columns (number of rows/cols) functions.
+ * Everything else (locate, printf, putc, cls) will come for free
+ *
+ * The model is the display will wrap at the right and bottom, so you can
+ * keep writing and will always get valid characters. The location is
+ * maintained internally to the class to make this easy
+ */
+
+#ifndef MBED_TEXTDISPLAY_H
+#define MBED_TEXTDISPLAY_H
+
+#include "mbed.h"
+
+class TextDisplay : public Stream {
+public:
+
+ // functions needing implementation in derived implementation class
+ TextDisplay();
+ virtual void character(uint16_t column, uint16_t row, int c) = 0;
+ virtual uint16_t rows() = 0;
+ virtual uint16_t columns() = 0;
+
+ // functions that come for free, but can be overwritten
+ virtual void cls();
+ virtual void locate(uint16_t column, uint16_t row);
+ virtual void foreground(uint32_t colour);
+ virtual void background(uint32_t colour);
+ // putc (from Stream)
+ // printf (from Stream)
+
+protected:
+
+ virtual int _putc(int value);
+ virtual int _getc();
+
+ // character location
+ uint16_t _column;
+ uint16_t _row;
+
+ // colours
+ uint32_t _foreground;
+ uint32_t _background;
+};
+
+#endif
Ned Konz