6 x 7 segment display library for PCA9637 driven breakout board

Dependents:   FTSE100 InternetDispBoB digitalThermometer Counter ... more

Committer:
d_worrall
Date:
Wed Jun 29 11:33:36 2011 +0000
Revision:
4:4963731eafd8
Parent:
3:e767f379b823
Child:
5:16b047464415
version1

Who changed what in which revision?

UserRevisionLine numberNew 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 1:d3d2fb119fa3 36 */
d_worrall 0:843654413849 37 dispBoB(PinName sda, PinName scl, PinName en);
d_worrall 0:843654413849 38
d_worrall 0:843654413849 39 //output control
d_worrall 0:843654413849 40 /** Clear screen
d_worrall 0:843654413849 41 *
d_worrall 0:843654413849 42 */
d_worrall 0:843654413849 43 void cls(void);
d_worrall 0:843654413849 44 /** Set cursor position
d_worrall 0:843654413849 45 *
d_worrall 0:843654413849 46 * @param pos display location left to right (0-5)
d_worrall 0:843654413849 47 */
d_worrall 0:843654413849 48 void locate(char pos);
d_worrall 0:843654413849 49 /** Put an ASCII encoded character onto display at current location
d_worrall 0:843654413849 50 *
d_worrall 0:843654413849 51 * @param c ASCII encoded character or number (no punctuation)
d_worrall 0:843654413849 52 */
d_worrall 0:843654413849 53 void putc(char c);
d_worrall 0:843654413849 54 /** Put an ASCII encoded character onto display at specified location
d_worrall 0:843654413849 55 *
d_worrall 0:843654413849 56 * @param c ASCII encoded character or number
d_worrall 0:843654413849 57 * @param pos display location lef to right (0-5)
d_worrall 0:843654413849 58 */
d_worrall 0:843654413849 59 void putc(char c, char pos);
d_worrall 0:843654413849 60 /** Write a string to the display
d_worrall 0:843654413849 61 *
d_worrall 3:e767f379b823 62 * @param str String to be displayed (no punctuation)
d_worrall 0:843654413849 63 */
d_worrall 0:843654413849 64 void write(string str);
d_worrall 4:4963731eafd8 65 /** Write a scrolling string (right to left) to display
d_worrall 0:843654413849 66 *
d_worrall 4:4963731eafd8 67 * @param str String to be displayed (no punctuation)
d_worrall 0:843654413849 68 * @param speed duration of each frame (seconds)
d_worrall 0:843654413849 69 */
d_worrall 0:843654413849 70 void scroll(string str, float speed);
d_worrall 0:843654413849 71
d_worrall 0:843654413849 72 private:
d_worrall 0:843654413849 73
d_worrall 0:843654413849 74 PCA9635 _pca;
d_worrall 0:843654413849 75 DigitalOut _en;
d_worrall 0:843654413849 76 char _cursor;
d_worrall 0:843654413849 77 };
d_worrall 0:843654413849 78
d_worrall 0:843654413849 79 #endif
d_worrall 0:843654413849 80