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