Set of routines to access 16*32character LCD display on WattBob I board.
Dependents: Assignment_2_herpe Final_V1 ass2 ass2 ... more
WattBob_TextLCD.h@1:190b705fb9e1, 2010-11-29 (annotated)
- Committer:
- jimherd
- Date:
- Mon Nov 29 14:22:52 2010 +0000
- Revision:
- 1:190b705fb9e1
- Parent:
- 0:e5b7c70254ac
- Child:
- 2:1cba2dd23d65
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jimherd | 0:e5b7c70254ac | 1 | /* draft mbed TextLCD |
jimherd | 0:e5b7c70254ac | 2 | * (c) 2007/8, sford |
jimherd | 0:e5b7c70254ac | 3 | */ |
jimherd | 0:e5b7c70254ac | 4 | |
jimherd | 0:e5b7c70254ac | 5 | #ifndef WATTBOB_TEXTLCD_H |
jimherd | 0:e5b7c70254ac | 6 | #define WATTBOB_TEXTLCD_H |
jimherd | 0:e5b7c70254ac | 7 | |
jimherd | 0:e5b7c70254ac | 8 | #include "mbed.h" |
jimherd | 0:e5b7c70254ac | 9 | #include "Stream.h" |
jimherd | 0:e5b7c70254ac | 10 | #include "MCP23017.h" |
jimherd | 0:e5b7c70254ac | 11 | |
jimherd | 0:e5b7c70254ac | 12 | #define RS_BIT 7 |
jimherd | 0:e5b7c70254ac | 13 | #define RW_BIT 6 |
jimherd | 0:e5b7c70254ac | 14 | #define E_BIT 5 |
jimherd | 0:e5b7c70254ac | 15 | #define BL_BIT 4 |
jimherd | 0:e5b7c70254ac | 16 | |
jimherd | 1:190b705fb9e1 | 17 | /** Class to access 16*2 LCD display connected to an MCP23017 I/O extender chip |
jimherd | 1:190b705fb9e1 | 18 | * |
jimherd | 1:190b705fb9e1 | 19 | * Derived from the "stream" class to be able to use methods such as "printf" |
jimherd | 1:190b705fb9e1 | 20 | * |
jimherd | 1:190b705fb9e1 | 21 | * Example : |
jimherd | 1:190b705fb9e1 | 22 | * @code |
jimherd | 1:190b705fb9e1 | 23 | * MCP23017 *par_port; |
jimherd | 1:190b705fb9e1 | 24 | * WattBob_TextLCD *lcd; |
jimherd | 1:190b705fb9e1 | 25 | * ..... |
jimherd | 1:190b705fb9e1 | 26 | * |
jimherd | 1:190b705fb9e1 | 27 | * par_port->write_bit(1,BL_BIT); // turn LCD backlight ON |
jimherd | 1:190b705fb9e1 | 28 | * lcd->cls(); lcd->locate(0,0); |
jimherd | 1:190b705fb9e1 | 29 | * lcd->printf("%s", message); |
jimherd | 1:190b705fb9e1 | 30 | * lcd->locate(1,0);lcd->printf("press 1 to cont"); |
jimherd | 1:190b705fb9e1 | 31 | * @endcode |
jimherd | 1:190b705fb9e1 | 32 | */ |
jimherd | 0:e5b7c70254ac | 33 | class WattBob_TextLCD : public Stream { |
jimherd | 0:e5b7c70254ac | 34 | |
jimherd | 0:e5b7c70254ac | 35 | public: |
jimherd | 1:190b705fb9e1 | 36 | /** Create TextLCD object connected to a MCP23017 device |
jimherd | 1:190b705fb9e1 | 37 | * |
jimherd | 1:190b705fb9e1 | 38 | * @param port pointer to MCP23017 object |
jimherd | 1:190b705fb9e1 | 39 | */ |
jimherd | 1:190b705fb9e1 | 40 | WattBob_TextLCD(MCP23017 *port); |
jimherd | 1:190b705fb9e1 | 41 | |
jimherd | 1:190b705fb9e1 | 42 | /** Set cursor to a known point |
jimherd | 1:190b705fb9e1 | 43 | * |
jimherd | 1:190b705fb9e1 | 44 | * Virtual function for stream class |
jimherd | 1:190b705fb9e1 | 45 | * |
jimherd | 1:190b705fb9e1 | 46 | * @param row integer row number (0 or 1) |
jimherd | 1:190b705fb9e1 | 47 | * @param col integer column number (0 or 15) |
jimherd | 1:190b705fb9e1 | 48 | */ |
jimherd | 0:e5b7c70254ac | 49 | virtual void locate(int row, int column); |
jimherd | 1:190b705fb9e1 | 50 | |
jimherd | 1:190b705fb9e1 | 51 | /** clear display |
jimherd | 1:190b705fb9e1 | 52 | * |
jimherd | 1:190b705fb9e1 | 53 | * Virtual function for stream class |
jimherd | 1:190b705fb9e1 | 54 | */ |
jimherd | 1:190b705fb9e1 | 55 | virtual void cls(); |
jimherd | 1:190b705fb9e1 | 56 | |
jimherd | 1:190b705fb9e1 | 57 | /** reset the display |
jimherd | 1:190b705fb9e1 | 58 | * |
jimherd | 1:190b705fb9e1 | 59 | * Virtual function for stream class |
jimherd | 1:190b705fb9e1 | 60 | */ |
jimherd | 0:e5b7c70254ac | 61 | virtual void reset(); |
jimherd | 0:e5b7c70254ac | 62 | |
jimherd | 0:e5b7c70254ac | 63 | protected: |
jimherd | 0:e5b7c70254ac | 64 | |
jimherd | 1:190b705fb9e1 | 65 | virtual int _putc(int c); |
jimherd | 1:190b705fb9e1 | 66 | virtual int _getc(); |
jimherd | 1:190b705fb9e1 | 67 | virtual void newline(); |
jimherd | 1:190b705fb9e1 | 68 | |
jimherd | 0:e5b7c70254ac | 69 | void clock(); |
jimherd | 0:e5b7c70254ac | 70 | void writeData(int data); |
jimherd | 0:e5b7c70254ac | 71 | void writeCommand(int command); |
jimherd | 0:e5b7c70254ac | 72 | void writeByte(int value); |
jimherd | 0:e5b7c70254ac | 73 | void writeNibble(int value); |
jimherd | 0:e5b7c70254ac | 74 | |
jimherd | 0:e5b7c70254ac | 75 | void _rs (int data); |
jimherd | 0:e5b7c70254ac | 76 | void _rw (int data); |
jimherd | 0:e5b7c70254ac | 77 | void _e (int data); |
jimherd | 0:e5b7c70254ac | 78 | void _d (int data); |
jimherd | 1:190b705fb9e1 | 79 | |
jimherd | 0:e5b7c70254ac | 80 | int _rows; |
jimherd | 0:e5b7c70254ac | 81 | int _columns; |
jimherd | 0:e5b7c70254ac | 82 | int _row; |
jimherd | 0:e5b7c70254ac | 83 | int _column; |
jimherd | 0:e5b7c70254ac | 84 | |
jimherd | 0:e5b7c70254ac | 85 | private: |
jimherd | 0:e5b7c70254ac | 86 | MCP23017 *par_port; |
jimherd | 0:e5b7c70254ac | 87 | }; |
jimherd | 0:e5b7c70254ac | 88 | |
jimherd | 0:e5b7c70254ac | 89 | #endif |