ECE 111 At Oregon State University / SLCD_KL46Z
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SLCD.h Source File

SLCD.h

00001 #pragma once
00002 #include "mbed.h"
00003 
00004 /*  ------ sample usage------
00005 
00006     #include "mbed.h"
00007     #include "SLCD.h"
00008 
00009     SLCD slcd;
00010 
00011     main()
00012     {
00013         slcd.printf("1.2.3.4"); // standard printf function, only charaters in ASCII_TO_WF_CODIFICATION_TABLE will display
00014                                 // Dots printed using decimal points
00015         slcd.putc('A');         // prints a single character
00016         slcd.clear();           // All segments off
00017         slcd.All_Segments(y);   // y=1 for ALL segments on, 0 for ALL segments off
00018         slcd.DP(x, true/false); // Set/Clear decimal point. x=0, 1 or 2.
00019                                 // Does nothing if invalid decimal point
00020         slcd.DPx(y);            // x=DP1 to DP3, y=1 for on 0 for off (legacy)
00021         slcd.Colon(y);          // y=1 for on, 0 for off
00022         slcd.CharPosition=x;    // x=0 to 3, 0 is start position
00023         slcd.Home();            // sets next charater to posistion 0 (start)
00024         slcd.Contrast (x);      // set contrast x=0 - 15, 0 lightest, 15 darkest
00025         slcd.blink(x);          // set display to blink, 0-7 is blink rate (default = 3), -1 disables blink
00026         slcd.deepsleepEnable(x);// true (default) keeps the lcd enabled in deepsleep, false disables its 4MHz internal oscillator clock. Total power consumption ~= 40uA
00027     }
00028 */
00029 
00030 /**
00031 * SLCD peripheral of the FRDM-KL46Z\n
00032 Inherits mbed::Stream and supports the majority of Stream functions.
00033 
00034 @code
00035 #include "mbed.h"
00036 #include "SLCD.h"
00037 
00038 SLCD slcd;
00039 
00040 main()
00041 {
00042     slcd.Home();            // Moves cursor to position 0 (start)
00043     slcd.printf("1.2.3.4"); // Standard printf function, only characters in ASCII_TO_WF_CODIFICATION_TABLE will display
00044     // Dots printed using decimal points
00045     slcd.putc('A');         // Prints a single character
00046     
00047     while(1);   // Wait forever
00048 }
00049 @endcode
00050 */
00051 class SLCD : public Stream
00052 {
00053 public:
00054     //! Construct an SLCD object
00055     SLCD();
00056 
00057     //! Move the SLCD cursor to the first character
00058     void Home();
00059     /**
00060     * Set contrast
00061     * @param lbContrast 0 - 15, 0 lightest, 15 darkest
00062     */
00063     void Contrast (uint8_t lbContrast);
00064     void All_Segments (int);
00065     //! Turn off all segments
00066     void clear();
00067     /**
00068     * Turn a decimal point on or off
00069     * @param pos decimal point position: 0-2
00070     * @param on True or False
00071     */
00072     void DP(int pos, bool on);
00073     void DP1 (int);
00074     void DP2 (int);
00075     void DP3 (int);
00076     //! Turn the colon symbol on or off
00077     void Colon (bool on);
00078     //! Current cursor position
00079     uint8_t CharPosition;
00080     void blink(int blink = 3);
00081     void deepsleepEnable(bool enable);
00082 
00083 private:
00084     void Write_Char(char lbValue);
00085     void init();
00086     virtual int _putc(int c);
00087     virtual int _getc() {
00088         return 0;
00089     }
00090 };