Bob B
/
Set_Clock
Set clock using unix time and included functions in mbed.h. Includes link to Unix time converter.
TextLCD.h@0:680c4f0d8664, 2010-07-19 (annotated)
- Committer:
- rumbleweed
- Date:
- Mon Jul 19 21:30:25 2010 +0000
- Revision:
- 0:680c4f0d8664
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rumbleweed | 0:680c4f0d8664 | 1 | /* mbed TextLCD Library |
rumbleweed | 0:680c4f0d8664 | 2 | * Copyright (c) 2007-2009 sford |
rumbleweed | 0:680c4f0d8664 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
rumbleweed | 0:680c4f0d8664 | 4 | */ |
rumbleweed | 0:680c4f0d8664 | 5 | |
rumbleweed | 0:680c4f0d8664 | 6 | #ifndef MBED_TEXTLCD_H |
rumbleweed | 0:680c4f0d8664 | 7 | #define MBED_TEXTLCD_H |
rumbleweed | 0:680c4f0d8664 | 8 | |
rumbleweed | 0:680c4f0d8664 | 9 | #include "Stream.h" |
rumbleweed | 0:680c4f0d8664 | 10 | #include "DigitalOut.h" |
rumbleweed | 0:680c4f0d8664 | 11 | #include "BusOut.h" |
rumbleweed | 0:680c4f0d8664 | 12 | |
rumbleweed | 0:680c4f0d8664 | 13 | namespace mbed { |
rumbleweed | 0:680c4f0d8664 | 14 | |
rumbleweed | 0:680c4f0d8664 | 15 | /* Class: TextLCD |
rumbleweed | 0:680c4f0d8664 | 16 | * A 16x2 Text LCD controller |
rumbleweed | 0:680c4f0d8664 | 17 | * |
rumbleweed | 0:680c4f0d8664 | 18 | * Allows you to print to a Text LCD screen, and locate/cls. Could be |
rumbleweed | 0:680c4f0d8664 | 19 | * turned in to a more generic libray. |
rumbleweed | 0:680c4f0d8664 | 20 | * |
rumbleweed | 0:680c4f0d8664 | 21 | * If you are connecting multiple displays, you can connect them all in |
rumbleweed | 0:680c4f0d8664 | 22 | * parallel except for the enable (e) pin, which must be unique for each |
rumbleweed | 0:680c4f0d8664 | 23 | * display. |
rumbleweed | 0:680c4f0d8664 | 24 | * |
rumbleweed | 0:680c4f0d8664 | 25 | * Example: |
rumbleweed | 0:680c4f0d8664 | 26 | * > #include "mbed.h" |
rumbleweed | 0:680c4f0d8664 | 27 | * > #include "TextLCD.h" |
rumbleweed | 0:680c4f0d8664 | 28 | * > |
rumbleweed | 0:680c4f0d8664 | 29 | * > TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d0, d1, d2, d3 |
rumbleweed | 0:680c4f0d8664 | 30 | * > |
rumbleweed | 0:680c4f0d8664 | 31 | * > int main() { |
rumbleweed | 0:680c4f0d8664 | 32 | * > lcd.printf("Hello World!"); |
rumbleweed | 0:680c4f0d8664 | 33 | * > } |
rumbleweed | 0:680c4f0d8664 | 34 | */ |
rumbleweed | 0:680c4f0d8664 | 35 | class TextLCD : public Stream { |
rumbleweed | 0:680c4f0d8664 | 36 | |
rumbleweed | 0:680c4f0d8664 | 37 | public: |
rumbleweed | 0:680c4f0d8664 | 38 | /* Constructor: TextLCD |
rumbleweed | 0:680c4f0d8664 | 39 | * Create a TextLCD object, connected to the specified pins |
rumbleweed | 0:680c4f0d8664 | 40 | * |
rumbleweed | 0:680c4f0d8664 | 41 | * All signals must be connected to DigitalIn compatible pins. |
rumbleweed | 0:680c4f0d8664 | 42 | * |
rumbleweed | 0:680c4f0d8664 | 43 | * Variables: |
rumbleweed | 0:680c4f0d8664 | 44 | * rs - Used to specify data or command |
rumbleweed | 0:680c4f0d8664 | 45 | * rw - Used to determine read or write |
rumbleweed | 0:680c4f0d8664 | 46 | * e - enable |
rumbleweed | 0:680c4f0d8664 | 47 | * d0..d3 - The data lines |
rumbleweed | 0:680c4f0d8664 | 48 | */ |
rumbleweed | 0:680c4f0d8664 | 49 | TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, |
rumbleweed | 0:680c4f0d8664 | 50 | PinName d2, PinName d3, int columns = 16, int rows = 2); |
rumbleweed | 0:680c4f0d8664 | 51 | |
rumbleweed | 0:680c4f0d8664 | 52 | #if 0 // Inhereted from Stream, for documentation only |
rumbleweed | 0:680c4f0d8664 | 53 | /* Function: putc |
rumbleweed | 0:680c4f0d8664 | 54 | * Write a character |
rumbleweed | 0:680c4f0d8664 | 55 | * |
rumbleweed | 0:680c4f0d8664 | 56 | * Variables: |
rumbleweed | 0:680c4f0d8664 | 57 | * c - The character to write to the serial port |
rumbleweed | 0:680c4f0d8664 | 58 | */ |
rumbleweed | 0:680c4f0d8664 | 59 | int putc(int c); |
rumbleweed | 0:680c4f0d8664 | 60 | |
rumbleweed | 0:680c4f0d8664 | 61 | /* Function: printf |
rumbleweed | 0:680c4f0d8664 | 62 | * Write a formated string |
rumbleweed | 0:680c4f0d8664 | 63 | * |
rumbleweed | 0:680c4f0d8664 | 64 | * Variables: |
rumbleweed | 0:680c4f0d8664 | 65 | * format - A printf-style format string, followed by the |
rumbleweed | 0:680c4f0d8664 | 66 | * variables to use in formating the string. |
rumbleweed | 0:680c4f0d8664 | 67 | */ |
rumbleweed | 0:680c4f0d8664 | 68 | int printf(const char* format, ...); |
rumbleweed | 0:680c4f0d8664 | 69 | #endif |
rumbleweed | 0:680c4f0d8664 | 70 | |
rumbleweed | 0:680c4f0d8664 | 71 | /* Function: locate |
rumbleweed | 0:680c4f0d8664 | 72 | * Locate to a certian position |
rumbleweed | 0:680c4f0d8664 | 73 | * |
rumbleweed | 0:680c4f0d8664 | 74 | * Variables: |
rumbleweed | 0:680c4f0d8664 | 75 | * column - the column to locate to, from 0..15 |
rumbleweed | 0:680c4f0d8664 | 76 | * row - the row to locate to, from 0..1 |
rumbleweed | 0:680c4f0d8664 | 77 | */ |
rumbleweed | 0:680c4f0d8664 | 78 | virtual void locate(int column, int row); |
rumbleweed | 0:680c4f0d8664 | 79 | |
rumbleweed | 0:680c4f0d8664 | 80 | /* Function: cls |
rumbleweed | 0:680c4f0d8664 | 81 | * Clear the screen, and locate to 0,0 |
rumbleweed | 0:680c4f0d8664 | 82 | */ |
rumbleweed | 0:680c4f0d8664 | 83 | virtual void cls(); |
rumbleweed | 0:680c4f0d8664 | 84 | |
rumbleweed | 0:680c4f0d8664 | 85 | virtual void reset(); |
rumbleweed | 0:680c4f0d8664 | 86 | |
rumbleweed | 0:680c4f0d8664 | 87 | protected: |
rumbleweed | 0:680c4f0d8664 | 88 | |
rumbleweed | 0:680c4f0d8664 | 89 | void clock(); |
rumbleweed | 0:680c4f0d8664 | 90 | void writeData(int data); |
rumbleweed | 0:680c4f0d8664 | 91 | void writeCommand(int command); |
rumbleweed | 0:680c4f0d8664 | 92 | void writeByte(int value); |
rumbleweed | 0:680c4f0d8664 | 93 | void writeNibble(int value); |
rumbleweed | 0:680c4f0d8664 | 94 | virtual int _putc(int c); |
rumbleweed | 0:680c4f0d8664 | 95 | virtual int _getc(); |
rumbleweed | 0:680c4f0d8664 | 96 | virtual void newline(); |
rumbleweed | 0:680c4f0d8664 | 97 | |
rumbleweed | 0:680c4f0d8664 | 98 | int _row; |
rumbleweed | 0:680c4f0d8664 | 99 | int _column; |
rumbleweed | 0:680c4f0d8664 | 100 | DigitalOut _rw, _rs, _e; |
rumbleweed | 0:680c4f0d8664 | 101 | BusOut _d; |
rumbleweed | 0:680c4f0d8664 | 102 | int _columns; |
rumbleweed | 0:680c4f0d8664 | 103 | int _rows; |
rumbleweed | 0:680c4f0d8664 | 104 | |
rumbleweed | 0:680c4f0d8664 | 105 | }; |
rumbleweed | 0:680c4f0d8664 | 106 | |
rumbleweed | 0:680c4f0d8664 | 107 | } |
rumbleweed | 0:680c4f0d8664 | 108 | |
rumbleweed | 0:680c4f0d8664 | 109 | #endif |