KBrat-SSD541-Final-16-1

Fork of SLCD by Stanley Cohen

Committer:
tisbrat
Date:
Mon Dec 05 14:25:01 2016 +0000
Revision:
14:801a40fce0eb
Parent:
12:73e8e2c9a5b8
KBrat-SSD541-Final-16-1

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