6 x 7 segment display library for PCA9637 driven breakout board
Dependents: FTSE100 InternetDispBoB digitalThermometer Counter ... more
dispBoB.h@5:16b047464415, 2011-06-29 (annotated)
- Committer:
- d_worrall
- Date:
- Wed Jun 29 11:36:09 2011 +0000
- Revision:
- 5:16b047464415
- Parent:
- 4:4963731eafd8
- Child:
- 7:adcfb0f5e4de
version1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
d_worrall | 0:843654413849 | 1 | //NXP PCA9635 library |
d_worrall | 0:843654413849 | 2 | //mbed Team - 28th June 2011 |
d_worrall | 0:843654413849 | 3 | //Daniel Worrall |
d_worrall | 0:843654413849 | 4 | |
d_worrall | 0:843654413849 | 5 | #ifndef MBED_DISPBOB_H |
d_worrall | 0:843654413849 | 6 | #define MBED_DISPBOB_H |
d_worrall | 0:843654413849 | 7 | |
d_worrall | 0:843654413849 | 8 | #include "mbed.h" |
d_worrall | 0:843654413849 | 9 | #include "string" |
d_worrall | 0:843654413849 | 10 | #include "PCA9635.h" |
d_worrall | 0:843654413849 | 11 | #include "ctype.h" |
d_worrall | 0:843654413849 | 12 | |
d_worrall | 2:b20aa44dec87 | 13 | /** dispBoB class, defined on the I2C master bus |
d_worrall | 2:b20aa44dec87 | 14 | * |
d_worrall | 2:b20aa44dec87 | 15 | * Example: |
d_worrall | 2:b20aa44dec87 | 16 | * @code |
d_worrall | 2:b20aa44dec87 | 17 | * #include "mbed.h" |
d_worrall | 2:b20aa44dec87 | 18 | * #include "dispBoB.h" |
d_worrall | 2:b20aa44dec87 | 19 | * |
d_worrall | 2:b20aa44dec87 | 20 | * dispBoB db(p28, p27, p26); |
d_worrall | 2:b20aa44dec87 | 21 | * string str = "This is London calling"; |
d_worrall | 2:b20aa44dec87 | 22 | * |
d_worrall | 2:b20aa44dec87 | 23 | * int main() { |
d_worrall | 2:b20aa44dec87 | 24 | * db.cls(); |
d_worrall | 2:b20aa44dec87 | 25 | * while(1){ |
d_worrall | 2:b20aa44dec87 | 26 | * db.scroll(str, 0.25); |
d_worrall | 2:b20aa44dec87 | 27 | * } |
d_worrall | 2:b20aa44dec87 | 28 | * } |
d_worrall | 2:b20aa44dec87 | 29 | * @endcode |
d_worrall | 2:b20aa44dec87 | 30 | */ |
d_worrall | 0:843654413849 | 31 | class dispBoB { |
d_worrall | 0:843654413849 | 32 | public: |
d_worrall | 0:843654413849 | 33 | //constructor |
d_worrall | 2:b20aa44dec87 | 34 | /** Create a dispBoB object defined on the I2C master bus |
d_worrall | 1:d3d2fb119fa3 | 35 | * |
d_worrall | 5:16b047464415 | 36 | * @param sda I2C data line |
d_worrall | 5:16b047464415 | 37 | * @param scl I2C clock line |
d_worrall | 5:16b047464415 | 38 | * @param en enable line |
d_worrall | 1:d3d2fb119fa3 | 39 | */ |
d_worrall | 0:843654413849 | 40 | dispBoB(PinName sda, PinName scl, PinName en); |
d_worrall | 0:843654413849 | 41 | |
d_worrall | 0:843654413849 | 42 | //output control |
d_worrall | 0:843654413849 | 43 | /** Clear screen |
d_worrall | 0:843654413849 | 44 | * |
d_worrall | 0:843654413849 | 45 | */ |
d_worrall | 0:843654413849 | 46 | void cls(void); |
d_worrall | 0:843654413849 | 47 | /** Set cursor position |
d_worrall | 0:843654413849 | 48 | * |
d_worrall | 0:843654413849 | 49 | * @param pos display location left to right (0-5) |
d_worrall | 0:843654413849 | 50 | */ |
d_worrall | 0:843654413849 | 51 | void locate(char pos); |
d_worrall | 0:843654413849 | 52 | /** Put an ASCII encoded character onto display at current location |
d_worrall | 0:843654413849 | 53 | * |
d_worrall | 0:843654413849 | 54 | * @param c ASCII encoded character or number (no punctuation) |
d_worrall | 0:843654413849 | 55 | */ |
d_worrall | 0:843654413849 | 56 | void putc(char c); |
d_worrall | 0:843654413849 | 57 | /** Put an ASCII encoded character onto display at specified location |
d_worrall | 0:843654413849 | 58 | * |
d_worrall | 0:843654413849 | 59 | * @param c ASCII encoded character or number |
d_worrall | 0:843654413849 | 60 | * @param pos display location lef to right (0-5) |
d_worrall | 0:843654413849 | 61 | */ |
d_worrall | 0:843654413849 | 62 | void putc(char c, char pos); |
d_worrall | 0:843654413849 | 63 | /** Write a string to the display |
d_worrall | 0:843654413849 | 64 | * |
d_worrall | 3:e767f379b823 | 65 | * @param str String to be displayed (no punctuation) |
d_worrall | 0:843654413849 | 66 | */ |
d_worrall | 0:843654413849 | 67 | void write(string str); |
d_worrall | 4:4963731eafd8 | 68 | /** Write a scrolling string (right to left) to display |
d_worrall | 0:843654413849 | 69 | * |
d_worrall | 4:4963731eafd8 | 70 | * @param str String to be displayed (no punctuation) |
d_worrall | 0:843654413849 | 71 | * @param speed duration of each frame (seconds) |
d_worrall | 0:843654413849 | 72 | */ |
d_worrall | 0:843654413849 | 73 | void scroll(string str, float speed); |
d_worrall | 0:843654413849 | 74 | |
d_worrall | 0:843654413849 | 75 | private: |
d_worrall | 0:843654413849 | 76 | |
d_worrall | 0:843654413849 | 77 | PCA9635 _pca; |
d_worrall | 0:843654413849 | 78 | DigitalOut _en; |
d_worrall | 0:843654413849 | 79 | char _cursor; |
d_worrall | 0:843654413849 | 80 | }; |
d_worrall | 0:843654413849 | 81 | |
d_worrall | 0:843654413849 | 82 | #endif |
d_worrall | 0:843654413849 | 83 |