Mark Turner
/
lightsense_kl46z_basic_v2
Tried to initialize the buttons and slider but couldn't get it to work.
SLCD/SLCD.h@0:0d6b77c9ae01, 2016-09-19 (annotated)
- Committer:
- mturner5
- Date:
- Mon Sep 19 03:28:41 2016 +0000
- Revision:
- 0:0d6b77c9ae01
basic v2;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mturner5 | 0:0d6b77c9ae01 | 1 | #pragma once |
mturner5 | 0:0d6b77c9ae01 | 2 | #include "mbed.h" |
mturner5 | 0:0d6b77c9ae01 | 3 | |
mturner5 | 0:0d6b77c9ae01 | 4 | /* ------ sample usage------ |
mturner5 | 0:0d6b77c9ae01 | 5 | |
mturner5 | 0:0d6b77c9ae01 | 6 | #include "mbed.h" |
mturner5 | 0:0d6b77c9ae01 | 7 | #include "SLCD.h" |
mturner5 | 0:0d6b77c9ae01 | 8 | |
mturner5 | 0:0d6b77c9ae01 | 9 | SLCD slcd; |
mturner5 | 0:0d6b77c9ae01 | 10 | |
mturner5 | 0:0d6b77c9ae01 | 11 | main() |
mturner5 | 0:0d6b77c9ae01 | 12 | { |
mturner5 | 0:0d6b77c9ae01 | 13 | slcd.printf("1.2.3.4"); // standard printf function, only charaters in ASCII_TO_WF_CODIFICATION_TABLE will display |
mturner5 | 0:0d6b77c9ae01 | 14 | // Dots printed using decimal points |
mturner5 | 0:0d6b77c9ae01 | 15 | slcd.putc('A'); // prints a single character |
mturner5 | 0:0d6b77c9ae01 | 16 | slcd.clear(); // All segments off |
mturner5 | 0:0d6b77c9ae01 | 17 | slcd.All_Segments(y); // y=1 for ALL segments on, 0 for ALL segments off |
mturner5 | 0:0d6b77c9ae01 | 18 | slcd.DP(x, true/false); // Set/Clear decimal point. x=0, 1 or 2. |
mturner5 | 0:0d6b77c9ae01 | 19 | // Does nothing if invalid decimal point |
mturner5 | 0:0d6b77c9ae01 | 20 | slcd.DPx(y); // x=DP1 to DP3, y=1 for on 0 for off (legacy) |
mturner5 | 0:0d6b77c9ae01 | 21 | slcd.Colon(y); // y=1 for on, 0 for off |
mturner5 | 0:0d6b77c9ae01 | 22 | slcd.CharPosition=x; // x=0 to 3, 0 is start position |
mturner5 | 0:0d6b77c9ae01 | 23 | slcd.Home(); // sets next charater to posistion 0 (start) |
mturner5 | 0:0d6b77c9ae01 | 24 | slcd.Contrast (x); // set contrast x=0 - 15, 0 lightest, 15 darkest |
mturner5 | 0:0d6b77c9ae01 | 25 | slcd.blink(x); // set display to blink, 0-7 is blink rate (default = 3), -1 disables blink |
mturner5 | 0:0d6b77c9ae01 | 26 | slcd.deepsleepEnable(x);// true (default) keeps the lcd enabled in deepsleep, false disables its 4MHz internal oscillator clock. Total power consumption ~= 40uA |
mturner5 | 0:0d6b77c9ae01 | 27 | } |
mturner5 | 0:0d6b77c9ae01 | 28 | */ |
mturner5 | 0:0d6b77c9ae01 | 29 | |
mturner5 | 0:0d6b77c9ae01 | 30 | /** |
mturner5 | 0:0d6b77c9ae01 | 31 | * SLCD peripheral of the FRDM-KL46Z\n |
mturner5 | 0:0d6b77c9ae01 | 32 | Inherits mbed::Stream and supports the majority of Stream functions. |
mturner5 | 0:0d6b77c9ae01 | 33 | |
mturner5 | 0:0d6b77c9ae01 | 34 | @code |
mturner5 | 0:0d6b77c9ae01 | 35 | #include "mbed.h" |
mturner5 | 0:0d6b77c9ae01 | 36 | #include "SLCD.h" |
mturner5 | 0:0d6b77c9ae01 | 37 | |
mturner5 | 0:0d6b77c9ae01 | 38 | SLCD slcd; |
mturner5 | 0:0d6b77c9ae01 | 39 | |
mturner5 | 0:0d6b77c9ae01 | 40 | main() |
mturner5 | 0:0d6b77c9ae01 | 41 | { |
mturner5 | 0:0d6b77c9ae01 | 42 | slcd.Home(); // Moves cursor to position 0 (start) |
mturner5 | 0:0d6b77c9ae01 | 43 | slcd.printf("1.2.3.4"); // Standard printf function, only characters in ASCII_TO_WF_CODIFICATION_TABLE will display |
mturner5 | 0:0d6b77c9ae01 | 44 | // Dots printed using decimal points |
mturner5 | 0:0d6b77c9ae01 | 45 | slcd.putc('A'); // Prints a single character |
mturner5 | 0:0d6b77c9ae01 | 46 | |
mturner5 | 0:0d6b77c9ae01 | 47 | while(1); // Wait forever |
mturner5 | 0:0d6b77c9ae01 | 48 | } |
mturner5 | 0:0d6b77c9ae01 | 49 | @endcode |
mturner5 | 0:0d6b77c9ae01 | 50 | */ |
mturner5 | 0:0d6b77c9ae01 | 51 | class SLCD : public Stream |
mturner5 | 0:0d6b77c9ae01 | 52 | { |
mturner5 | 0:0d6b77c9ae01 | 53 | public: |
mturner5 | 0:0d6b77c9ae01 | 54 | //! Construct an SLCD object |
mturner5 | 0:0d6b77c9ae01 | 55 | SLCD(); |
mturner5 | 0:0d6b77c9ae01 | 56 | |
mturner5 | 0:0d6b77c9ae01 | 57 | //! Move the SLCD cursor to the first character |
mturner5 | 0:0d6b77c9ae01 | 58 | void Home(); |
mturner5 | 0:0d6b77c9ae01 | 59 | /** |
mturner5 | 0:0d6b77c9ae01 | 60 | * Set contrast |
mturner5 | 0:0d6b77c9ae01 | 61 | * @param lbContrast 0 - 15, 0 lightest, 15 darkest |
mturner5 | 0:0d6b77c9ae01 | 62 | */ |
mturner5 | 0:0d6b77c9ae01 | 63 | void Contrast (uint8_t lbContrast); |
mturner5 | 0:0d6b77c9ae01 | 64 | void All_Segments (int); |
mturner5 | 0:0d6b77c9ae01 | 65 | //! Turn off all segments |
mturner5 | 0:0d6b77c9ae01 | 66 | void clear(); |
mturner5 | 0:0d6b77c9ae01 | 67 | /** |
mturner5 | 0:0d6b77c9ae01 | 68 | * Turn a decimal point on or off |
mturner5 | 0:0d6b77c9ae01 | 69 | * @param pos decimal point position: 0-2 |
mturner5 | 0:0d6b77c9ae01 | 70 | * @param on True or False |
mturner5 | 0:0d6b77c9ae01 | 71 | */ |
mturner5 | 0:0d6b77c9ae01 | 72 | void DP(int pos, bool on); |
mturner5 | 0:0d6b77c9ae01 | 73 | void DP1 (int); |
mturner5 | 0:0d6b77c9ae01 | 74 | void DP2 (int); |
mturner5 | 0:0d6b77c9ae01 | 75 | void DP3 (int); |
mturner5 | 0:0d6b77c9ae01 | 76 | //! Turn the colon symbol on or off |
mturner5 | 0:0d6b77c9ae01 | 77 | void Colon (bool on); |
mturner5 | 0:0d6b77c9ae01 | 78 | //! Current cursor position |
mturner5 | 0:0d6b77c9ae01 | 79 | uint8_t CharPosition; |
mturner5 | 0:0d6b77c9ae01 | 80 | void blink(int blink = 3); |
mturner5 | 0:0d6b77c9ae01 | 81 | void deepsleepEnable(bool enable); |
mturner5 | 0:0d6b77c9ae01 | 82 | |
mturner5 | 0:0d6b77c9ae01 | 83 | private: |
mturner5 | 0:0d6b77c9ae01 | 84 | void Write_Char(char lbValue); |
mturner5 | 0:0d6b77c9ae01 | 85 | void init(); |
mturner5 | 0:0d6b77c9ae01 | 86 | virtual int _putc(int c); |
mturner5 | 0:0d6b77c9ae01 | 87 | virtual int _getc() { |
mturner5 | 0:0d6b77c9ae01 | 88 | return 0; |
mturner5 | 0:0d6b77c9ae01 | 89 | } |
mturner5 | 0:0d6b77c9ae01 | 90 | }; |