KBrat-SSD541-Final-16-1

Fork of SLCD by Stanley Cohen

Committer:
scohennm
Date:
Mon Nov 28 15:41:43 2016 +0000
Revision:
12:73e8e2c9a5b8
Parent:
11:ee727b8319f4
Child:
14:801a40fce0eb
Upgraded the SLCD library with new location for minus sign.

Who changed what in which revision?

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