Junaid Ahmed
/
202A_HW1
Configuring sensors dynamically using serial bus from the host computer.
SLCD/SLCD.h@0:1efeb3fc4ba6, 2014-02-12 (annotated)
- Committer:
- mja054
- Date:
- Wed Feb 12 22:23:22 2014 +0000
- Revision:
- 0:1efeb3fc4ba6
Home work1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mja054 | 0:1efeb3fc4ba6 | 1 | #include "mbed.h" |
mja054 | 0:1efeb3fc4ba6 | 2 | |
mja054 | 0:1efeb3fc4ba6 | 3 | |
mja054 | 0:1efeb3fc4ba6 | 4 | /* ------ sample usage------ |
mja054 | 0:1efeb3fc4ba6 | 5 | |
mja054 | 0:1efeb3fc4ba6 | 6 | #include "mbed.h" |
mja054 | 0:1efeb3fc4ba6 | 7 | #include "SLCD.h" |
mja054 | 0:1efeb3fc4ba6 | 8 | |
mja054 | 0:1efeb3fc4ba6 | 9 | SLCD slcd; |
mja054 | 0:1efeb3fc4ba6 | 10 | |
mja054 | 0:1efeb3fc4ba6 | 11 | main() |
mja054 | 0:1efeb3fc4ba6 | 12 | { |
mja054 | 0:1efeb3fc4ba6 | 13 | slcd.printf("1234"); // standard printf function, only charaters in ASCII_TO_WF_CODIFICATION_TABLE will display |
mja054 | 0:1efeb3fc4ba6 | 14 | slcd.putc("A"); // prints a single character |
mja054 | 0:1efeb3fc4ba6 | 15 | slcd.Write_Char('A'); // prints a single character |
mja054 | 0:1efeb3fc4ba6 | 16 | slcd.All_Segments(y); // y=1 for ALL segments on, 0 for ALL segments off |
mja054 | 0:1efeb3fc4ba6 | 17 | slcd.DPx(y); // x=DP1 to DP3, y=1 for on 0 for off |
mja054 | 0:1efeb3fc4ba6 | 18 | slcd.Colon(y); // y=1 for on, 0 for off |
mja054 | 0:1efeb3fc4ba6 | 19 | slcd.CharPosition=x; // x=0 to 3, 0 is start position |
mja054 | 0:1efeb3fc4ba6 | 20 | slcd.Home(); // sets next charater to posistion 0 (start) |
mja054 | 0:1efeb3fc4ba6 | 21 | slcd.Contrast (x); // set contrast x=0 - 15, 0 lightest, 15 darkest |
mja054 | 0:1efeb3fc4ba6 | 22 | } |
mja054 | 0:1efeb3fc4ba6 | 23 | */ |
mja054 | 0:1efeb3fc4ba6 | 24 | |
mja054 | 0:1efeb3fc4ba6 | 25 | class SLCD : public Stream { |
mja054 | 0:1efeb3fc4ba6 | 26 | public: |
mja054 | 0:1efeb3fc4ba6 | 27 | SLCD(); |
mja054 | 0:1efeb3fc4ba6 | 28 | |
mja054 | 0:1efeb3fc4ba6 | 29 | void init(); |
mja054 | 0:1efeb3fc4ba6 | 30 | void Write_Char(char lbValue); |
mja054 | 0:1efeb3fc4ba6 | 31 | void Home (void); |
mja054 | 0:1efeb3fc4ba6 | 32 | void Contrast (uint8_t lbContrast); |
mja054 | 0:1efeb3fc4ba6 | 33 | void All_Segments (int); |
mja054 | 0:1efeb3fc4ba6 | 34 | void DP1 (int); |
mja054 | 0:1efeb3fc4ba6 | 35 | void DP2 (int); |
mja054 | 0:1efeb3fc4ba6 | 36 | void DP3 (int); |
mja054 | 0:1efeb3fc4ba6 | 37 | void Colon (int); |
mja054 | 0:1efeb3fc4ba6 | 38 | uint8_t CharPosition; |
mja054 | 0:1efeb3fc4ba6 | 39 | |
mja054 | 0:1efeb3fc4ba6 | 40 | virtual int _putc(int c); |
mja054 | 0:1efeb3fc4ba6 | 41 | virtual int _getc() { |
mja054 | 0:1efeb3fc4ba6 | 42 | return 0; |
mja054 | 0:1efeb3fc4ba6 | 43 | } |
mja054 | 0:1efeb3fc4ba6 | 44 | }; |