Tried to initialize the buttons and slider but couldn't get it to work.

Dependencies:   mbed

Committer:
mturner5
Date:
Mon Sep 19 03:28:41 2016 +0000
Revision:
0:0d6b77c9ae01
basic v2;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mturner5 0:0d6b77c9ae01 1 #include "SLCD.h"
mturner5 0:0d6b77c9ae01 2 #include "LCDconfig.h"
mturner5 0:0d6b77c9ae01 3
mturner5 0:0d6b77c9ae01 4
mturner5 0:0d6b77c9ae01 5 const uint8_t WF_ORDERING_TABLE[ ] = {
mturner5 0:0d6b77c9ae01 6 CHAR1a, // LCD81 --- Pin:5 LCDnAddress=51
mturner5 0:0d6b77c9ae01 7 CHAR1b, // LCD82 --- Pin:6 LCDnAddress=52
mturner5 0:0d6b77c9ae01 8 CHAR2a, // LCD83 --- Pin:7 LCDnAddress=53
mturner5 0:0d6b77c9ae01 9 CHAR2b, // LCD84 --- Pin:8 LCDnAddress=54
mturner5 0:0d6b77c9ae01 10 CHAR3a, // LCD85 --- Pin:9 LCDnAddress=55
mturner5 0:0d6b77c9ae01 11 CHAR3b, // LCD86 --- Pin:10 LCDnAddress=56
mturner5 0:0d6b77c9ae01 12 CHAR4a, // LCD87 --- Pin:11 LCDnAddress=57
mturner5 0:0d6b77c9ae01 13 CHAR4b, // LCD88 --- Pin:12 LCDnAddress=58
mturner5 0:0d6b77c9ae01 14 CHARCOM0, // LCD77 --- Pin:1 LCDnAddress=4D
mturner5 0:0d6b77c9ae01 15 CHARCOM1, // LCD78 --- Pin:2 LCDnAddress=4E
mturner5 0:0d6b77c9ae01 16 CHARCOM2, // LCD79 --- Pin:3 LCDnAddress=4F
mturner5 0:0d6b77c9ae01 17 CHARCOM3, // LCD80 --- Pin:4 LCDnAddress=50
mturner5 0:0d6b77c9ae01 18 };
mturner5 0:0d6b77c9ae01 19
mturner5 0:0d6b77c9ae01 20 const char ASCII_TO_WF_CODIFICATION_TABLE [ ] = {
mturner5 0:0d6b77c9ae01 21
mturner5 0:0d6b77c9ae01 22 /*
mturner5 0:0d6b77c9ae01 23 segA
mturner5 0:0d6b77c9ae01 24 ________
mturner5 0:0d6b77c9ae01 25 | |
mturner5 0:0d6b77c9ae01 26 segF | | segB
mturner5 0:0d6b77c9ae01 27 | |
mturner5 0:0d6b77c9ae01 28 -segG--
mturner5 0:0d6b77c9ae01 29 | |
mturner5 0:0d6b77c9ae01 30 segE | | segC
mturner5 0:0d6b77c9ae01 31 |________|
mturner5 0:0d6b77c9ae01 32 segD
mturner5 0:0d6b77c9ae01 33 */
mturner5 0:0d6b77c9ae01 34
mturner5 0:0d6b77c9ae01 35 ( SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 0, offset=0
mturner5 0:0d6b77c9ae01 36 (!SEGD+!SEGE+!SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = 1, offset=4
mturner5 0:0d6b77c9ae01 37 ( SEGD+ SEGE+!SEGF+ SEGG) , (!SEGC+ SEGB+ SEGA) ,//Char = 2, offset=8
mturner5 0:0d6b77c9ae01 38 ( SEGD+!SEGE+!SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 3, offset=12
mturner5 0:0d6b77c9ae01 39 (!SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = 4, offset=16
mturner5 0:0d6b77c9ae01 40 ( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = 5, offset=20
mturner5 0:0d6b77c9ae01 41 ( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = 6, offset=24
mturner5 0:0d6b77c9ae01 42 (!SEGD+!SEGE+!SEGF+!SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 7, offset=28
mturner5 0:0d6b77c9ae01 43 ( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 8, offset=32
mturner5 0:0d6b77c9ae01 44 ( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 9, offset=36
mturner5 0:0d6b77c9ae01 45 (!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = :, offset=40
mturner5 0:0d6b77c9ae01 46 (!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = ;, offset=44
mturner5 0:0d6b77c9ae01 47 (!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = <, offset=48
mturner5 0:0d6b77c9ae01 48 ( SEGD+!SEGE+!SEGF+ SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = =, offset=52
mturner5 0:0d6b77c9ae01 49 (!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = >, offset=56
mturner5 0:0d6b77c9ae01 50 (!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = ?, offset=60
mturner5 0:0d6b77c9ae01 51 ( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = @, offset=64
mturner5 0:0d6b77c9ae01 52 (!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = A, offset=68
mturner5 0:0d6b77c9ae01 53 ( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = B, offset=72
mturner5 0:0d6b77c9ae01 54 ( SEGD+ SEGE+ SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = C, offset=76
mturner5 0:0d6b77c9ae01 55 ( SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = D, offset=80
mturner5 0:0d6b77c9ae01 56 ( SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = E, offset=84
mturner5 0:0d6b77c9ae01 57 (!SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = F, offset=88
mturner5 0:0d6b77c9ae01 58 ( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = G, offset=92
mturner5 0:0d6b77c9ae01 59 (!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = H, offset=96
mturner5 0:0d6b77c9ae01 60 (!SEGD+!SEGE+!SEGF+!SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = I, offset=100
mturner5 0:0d6b77c9ae01 61 ( SEGD+ SEGE+!SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = J, offset=104
mturner5 0:0d6b77c9ae01 62 (!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = K, offset=108
mturner5 0:0d6b77c9ae01 63 ( SEGD+ SEGE+ SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = L, offset=112
mturner5 0:0d6b77c9ae01 64 (!SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = M, offset=116
mturner5 0:0d6b77c9ae01 65 (!SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = N, offset=120
mturner5 0:0d6b77c9ae01 66 ( SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = O, offset=124
mturner5 0:0d6b77c9ae01 67 (!SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+ SEGB+ SEGA) ,//Char = P, offset=128
mturner5 0:0d6b77c9ae01 68 ( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = Q, offset=132
mturner5 0:0d6b77c9ae01 69 (!SEGD+ SEGE+!SEGF+ SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = R, offset=136
mturner5 0:0d6b77c9ae01 70 ( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = S, offset=140
mturner5 0:0d6b77c9ae01 71 ( SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = T, offset=144
mturner5 0:0d6b77c9ae01 72 ( SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = U, offset=148
mturner5 0:0d6b77c9ae01 73 ( SEGD+ SEGE+!SEGF+!SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = V, offset=152
mturner5 0:0d6b77c9ae01 74 ( SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = W, offset=156
mturner5 0:0d6b77c9ae01 75 (!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = X, offset=160
mturner5 0:0d6b77c9ae01 76 ( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = Y, offset=164
mturner5 0:0d6b77c9ae01 77 ( SEGD+!SEGE+!SEGF+ SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = Z, offset=168
mturner5 0:0d6b77c9ae01 78 ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = [, offset=172
mturner5 0:0d6b77c9ae01 79 ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = \, offset=176
mturner5 0:0d6b77c9ae01 80 ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = ], offset=180
mturner5 0:0d6b77c9ae01 81 ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = ^, offset=184
mturner5 0:0d6b77c9ae01 82 ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = _, offset=188
mturner5 0:0d6b77c9ae01 83 ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = `, offset=192
mturner5 0:0d6b77c9ae01 84 };
mturner5 0:0d6b77c9ae01 85
mturner5 0:0d6b77c9ae01 86 SLCD::SLCD()
mturner5 0:0d6b77c9ae01 87 {
mturner5 0:0d6b77c9ae01 88 init();
mturner5 0:0d6b77c9ae01 89 CharPosition = 0;
mturner5 0:0d6b77c9ae01 90 }
mturner5 0:0d6b77c9ae01 91
mturner5 0:0d6b77c9ae01 92 void SLCD::init()
mturner5 0:0d6b77c9ae01 93 {
mturner5 0:0d6b77c9ae01 94 SIM->SCGC5 |= SIM_SCGC5_SLCD_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK;
mturner5 0:0d6b77c9ae01 95
mturner5 0:0d6b77c9ae01 96 // configure pins for LCD operation
mturner5 0:0d6b77c9ae01 97 PORTC->PCR[20] = 0x00000000; //VLL2
mturner5 0:0d6b77c9ae01 98 PORTC->PCR[21] = 0x00000000; //VLL1
mturner5 0:0d6b77c9ae01 99 PORTC->PCR[22] = 0x00000000; //VCAP2
mturner5 0:0d6b77c9ae01 100 PORTC->PCR[23] = 0x00000000; //VCAP1
mturner5 0:0d6b77c9ae01 101 // Enable IRCLK
mturner5 0:0d6b77c9ae01 102 MCG->C1 |= MCG_C1_IRCLKEN_MASK | MCG_C1_IREFSTEN_MASK;
mturner5 0:0d6b77c9ae01 103 MCG->C2 |= MCG_C2_IRCS_MASK ; //0 32KHZ internal reference clock; 1= 4MHz irc
mturner5 0:0d6b77c9ae01 104
mturner5 0:0d6b77c9ae01 105 //Check if the Fast reference has its divide by 2 enabled (default):
mturner5 0:0d6b77c9ae01 106 if ((MCG->SC & MCG_SC_FCRDIV_MASK) != 1<<1)
mturner5 0:0d6b77c9ae01 107 error("Invalid clock configuration for SLCD\n");
mturner5 0:0d6b77c9ae01 108 LCD->GCR = 0x0;
mturner5 0:0d6b77c9ae01 109 LCD->AR = 0x0;
mturner5 0:0d6b77c9ae01 110
mturner5 0:0d6b77c9ae01 111 // LCD configurartion
mturner5 0:0d6b77c9ae01 112 LCD->GCR = ( LCD_GCR_RVEN_MASK*_LCDRVEN
mturner5 0:0d6b77c9ae01 113 | LCD_GCR_RVTRIM(_LCDRVTRIM) //0-15
mturner5 0:0d6b77c9ae01 114 | LCD_GCR_CPSEL_MASK*_LCDCPSEL
mturner5 0:0d6b77c9ae01 115 | LCD_GCR_LADJ(_LCDLOADADJUST) //0-3
mturner5 0:0d6b77c9ae01 116 | LCD_GCR_VSUPPLY_MASK*_LCDSUPPLY //0-1
mturner5 0:0d6b77c9ae01 117 |!LCD_GCR_FDCIEN_MASK
mturner5 0:0d6b77c9ae01 118 | LCD_GCR_ALTDIV(1) //divide by something
mturner5 0:0d6b77c9ae01 119 |!LCD_GCR_LCDDOZE_MASK
mturner5 0:0d6b77c9ae01 120 |!LCD_GCR_LCDSTP_MASK
mturner5 0:0d6b77c9ae01 121 |!LCD_GCR_LCDEN_MASK //WILL BE ENABLE ON SUBSEQUENT STEP
mturner5 0:0d6b77c9ae01 122 | LCD_GCR_SOURCE_MASK*1
mturner5 0:0d6b77c9ae01 123 | LCD_GCR_ALTSOURCE_MASK*0
mturner5 0:0d6b77c9ae01 124 | LCD_GCR_LCLK(0) //0-7
mturner5 0:0d6b77c9ae01 125 | LCD_GCR_DUTY(_LCDDUTY) //0-7
mturner5 0:0d6b77c9ae01 126 );
mturner5 0:0d6b77c9ae01 127 uint8_t i;
mturner5 0:0d6b77c9ae01 128 uint32_t *p_pen;
mturner5 0:0d6b77c9ae01 129 uint8_t pen_offset; // 0 or 1
mturner5 0:0d6b77c9ae01 130 uint8_t pen_bit; // 0 to 31
mturner5 0:0d6b77c9ae01 131 LCD->PEN[0] = 0x0;
mturner5 0:0d6b77c9ae01 132 LCD->PEN[1] = 0x0;
mturner5 0:0d6b77c9ae01 133 LCD->BPEN[0] = 0x0;
mturner5 0:0d6b77c9ae01 134 LCD->BPEN[1] = 0x0;
mturner5 0:0d6b77c9ae01 135 p_pen = (uint32_t *)&LCD->PEN[0];
mturner5 0:0d6b77c9ae01 136 for (i=0; i<_LCDUSEDPINS; i++) {
mturner5 0:0d6b77c9ae01 137 pen_offset = WF_ORDERING_TABLE[i]/32;
mturner5 0:0d6b77c9ae01 138 pen_bit = WF_ORDERING_TABLE[i]%32;
mturner5 0:0d6b77c9ae01 139 p_pen[pen_offset] |= 1 << pen_bit;
mturner5 0:0d6b77c9ae01 140 if (i>= _LCDFRONTPLANES) { // Pin is a backplane
mturner5 0:0d6b77c9ae01 141 p_pen[pen_offset+2] |= 1 << pen_bit; // Enable BPEN
mturner5 0:0d6b77c9ae01 142 LCD->WF8B[(uint8_t)WF_ORDERING_TABLE[i]] = 1 << (i - _LCDFRONTPLANES); // fill with 0x01, 0x02, etc
mturner5 0:0d6b77c9ae01 143 }
mturner5 0:0d6b77c9ae01 144 }
mturner5 0:0d6b77c9ae01 145 LCD->GCR |= LCD_GCR_LCDEN_MASK;
mturner5 0:0d6b77c9ae01 146 }
mturner5 0:0d6b77c9ae01 147
mturner5 0:0d6b77c9ae01 148 int SLCD::_putc(int c)
mturner5 0:0d6b77c9ae01 149 {
mturner5 0:0d6b77c9ae01 150 Write_Char(c);
mturner5 0:0d6b77c9ae01 151 return 0;
mturner5 0:0d6b77c9ae01 152 }
mturner5 0:0d6b77c9ae01 153
mturner5 0:0d6b77c9ae01 154 void SLCD::Write_Char (char lbValue)
mturner5 0:0d6b77c9ae01 155 {
mturner5 0:0d6b77c9ae01 156 if (CharPosition >= _CHARNUM)
mturner5 0:0d6b77c9ae01 157 CharPosition = 0;
mturner5 0:0d6b77c9ae01 158
mturner5 0:0d6b77c9ae01 159 if (lbValue == '.') {
mturner5 0:0d6b77c9ae01 160 // Use built-in dot
mturner5 0:0d6b77c9ae01 161 DP(CharPosition-1, true);
mturner5 0:0d6b77c9ae01 162 return;
mturner5 0:0d6b77c9ae01 163 }
mturner5 0:0d6b77c9ae01 164
mturner5 0:0d6b77c9ae01 165 uint8_t char_val;
mturner5 0:0d6b77c9ae01 166 uint8_t temp;
mturner5 0:0d6b77c9ae01 167 uint8_t *lbpLCDWF;
mturner5 0:0d6b77c9ae01 168 uint8_t lbCounter;
mturner5 0:0d6b77c9ae01 169 uint16_t arrayOffset;
mturner5 0:0d6b77c9ae01 170 uint8_t position;
mturner5 0:0d6b77c9ae01 171
mturner5 0:0d6b77c9ae01 172 lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
mturner5 0:0d6b77c9ae01 173 /* only ascii character if value not writeable write as @ */
mturner5 0:0d6b77c9ae01 174 if (lbValue>='a' && lbValue<='z') {
mturner5 0:0d6b77c9ae01 175 lbValue -= 32; // UpperCase
mturner5 0:0d6b77c9ae01 176 }
mturner5 0:0d6b77c9ae01 177 if (lbValue<ASCCI_TABLE_START || lbValue >ASCCI_TABLE_END) {
mturner5 0:0d6b77c9ae01 178 lbValue = BLANK_CHARACTER; // default value as space
mturner5 0:0d6b77c9ae01 179 }
mturner5 0:0d6b77c9ae01 180 lbValue -=ASCCI_TABLE_START; // Remove the offset to search in the ascci table
mturner5 0:0d6b77c9ae01 181 arrayOffset = (lbValue * _CHAR_SIZE); // Compensate matrix offset
mturner5 0:0d6b77c9ae01 182 // ensure bLCD position is in valid limit
mturner5 0:0d6b77c9ae01 183 lbCounter = 0; //number of writings to complete one char
mturner5 0:0d6b77c9ae01 184 while (lbCounter<_CHAR_SIZE) {
mturner5 0:0d6b77c9ae01 185 position = (CharPosition) *_LCDTYPE + lbCounter;
mturner5 0:0d6b77c9ae01 186 temp=0;
mturner5 0:0d6b77c9ae01 187 if (lbCounter==1) {
mturner5 0:0d6b77c9ae01 188 temp = lbpLCDWF[WF_ORDERING_TABLE[position]] & 0x01;//bit 0 has the special symbol information
mturner5 0:0d6b77c9ae01 189 }
mturner5 0:0d6b77c9ae01 190 char_val = ASCII_TO_WF_CODIFICATION_TABLE[arrayOffset + lbCounter];
mturner5 0:0d6b77c9ae01 191 lbpLCDWF[WF_ORDERING_TABLE[position]] = char_val | temp;
mturner5 0:0d6b77c9ae01 192 // if (char_val==0) lbCounter = _CHAR_SIZE; //end of this character
mturner5 0:0d6b77c9ae01 193 lbCounter++;
mturner5 0:0d6b77c9ae01 194 }
mturner5 0:0d6b77c9ae01 195 CharPosition++;
mturner5 0:0d6b77c9ae01 196 }
mturner5 0:0d6b77c9ae01 197
mturner5 0:0d6b77c9ae01 198 void SLCD::Home()
mturner5 0:0d6b77c9ae01 199 {
mturner5 0:0d6b77c9ae01 200 CharPosition = 0;
mturner5 0:0d6b77c9ae01 201 }
mturner5 0:0d6b77c9ae01 202
mturner5 0:0d6b77c9ae01 203 void SLCD::Contrast (uint8_t lbContrast)
mturner5 0:0d6b77c9ae01 204 {
mturner5 0:0d6b77c9ae01 205 lbContrast &= 0x0F; //Forced to the only values accepted
mturner5 0:0d6b77c9ae01 206 LCD->GCR |= LCD_GCR_RVTRIM(lbContrast);
mturner5 0:0d6b77c9ae01 207 }
mturner5 0:0d6b77c9ae01 208
mturner5 0:0d6b77c9ae01 209 void SLCD::clear()
mturner5 0:0d6b77c9ae01 210 {
mturner5 0:0d6b77c9ae01 211 All_Segments(0);
mturner5 0:0d6b77c9ae01 212 }
mturner5 0:0d6b77c9ae01 213
mturner5 0:0d6b77c9ae01 214 void SLCD::All_Segments (int mode)
mturner5 0:0d6b77c9ae01 215 {
mturner5 0:0d6b77c9ae01 216 uint8_t lbTotalBytes = _CHARNUM * _LCDTYPE;
mturner5 0:0d6b77c9ae01 217 uint8_t lbCounter=0;
mturner5 0:0d6b77c9ae01 218 uint8_t *lbpLCDWF;
mturner5 0:0d6b77c9ae01 219
mturner5 0:0d6b77c9ae01 220 lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
mturner5 0:0d6b77c9ae01 221 while (lbCounter < lbTotalBytes) {
mturner5 0:0d6b77c9ae01 222 if (mode==1) {
mturner5 0:0d6b77c9ae01 223 lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[lbCounter++]]=_ALLON;
mturner5 0:0d6b77c9ae01 224 } else {
mturner5 0:0d6b77c9ae01 225 lbpLCDWF[WF_ORDERING_TABLE[lbCounter++]]=0;
mturner5 0:0d6b77c9ae01 226 }
mturner5 0:0d6b77c9ae01 227 }
mturner5 0:0d6b77c9ae01 228 }
mturner5 0:0d6b77c9ae01 229
mturner5 0:0d6b77c9ae01 230 void SLCD::DP(int pos, bool on)
mturner5 0:0d6b77c9ae01 231 {
mturner5 0:0d6b77c9ae01 232 uint8_t *lbpLCDWF;
mturner5 0:0d6b77c9ae01 233 int tableLoc;
mturner5 0:0d6b77c9ae01 234 switch (pos) {
mturner5 0:0d6b77c9ae01 235 case 0:
mturner5 0:0d6b77c9ae01 236 tableLoc = 1;
mturner5 0:0d6b77c9ae01 237 break;
mturner5 0:0d6b77c9ae01 238 case 1:
mturner5 0:0d6b77c9ae01 239 tableLoc = 3;
mturner5 0:0d6b77c9ae01 240 break;
mturner5 0:0d6b77c9ae01 241 case 2:
mturner5 0:0d6b77c9ae01 242 tableLoc = 5;
mturner5 0:0d6b77c9ae01 243 break;
mturner5 0:0d6b77c9ae01 244 default:
mturner5 0:0d6b77c9ae01 245 return; // Bad position
mturner5 0:0d6b77c9ae01 246 }
mturner5 0:0d6b77c9ae01 247 lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
mturner5 0:0d6b77c9ae01 248 if (on) {
mturner5 0:0d6b77c9ae01 249 lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[tableLoc]]|=1;
mturner5 0:0d6b77c9ae01 250 } else {
mturner5 0:0d6b77c9ae01 251 lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[tableLoc]]&=~1;
mturner5 0:0d6b77c9ae01 252 }
mturner5 0:0d6b77c9ae01 253 }
mturner5 0:0d6b77c9ae01 254
mturner5 0:0d6b77c9ae01 255 void SLCD::DP1 (int mode)
mturner5 0:0d6b77c9ae01 256 {
mturner5 0:0d6b77c9ae01 257 DP(0, mode==1);
mturner5 0:0d6b77c9ae01 258 }
mturner5 0:0d6b77c9ae01 259
mturner5 0:0d6b77c9ae01 260 void SLCD::DP2 (int mode)
mturner5 0:0d6b77c9ae01 261 {
mturner5 0:0d6b77c9ae01 262 DP(1, mode==1);
mturner5 0:0d6b77c9ae01 263 }
mturner5 0:0d6b77c9ae01 264
mturner5 0:0d6b77c9ae01 265 void SLCD::DP3 (int mode)
mturner5 0:0d6b77c9ae01 266 {
mturner5 0:0d6b77c9ae01 267 DP(2, mode==1);
mturner5 0:0d6b77c9ae01 268 }
mturner5 0:0d6b77c9ae01 269
mturner5 0:0d6b77c9ae01 270 void SLCD::Colon (bool on)
mturner5 0:0d6b77c9ae01 271 {
mturner5 0:0d6b77c9ae01 272 uint8_t *lbpLCDWF;
mturner5 0:0d6b77c9ae01 273 lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
mturner5 0:0d6b77c9ae01 274 if (on) {
mturner5 0:0d6b77c9ae01 275 lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]|=1;
mturner5 0:0d6b77c9ae01 276 } else {
mturner5 0:0d6b77c9ae01 277 lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]&=~1;
mturner5 0:0d6b77c9ae01 278 }
mturner5 0:0d6b77c9ae01 279 }
mturner5 0:0d6b77c9ae01 280
mturner5 0:0d6b77c9ae01 281 void SLCD::blink(int blink)
mturner5 0:0d6b77c9ae01 282 {
mturner5 0:0d6b77c9ae01 283 if (( blink > 7) || (blink < 0))
mturner5 0:0d6b77c9ae01 284 LCD->AR &= ~LCD_AR_BLINK_MASK;
mturner5 0:0d6b77c9ae01 285 else
mturner5 0:0d6b77c9ae01 286 LCD->AR |= LCD_AR_BLINK_MASK | blink;
mturner5 0:0d6b77c9ae01 287 }
mturner5 0:0d6b77c9ae01 288
mturner5 0:0d6b77c9ae01 289 void SLCD::deepsleepEnable(bool enable)
mturner5 0:0d6b77c9ae01 290 {
mturner5 0:0d6b77c9ae01 291 MCG->C1 &= ~MCG_C1_IREFSTEN_MASK;
mturner5 0:0d6b77c9ae01 292 MCG->C1 |= enable << MCG_C1_IREFSTEN_SHIFT;
mturner5 0:0d6b77c9ae01 293 LCD->GCR &= ~LCD_GCR_LCDSTP_MASK;
mturner5 0:0d6b77c9ae01 294 LCD->GCR |= (!enable) << LCD_GCR_LCDSTP_SHIFT;
mturner5 0:0d6b77c9ae01 295 }