6 x 7 segment display library for PCA9637 driven breakout board

Dependents:   FTSE100 InternetDispBoB digitalThermometer Counter ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dispBoB.h Source File

dispBoB.h

00001 //NXP PCA9635 library
00002 //mbed Team     -   28th June 2011
00003 //Daniel Worrall
00004 
00005 #ifndef MBED_DISPBOB_H
00006 #define MBED_DISPBOB_H
00007 
00008 #include "mbed.h"
00009 #include "string"
00010 #include "PCA9635.h"
00011 #include "ctype.h"
00012 
00013 /** dispBoB class, defined on the I2C master bus
00014 * 
00015 * Example:
00016 * @code
00017 * #include "mbed.h"
00018 * #include "dispBoB.h"
00019 *
00020 * dispBoB db(p28, p27, p26);
00021 * string str = "This is London calling";
00022 *
00023 * int main() {
00024 *     db.cls();
00025 *     while(1){
00026 *         db.scroll(str, 0.25);
00027 *     }
00028 * }
00029 * @endcode
00030 */
00031 class dispBoB : public Stream {
00032 public:
00033     //constructor
00034     /** Create a dispBoB object defined on the I2C master bus
00035     *
00036     * @param sda I2C data line
00037     * @param scl I2C clock line
00038     * @param en enable line
00039     */
00040     dispBoB(PinName sda, PinName scl, PinName en);
00041     
00042     //Output control
00043     
00044     /** Initialise device
00045     *
00046     */
00047     void init(void);
00048     /** Clear screen
00049     *
00050     */
00051     virtual void cls(void);
00052     /** Set cursor position
00053     *
00054     * @param pos display location left to right (0-5)
00055     */
00056     virtual void locate(char pos);    
00057     /** Write a scrolling string (right to left) to display 
00058     *
00059     * @param str String to be displayed (no punctuation)
00060     * @param speed duration of each frame (seconds)
00061     */
00062     void scroll(string str, float speed);
00063     /** Same functionality as the bus() function on the PCA9635
00064     *
00065     * @param leds Set output according to parameter value - e.g. 0x0003 >> p0 & p1 high, rest low 
00066     */
00067     void bus(short leds);
00068     
00069 #if DOXYGEN_ONLY
00070     /** Write a character to the display
00071      *
00072      * @param c The character to write to the display
00073      */
00074     int putc(int c);
00075     /** Write a formated string to the LCD
00076      *
00077      * @param format A printf-style format string, followed by the
00078      *               variables to use in formating the string. N.B. it will
00079      *               only display the first 6 characters.
00080      */
00081     int printf(const char* format, ...);
00082 #endif
00083     
00084 protected:
00085 
00086     //Stream implementation functions
00087     virtual int _putc(int c);
00088     virtual int _getc();
00089 
00090     PCA9635 _pca;
00091     DigitalOut _en;
00092     char _cursor; 
00093 };
00094 
00095 #endif
00096