6 x 7 segment display library for PCA9637 driven breakout board

Dependents:   FTSE100 InternetDispBoB digitalThermometer Counter ... more

Committer:
d_worrall
Date:
Thu Jun 30 15:03:18 2011 +0000
Revision:
9:44de04d410df
Parent:
8:a875c4229c57
Child:
12:2235c72db927
version5

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 9:44de04d410df 31 class dispBoB : public Stream {
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 9:44de04d410df 46 virtual 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 9:44de04d410df 51 virtual void locate(char pos);
d_worrall 4:4963731eafd8 52 /** Write a scrolling string (right to left) to display
d_worrall 0:843654413849 53 *
d_worrall 4:4963731eafd8 54 * @param str String to be displayed (no punctuation)
d_worrall 0:843654413849 55 * @param speed duration of each frame (seconds)
d_worrall 0:843654413849 56 */
d_worrall 0:843654413849 57 void scroll(string str, float speed);
d_worrall 8:a875c4229c57 58 /** Same functionality as the bus() function on the PCA9635
d_worrall 8:a875c4229c57 59 *
d_worrall 8:a875c4229c57 60 * @param leds Set output according to parameter value - e.g. 0x0003 >> p0 & p1 high, rest low
d_worrall 8:a875c4229c57 61 */
d_worrall 8:a875c4229c57 62 void bus(short leds);
d_worrall 0:843654413849 63
d_worrall 9:44de04d410df 64 #if DOXYGEN_ONLY
d_worrall 9:44de04d410df 65 /** Write a character to the display
d_worrall 9:44de04d410df 66 *
d_worrall 9:44de04d410df 67 * @param c The character to write to the display
d_worrall 9:44de04d410df 68 */
d_worrall 9:44de04d410df 69 int putc(int c);
d_worrall 9:44de04d410df 70 /** Write a formated string to the LCD
d_worrall 9:44de04d410df 71 *
d_worrall 9:44de04d410df 72 * @param format A printf-style format string, followed by the
d_worrall 9:44de04d410df 73 * variables to use in formating the string. N.B. it will
d_worrall 9:44de04d410df 74 * only display the first 6 characters.
d_worrall 9:44de04d410df 75 */
d_worrall 9:44de04d410df 76 int printf(const char* format, ...);
d_worrall 9:44de04d410df 77 #endif
d_worrall 9:44de04d410df 78
d_worrall 9:44de04d410df 79 protected:
d_worrall 9:44de04d410df 80
d_worrall 9:44de04d410df 81 //Stream implementation functions
d_worrall 9:44de04d410df 82 virtual int _putc(int c);
d_worrall 9:44de04d410df 83 virtual int _getc();
d_worrall 0:843654413849 84
d_worrall 0:843654413849 85 PCA9635 _pca;
d_worrall 0:843654413849 86 DigitalOut _en;
d_worrall 0:843654413849 87 char _cursor;
d_worrall 9:44de04d410df 88 char _pos;
d_worrall 0:843654413849 89 };
d_worrall 0:843654413849 90
d_worrall 0:843654413849 91 #endif
d_worrall 0:843654413849 92