Junaid Ahmed
/
202A_HW1
Configuring sensors dynamically using serial bus from the host computer.
SLCD/SLCD.cpp@2:a422a41dbea1, 2014-02-15 (annotated)
- Committer:
- mja054
- Date:
- Sat Feb 15 00:46:41 2014 +0000
- Revision:
- 2:a422a41dbea1
- Parent:
- 0:1efeb3fc4ba6
Send the time delay
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mja054 | 0:1efeb3fc4ba6 | 1 | #include "SLCD.h" |
mja054 | 0:1efeb3fc4ba6 | 2 | #include "LCDconfig.h" |
mja054 | 0:1efeb3fc4ba6 | 3 | |
mja054 | 0:1efeb3fc4ba6 | 4 | |
mja054 | 0:1efeb3fc4ba6 | 5 | const uint8_t WF_ORDERING_TABLE[ ] = |
mja054 | 0:1efeb3fc4ba6 | 6 | { |
mja054 | 0:1efeb3fc4ba6 | 7 | CHAR1a, // LCD81 --- Pin:5 LCDnAddress=51 |
mja054 | 0:1efeb3fc4ba6 | 8 | CHAR1b, // LCD82 --- Pin:6 LCDnAddress=52 |
mja054 | 0:1efeb3fc4ba6 | 9 | CHAR2a, // LCD83 --- Pin:7 LCDnAddress=53 |
mja054 | 0:1efeb3fc4ba6 | 10 | CHAR2b, // LCD84 --- Pin:8 LCDnAddress=54 |
mja054 | 0:1efeb3fc4ba6 | 11 | CHAR3a, // LCD85 --- Pin:9 LCDnAddress=55 |
mja054 | 0:1efeb3fc4ba6 | 12 | CHAR3b, // LCD86 --- Pin:10 LCDnAddress=56 |
mja054 | 0:1efeb3fc4ba6 | 13 | CHAR4a, // LCD87 --- Pin:11 LCDnAddress=57 |
mja054 | 0:1efeb3fc4ba6 | 14 | CHAR4b, // LCD88 --- Pin:12 LCDnAddress=58 |
mja054 | 0:1efeb3fc4ba6 | 15 | CHARCOM0, // LCD77 --- Pin:1 LCDnAddress=4D |
mja054 | 0:1efeb3fc4ba6 | 16 | CHARCOM1, // LCD78 --- Pin:2 LCDnAddress=4E |
mja054 | 0:1efeb3fc4ba6 | 17 | CHARCOM2, // LCD79 --- Pin:3 LCDnAddress=4F |
mja054 | 0:1efeb3fc4ba6 | 18 | CHARCOM3, // LCD80 --- Pin:4 LCDnAddress=50 |
mja054 | 0:1efeb3fc4ba6 | 19 | }; |
mja054 | 0:1efeb3fc4ba6 | 20 | |
mja054 | 0:1efeb3fc4ba6 | 21 | const char ASCII_TO_WF_CODIFICATION_TABLE [ ] = |
mja054 | 0:1efeb3fc4ba6 | 22 | { |
mja054 | 0:1efeb3fc4ba6 | 23 | |
mja054 | 0:1efeb3fc4ba6 | 24 | /* |
mja054 | 0:1efeb3fc4ba6 | 25 | segA |
mja054 | 0:1efeb3fc4ba6 | 26 | ________ |
mja054 | 0:1efeb3fc4ba6 | 27 | | | |
mja054 | 0:1efeb3fc4ba6 | 28 | segF | | segB |
mja054 | 0:1efeb3fc4ba6 | 29 | | | |
mja054 | 0:1efeb3fc4ba6 | 30 | -segG-- |
mja054 | 0:1efeb3fc4ba6 | 31 | | | |
mja054 | 0:1efeb3fc4ba6 | 32 | segE | | segC |
mja054 | 0:1efeb3fc4ba6 | 33 | |________| |
mja054 | 0:1efeb3fc4ba6 | 34 | segD |
mja054 | 0:1efeb3fc4ba6 | 35 | */ |
mja054 | 0:1efeb3fc4ba6 | 36 | |
mja054 | 0:1efeb3fc4ba6 | 37 | ( SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 0, offset=0 |
mja054 | 0:1efeb3fc4ba6 | 38 | (!SEGD+!SEGE+!SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = 1, offset=4 |
mja054 | 0:1efeb3fc4ba6 | 39 | ( SEGD+ SEGE+!SEGF+ SEGG) , (!SEGC+ SEGB+ SEGA) ,//Char = 2, offset=8 |
mja054 | 0:1efeb3fc4ba6 | 40 | ( SEGD+!SEGE+!SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 3, offset=12 |
mja054 | 0:1efeb3fc4ba6 | 41 | (!SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = 4, offset=16 |
mja054 | 0:1efeb3fc4ba6 | 42 | ( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = 5, offset=20 |
mja054 | 0:1efeb3fc4ba6 | 43 | ( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = 6, offset=24 |
mja054 | 0:1efeb3fc4ba6 | 44 | (!SEGD+!SEGE+!SEGF+!SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 7, offset=28 |
mja054 | 0:1efeb3fc4ba6 | 45 | ( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 8, offset=32 |
mja054 | 0:1efeb3fc4ba6 | 46 | ( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 9, offset=36 |
mja054 | 0:1efeb3fc4ba6 | 47 | (!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = :, offset=40 |
mja054 | 0:1efeb3fc4ba6 | 48 | (!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = ;, offset=44 |
mja054 | 0:1efeb3fc4ba6 | 49 | (!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = <, offset=48 |
mja054 | 0:1efeb3fc4ba6 | 50 | ( SEGD+!SEGE+!SEGF+ SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = =, offset=52 |
mja054 | 0:1efeb3fc4ba6 | 51 | (!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = >, offset=56 |
mja054 | 0:1efeb3fc4ba6 | 52 | (!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = ?, offset=60 |
mja054 | 0:1efeb3fc4ba6 | 53 | ( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = @, offset=64 |
mja054 | 0:1efeb3fc4ba6 | 54 | (!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = A, offset=68 |
mja054 | 0:1efeb3fc4ba6 | 55 | ( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = B, offset=72 |
mja054 | 0:1efeb3fc4ba6 | 56 | ( SEGD+ SEGE+ SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = C, offset=76 |
mja054 | 0:1efeb3fc4ba6 | 57 | ( SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = D, offset=80 |
mja054 | 0:1efeb3fc4ba6 | 58 | ( SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = E, offset=84 |
mja054 | 0:1efeb3fc4ba6 | 59 | (!SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = F, offset=88 |
mja054 | 0:1efeb3fc4ba6 | 60 | ( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = G, offset=92 |
mja054 | 0:1efeb3fc4ba6 | 61 | (!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = H, offset=96 |
mja054 | 0:1efeb3fc4ba6 | 62 | (!SEGD+!SEGE+!SEGF+!SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = I, offset=100 |
mja054 | 0:1efeb3fc4ba6 | 63 | ( SEGD+ SEGE+!SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = J, offset=104 |
mja054 | 0:1efeb3fc4ba6 | 64 | (!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = K, offset=108 |
mja054 | 0:1efeb3fc4ba6 | 65 | ( SEGD+ SEGE+ SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = L, offset=112 |
mja054 | 0:1efeb3fc4ba6 | 66 | (!SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = M, offset=116 |
mja054 | 0:1efeb3fc4ba6 | 67 | (!SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = N, offset=120 |
mja054 | 0:1efeb3fc4ba6 | 68 | ( SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = O, offset=124 |
mja054 | 0:1efeb3fc4ba6 | 69 | (!SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+ SEGB+ SEGA) ,//Char = P, offset=128 |
mja054 | 0:1efeb3fc4ba6 | 70 | ( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = Q, offset=132 |
mja054 | 0:1efeb3fc4ba6 | 71 | (!SEGD+ SEGE+!SEGF+ SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = R, offset=136 |
mja054 | 0:1efeb3fc4ba6 | 72 | ( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = S, offset=140 |
mja054 | 0:1efeb3fc4ba6 | 73 | ( SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = T, offset=144 |
mja054 | 0:1efeb3fc4ba6 | 74 | ( SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = U, offset=148 |
mja054 | 0:1efeb3fc4ba6 | 75 | ( SEGD+ SEGE+!SEGF+!SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = V, offset=152 |
mja054 | 0:1efeb3fc4ba6 | 76 | ( SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = W, offset=156 |
mja054 | 0:1efeb3fc4ba6 | 77 | (!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = X, offset=160 |
mja054 | 0:1efeb3fc4ba6 | 78 | ( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = Y, offset=164 |
mja054 | 0:1efeb3fc4ba6 | 79 | ( SEGD+!SEGE+!SEGF+ SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = Z, offset=168 |
mja054 | 0:1efeb3fc4ba6 | 80 | ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = [, offset=172 |
mja054 | 0:1efeb3fc4ba6 | 81 | ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = \, offset=176 |
mja054 | 0:1efeb3fc4ba6 | 82 | ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = ], offset=180 |
mja054 | 0:1efeb3fc4ba6 | 83 | ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = ^, offset=184 |
mja054 | 0:1efeb3fc4ba6 | 84 | ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = _, offset=188 |
mja054 | 0:1efeb3fc4ba6 | 85 | ( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = `, offset=192 |
mja054 | 0:1efeb3fc4ba6 | 86 | }; |
mja054 | 0:1efeb3fc4ba6 | 87 | |
mja054 | 0:1efeb3fc4ba6 | 88 | SLCD::SLCD() { |
mja054 | 0:1efeb3fc4ba6 | 89 | init(); |
mja054 | 0:1efeb3fc4ba6 | 90 | CharPosition = 0; |
mja054 | 0:1efeb3fc4ba6 | 91 | } |
mja054 | 0:1efeb3fc4ba6 | 92 | |
mja054 | 0:1efeb3fc4ba6 | 93 | void SLCD::init(){ |
mja054 | 0:1efeb3fc4ba6 | 94 | SIM->SCGC5 |= SIM_SCGC5_SLCD_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK; |
mja054 | 0:1efeb3fc4ba6 | 95 | |
mja054 | 0:1efeb3fc4ba6 | 96 | // configure pins for LCD operation |
mja054 | 0:1efeb3fc4ba6 | 97 | PORTC->PCR[20] = 0x00000000; //VLL2 |
mja054 | 0:1efeb3fc4ba6 | 98 | PORTC->PCR[21] = 0x00000000; //VLL1 |
mja054 | 0:1efeb3fc4ba6 | 99 | PORTC->PCR[22] = 0x00000000; //VCAP2 |
mja054 | 0:1efeb3fc4ba6 | 100 | PORTC->PCR[23] = 0x00000000; //VCAP1 |
mja054 | 0:1efeb3fc4ba6 | 101 | // Enable IRCLK |
mja054 | 0:1efeb3fc4ba6 | 102 | MCG->C1 = MCG_C1_IRCLKEN_MASK | MCG_C1_IREFSTEN_MASK; |
mja054 | 0:1efeb3fc4ba6 | 103 | MCG->C2 &= ~MCG_C2_IRCS_MASK ; //0 32KHZ internal reference clock; 1= 4MHz irc |
mja054 | 0:1efeb3fc4ba6 | 104 | LCD->GCR = 0x0; |
mja054 | 0:1efeb3fc4ba6 | 105 | LCD->AR = 0x0; |
mja054 | 0:1efeb3fc4ba6 | 106 | // LCD configurartion |
mja054 | 0:1efeb3fc4ba6 | 107 | LCD->GCR = ( LCD_GCR_RVEN_MASK*_LCDRVEN |
mja054 | 0:1efeb3fc4ba6 | 108 | | LCD_GCR_RVTRIM(_LCDRVTRIM) //0-15 |
mja054 | 0:1efeb3fc4ba6 | 109 | | LCD_GCR_CPSEL_MASK*_LCDCPSEL |
mja054 | 0:1efeb3fc4ba6 | 110 | | LCD_GCR_LADJ(_LCDLOADADJUST) //0-3 |
mja054 | 0:1efeb3fc4ba6 | 111 | | LCD_GCR_VSUPPLY_MASK*_LCDSUPPLY //0-1 |
mja054 | 0:1efeb3fc4ba6 | 112 | |!LCD_GCR_FDCIEN_MASK |
mja054 | 0:1efeb3fc4ba6 | 113 | | LCD_GCR_ALTDIV(_LCDALTDIV) //0-3 |
mja054 | 0:1efeb3fc4ba6 | 114 | |!LCD_GCR_LCDDOZE_MASK |
mja054 | 0:1efeb3fc4ba6 | 115 | |!LCD_GCR_LCDSTP_MASK |
mja054 | 0:1efeb3fc4ba6 | 116 | |!LCD_GCR_LCDEN_MASK //WILL BE ENABLE ON SUBSEQUENT STEP |
mja054 | 0:1efeb3fc4ba6 | 117 | | LCD_GCR_SOURCE_MASK*_LCDCLKSOURCE |
mja054 | 0:1efeb3fc4ba6 | 118 | | LCD_GCR_ALTSOURCE_MASK*_LCDALRCLKSOURCE |
mja054 | 0:1efeb3fc4ba6 | 119 | | LCD_GCR_LCLK(_LCDLCK) //0-7 |
mja054 | 0:1efeb3fc4ba6 | 120 | | LCD_GCR_DUTY(_LCDDUTY) //0-7 |
mja054 | 0:1efeb3fc4ba6 | 121 | ); |
mja054 | 0:1efeb3fc4ba6 | 122 | uint8_t i; |
mja054 | 0:1efeb3fc4ba6 | 123 | uint32_t *p_pen; |
mja054 | 0:1efeb3fc4ba6 | 124 | uint8_t pen_offset; // 0 or 1 |
mja054 | 0:1efeb3fc4ba6 | 125 | uint8_t pen_bit; // 0 to 31 |
mja054 | 0:1efeb3fc4ba6 | 126 | LCD->PEN[0] = 0x0; |
mja054 | 0:1efeb3fc4ba6 | 127 | LCD->PEN[1] = 0x0; |
mja054 | 0:1efeb3fc4ba6 | 128 | LCD->BPEN[0] = 0x0; |
mja054 | 0:1efeb3fc4ba6 | 129 | LCD->BPEN[1] = 0x0; |
mja054 | 0:1efeb3fc4ba6 | 130 | p_pen = (uint32_t *)&LCD->PEN[0]; |
mja054 | 0:1efeb3fc4ba6 | 131 | for (i=0;i<_LCDUSEDPINS;i++) |
mja054 | 0:1efeb3fc4ba6 | 132 | { |
mja054 | 0:1efeb3fc4ba6 | 133 | pen_offset = WF_ORDERING_TABLE[i]/32; |
mja054 | 0:1efeb3fc4ba6 | 134 | pen_bit = WF_ORDERING_TABLE[i]%32; |
mja054 | 0:1efeb3fc4ba6 | 135 | p_pen[pen_offset] |= 1 << pen_bit; |
mja054 | 0:1efeb3fc4ba6 | 136 | if (i>= _LCDFRONTPLANES) // Pin is a backplane |
mja054 | 0:1efeb3fc4ba6 | 137 | { |
mja054 | 0:1efeb3fc4ba6 | 138 | p_pen[pen_offset+2] |= 1 << pen_bit; // Enable BPEN |
mja054 | 0:1efeb3fc4ba6 | 139 | LCD->WF8B[(uint8_t)WF_ORDERING_TABLE[i]] = 1 << (i - _LCDFRONTPLANES); // fill with 0x01, 0x02, etc |
mja054 | 0:1efeb3fc4ba6 | 140 | } |
mja054 | 0:1efeb3fc4ba6 | 141 | } |
mja054 | 0:1efeb3fc4ba6 | 142 | LCD->GCR |= LCD_GCR_LCDEN_MASK; |
mja054 | 0:1efeb3fc4ba6 | 143 | } |
mja054 | 0:1efeb3fc4ba6 | 144 | |
mja054 | 0:1efeb3fc4ba6 | 145 | int SLCD::_putc(int c) { |
mja054 | 0:1efeb3fc4ba6 | 146 | Write_Char(c); |
mja054 | 0:1efeb3fc4ba6 | 147 | return 0; |
mja054 | 0:1efeb3fc4ba6 | 148 | } |
mja054 | 0:1efeb3fc4ba6 | 149 | |
mja054 | 0:1efeb3fc4ba6 | 150 | void SLCD::Write_Char (char lbValue) { |
mja054 | 0:1efeb3fc4ba6 | 151 | uint8_t char_val; |
mja054 | 0:1efeb3fc4ba6 | 152 | uint8_t temp; |
mja054 | 0:1efeb3fc4ba6 | 153 | uint8_t *lbpLCDWF; |
mja054 | 0:1efeb3fc4ba6 | 154 | uint8_t lbCounter; |
mja054 | 0:1efeb3fc4ba6 | 155 | uint16_t arrayOffset; |
mja054 | 0:1efeb3fc4ba6 | 156 | uint8_t position; |
mja054 | 0:1efeb3fc4ba6 | 157 | |
mja054 | 0:1efeb3fc4ba6 | 158 | if (CharPosition >= _CHARNUM) |
mja054 | 0:1efeb3fc4ba6 | 159 | CharPosition = 0; |
mja054 | 0:1efeb3fc4ba6 | 160 | lbpLCDWF = (uint8_t *)&LCD->WF8B[0]; |
mja054 | 0:1efeb3fc4ba6 | 161 | /* only ascii character if value not writeable write as @ */ |
mja054 | 0:1efeb3fc4ba6 | 162 | if (lbValue>='a' && lbValue<='z') { |
mja054 | 0:1efeb3fc4ba6 | 163 | lbValue -= 32; // UpperCase |
mja054 | 0:1efeb3fc4ba6 | 164 | } |
mja054 | 0:1efeb3fc4ba6 | 165 | if (lbValue<ASCCI_TABLE_START || lbValue >ASCCI_TABLE_END) { |
mja054 | 0:1efeb3fc4ba6 | 166 | lbValue = BLANK_CHARACTER; // default value as space |
mja054 | 0:1efeb3fc4ba6 | 167 | } |
mja054 | 0:1efeb3fc4ba6 | 168 | lbValue -=ASCCI_TABLE_START; // Remove the offset to search in the ascci table |
mja054 | 0:1efeb3fc4ba6 | 169 | arrayOffset = (lbValue * _CHAR_SIZE); // Compensate matrix offset |
mja054 | 0:1efeb3fc4ba6 | 170 | // ensure bLCD position is in valid limit |
mja054 | 0:1efeb3fc4ba6 | 171 | lbCounter = 0; //number of writings to complete one char |
mja054 | 0:1efeb3fc4ba6 | 172 | while (lbCounter<_CHAR_SIZE) { |
mja054 | 0:1efeb3fc4ba6 | 173 | position = (CharPosition) *_LCDTYPE + lbCounter; |
mja054 | 0:1efeb3fc4ba6 | 174 | temp=0; |
mja054 | 0:1efeb3fc4ba6 | 175 | if (lbCounter==1) { |
mja054 | 0:1efeb3fc4ba6 | 176 | temp = lbpLCDWF[WF_ORDERING_TABLE[position]] & 0x01;//bit 0 has the special symbol information |
mja054 | 0:1efeb3fc4ba6 | 177 | } |
mja054 | 0:1efeb3fc4ba6 | 178 | char_val = ASCII_TO_WF_CODIFICATION_TABLE[arrayOffset + lbCounter]; |
mja054 | 0:1efeb3fc4ba6 | 179 | lbpLCDWF[WF_ORDERING_TABLE[position]] = char_val | temp; |
mja054 | 0:1efeb3fc4ba6 | 180 | // if (char_val==0) lbCounter = _CHAR_SIZE; //end of this character |
mja054 | 0:1efeb3fc4ba6 | 181 | lbCounter++; |
mja054 | 0:1efeb3fc4ba6 | 182 | } |
mja054 | 0:1efeb3fc4ba6 | 183 | CharPosition++; |
mja054 | 0:1efeb3fc4ba6 | 184 | } |
mja054 | 0:1efeb3fc4ba6 | 185 | |
mja054 | 0:1efeb3fc4ba6 | 186 | void SLCD::Home (void) |
mja054 | 0:1efeb3fc4ba6 | 187 | { |
mja054 | 0:1efeb3fc4ba6 | 188 | CharPosition = 0; |
mja054 | 0:1efeb3fc4ba6 | 189 | } |
mja054 | 0:1efeb3fc4ba6 | 190 | |
mja054 | 0:1efeb3fc4ba6 | 191 | void SLCD::Contrast (uint8_t lbContrast) |
mja054 | 0:1efeb3fc4ba6 | 192 | { |
mja054 | 0:1efeb3fc4ba6 | 193 | lbContrast &= 0x0F; //Forced to the only values accepted |
mja054 | 0:1efeb3fc4ba6 | 194 | LCD->GCR |= LCD_GCR_RVTRIM(lbContrast); |
mja054 | 0:1efeb3fc4ba6 | 195 | } |
mja054 | 0:1efeb3fc4ba6 | 196 | |
mja054 | 0:1efeb3fc4ba6 | 197 | void SLCD::All_Segments (int mode) |
mja054 | 0:1efeb3fc4ba6 | 198 | { |
mja054 | 0:1efeb3fc4ba6 | 199 | uint8_t lbTotalBytes = _CHARNUM * _LCDTYPE; |
mja054 | 0:1efeb3fc4ba6 | 200 | uint8_t lbCounter=0; |
mja054 | 0:1efeb3fc4ba6 | 201 | uint8_t *lbpLCDWF; |
mja054 | 0:1efeb3fc4ba6 | 202 | |
mja054 | 0:1efeb3fc4ba6 | 203 | lbpLCDWF = (uint8_t *)&LCD->WF8B[0]; |
mja054 | 0:1efeb3fc4ba6 | 204 | while (lbCounter < lbTotalBytes) |
mja054 | 0:1efeb3fc4ba6 | 205 | { |
mja054 | 0:1efeb3fc4ba6 | 206 | if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[lbCounter++]]=_ALLON;} |
mja054 | 0:1efeb3fc4ba6 | 207 | else {lbpLCDWF[WF_ORDERING_TABLE[lbCounter++]]=0;} |
mja054 | 0:1efeb3fc4ba6 | 208 | } |
mja054 | 0:1efeb3fc4ba6 | 209 | } |
mja054 | 0:1efeb3fc4ba6 | 210 | |
mja054 | 0:1efeb3fc4ba6 | 211 | void SLCD::DP1 (int mode) |
mja054 | 0:1efeb3fc4ba6 | 212 | { |
mja054 | 0:1efeb3fc4ba6 | 213 | uint8_t *lbpLCDWF; |
mja054 | 0:1efeb3fc4ba6 | 214 | lbpLCDWF = (uint8_t *)&LCD->WF8B[0]; |
mja054 | 0:1efeb3fc4ba6 | 215 | if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]|=1;} |
mja054 | 0:1efeb3fc4ba6 | 216 | else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]&=~1;} |
mja054 | 0:1efeb3fc4ba6 | 217 | } |
mja054 | 0:1efeb3fc4ba6 | 218 | |
mja054 | 0:1efeb3fc4ba6 | 219 | void SLCD::DP2 (int mode) |
mja054 | 0:1efeb3fc4ba6 | 220 | { |
mja054 | 0:1efeb3fc4ba6 | 221 | uint8_t *lbpLCDWF; |
mja054 | 0:1efeb3fc4ba6 | 222 | lbpLCDWF = (uint8_t *)&LCD->WF8B[0]; |
mja054 | 0:1efeb3fc4ba6 | 223 | if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]|=1;} |
mja054 | 0:1efeb3fc4ba6 | 224 | else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]&=~1;} |
mja054 | 0:1efeb3fc4ba6 | 225 | } |
mja054 | 0:1efeb3fc4ba6 | 226 | |
mja054 | 0:1efeb3fc4ba6 | 227 | void SLCD::DP3 (int mode) |
mja054 | 0:1efeb3fc4ba6 | 228 | { |
mja054 | 0:1efeb3fc4ba6 | 229 | uint8_t *lbpLCDWF; |
mja054 | 0:1efeb3fc4ba6 | 230 | lbpLCDWF = (uint8_t *)&LCD->WF8B[0]; |
mja054 | 0:1efeb3fc4ba6 | 231 | if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]|=1;} |
mja054 | 0:1efeb3fc4ba6 | 232 | else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]&=~1;} |
mja054 | 0:1efeb3fc4ba6 | 233 | } |
mja054 | 0:1efeb3fc4ba6 | 234 | |
mja054 | 0:1efeb3fc4ba6 | 235 | void SLCD::Colon (int mode) |
mja054 | 0:1efeb3fc4ba6 | 236 | { |
mja054 | 0:1efeb3fc4ba6 | 237 | uint8_t *lbpLCDWF; |
mja054 | 0:1efeb3fc4ba6 | 238 | lbpLCDWF = (uint8_t *)&LCD->WF8B[0]; |
mja054 | 0:1efeb3fc4ba6 | 239 | if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]|=1;} |
mja054 | 0:1efeb3fc4ba6 | 240 | else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]&=~1;} |
mja054 | 0:1efeb3fc4ba6 | 241 | } |
mja054 | 0:1efeb3fc4ba6 | 242 | |
mja054 | 0:1efeb3fc4ba6 | 243 |