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