Rev 1801 | Rev 1803 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1801 | Rev 1802 | ||
|---|---|---|---|
| Line 114... | Line 114... | ||
| 114 | 114 | ||
| 115 | if (GrLcdState.lcdXAddr > GRAPHICS_WIDTH ){ |
115 | if (GrLcdState.lcdXAddr > GRAPHICS_WIDTH ){ |
| 116 | dotmatrixSetXY(0,GrLcdState.lcdYAddr+8); |
116 | dotmatrixSetXY(0,GrLcdState.lcdYAddr+8); |
| 117 | } |
117 | } |
| 118 | } |
118 | } |
| - | 119 | ||
| 119 | void dotmatrixWriteDataTransparent(uint8_t inputdata, uint8_t color){ |
120 | void dotmatrixWriteDataTransparent(uint8_t inputdata, uint8_t color){ |
| 120 | /* FIXME */ |
- | |
| 121 | - | ||
| 122 |
|
121 | uint8_t data = dotmatrixGetData(); |
| 123 | dotmatrixSetDirection(INPUT); |
- | |
| 124 | dotmatrixSetControls(1,1); |
- | |
| 125 | dotmatrixEnable(); //dummy read |
- | |
| 126 | dotmatrixDelay(); |
- | |
| 127 | gpio_set_pin(LCD_CONTROL_E); |
- | |
| 128 | dotmatrixDelay(); |
- | |
| 129 |
|
122 | if (GrLcdState.color != GLCD_COLOR_BLACK) |
| 130 | data = dotmatrixGetData(); |
- | |
| 131 |
|
123 | { |
| 132 |
|
124 | data = ~data; |
| 133 | dotmatrixDisable(); |
- | |
| 134 |
|
125 | } |
| 135 | dotmatrixSetControls(1,0); |
- | |
| 136 | dotmatrixSetDirection(OUTPUT); |
- | |
| 137 | dotmatrixSetXY(GrLcdState.lcdXAddr, GrLcdState.lcdYAddr); |
- | |
| 138 | dotmatrixSetControls(1,0); |
- | |
| - | 126 | ||
| 139 | if (color == GLCD_COLOR_CLEAR) |
127 | if (color == GLCD_COLOR_CLEAR) |
| - | 128 | { |
|
| 140 | data = data&(~inputdata); |
129 | data = data&(~inputdata); |
| - | 130 | } |
|
| 141 | else |
131 | else |
| - | 132 | { |
|
| 142 | data = data|inputdata; |
133 | data = data|inputdata; |
| - | 134 | } |
|
| - | 135 | ||
| 143 | if (GrLcdState.color == GLCD_COLOR_BLACK) |
136 | if (GrLcdState.color == GLCD_COLOR_BLACK) |
| - | 137 | { |
|
| 144 | dotmatrixSetData(data); |
138 | dotmatrixSetData(data); |
| - | 139 | } |
|
| 145 | else |
140 | else |
| - | 141 | { |
|
| 146 | dotmatrixSetData(~data); |
142 | dotmatrixSetData(~data); |
| 147 | dotmatrixEnable(); |
- | |
| 148 | GrLcdState.lcdXAddr++; |
- | |
| 149 | 143 | } |
|
| 150 | 144 | ||
| 151 |
|
145 | GrLcdState.lcdXAddr++; |
| 152 | dotmatrixSetXY(GrLcdState.lcdXAddr,GrLcdState.lcdYAddr); |
- | |
| 153 | } |
- | |
| 154 | #if KS0108_WIDTH > 128 |
- | |
| 155 | else if (GrLcdState.lcdXAddr == 128 ){ |
- | |
| 156 | dotmatrixSetXY(GrLcdState.lcdXAddr,GrLcdState.lcdYAddr); |
- | |
| 157 | } |
146 | |
| 158 | #endif |
- | |
| 159 |
|
147 | if (GrLcdState.lcdXAddr > GRAPHICS_WIDTH ){ |
| 160 | dotmatrixSetXY(0,GrLcdState.lcdYAddr+8); |
148 | dotmatrixSetXY(0,GrLcdState.lcdYAddr+8); |
| 161 |
|
149 | } |
| 162 | } |
150 | } |
| 163 | 151 | ||
| 164 | uint8_t dotmatrixReadData(void){ |
152 | uint8_t dotmatrixReadData(void){ |
| 165 | uint8_t data = 0; |
153 | uint8_t data = 0; |
| 166 | /* FIXME */ |
- | |
| 167 | - | ||
| 168 | /* dotmatrixSetDirection(INPUT); |
- | |
| 169 | dotmatrixSetControls(1,1); |
- | |
| 170 | dotmatrixEnable(); //dummy read |
- | |
| 171 | dotmatrixDelay(); |
- | |
| 172 | gpio_set_pin(LCD_CONTROL_E); |
- | |
| 173 | dotmatrixDelay(); |
- | |
| 174 | if (GrLcdState.color == GLCD_COLOR_BLACK) |
154 | if (GrLcdState.color == GLCD_COLOR_BLACK) |
| - | 155 | { |
|
| 175 | data = dotmatrixGetData(); |
156 | data = dotmatrixGetData(); |
| - | 157 | } |
|
| 176 | else |
158 | else |
| - | 159 | { |
|
| 177 | data = ~dotmatrixGetData(); |
160 | data = ~dotmatrixGetData(); |
| 178 | dotmatrixDisable(); |
- | |
| 179 |
|
161 | } |
| 180 | dotmatrixSetControls(1,0); |
- | |
| 181 | dotmatrixSetDirection(OUTPUT); |
- | |
| 182 | dotmatrixSetXY(GrLcdState.lcdXAddr, GrLcdState.lcdYAddr);*/ |
- | |
| - | 162 | ||
| 183 | return data; |
163 | return data; |
| 184 | } |
164 | } |
| 185 | 165 | ||
| 186 | /* Callback run periodically to manage rows. |
166 | /* Callback run periodically to manage rows. |
| 187 | For each time callback is run, the next row is enabled and the last disabled |
167 | For each time callback is run, the next row is enabled and the last disabled |
| Line 209... | Line 189... | ||
| 209 | /* Add more here to support 8-module panels */ |
189 | /* Add more here to support 8-module panels */ |
| 210 | 190 | ||
| 211 | /* Toggle shift register latch */ |
191 | /* Toggle shift register latch */ |
| 212 | gpio_clr_pin(dotmatrixLATCHCLOCK_IO); |
192 | gpio_clr_pin(dotmatrixLATCHCLOCK_IO); |
| 213 | gpio_set_pin(dotmatrixLATCHCLOCK_IO); |
193 | gpio_set_pin(dotmatrixLATCHCLOCK_IO); |
| 214 | 194 | ||
| 215 | /* Enable one row */ |
195 | /* Enable one row */ |
| 216 | switch (dotmatrixRowCounter) |
196 | switch (dotmatrixRowCounter) |
| 217 | { |
197 | { |
| 218 | case 0: |
198 | case 0: |
| 219 | gpio_set_pin(dotmatrixROW_IO1); |
199 | gpio_set_pin(dotmatrixROW_IO1); |
| Line 282... | Line 262... | ||
| 282 | UBRR0 = 0; |
262 | UBRR0 = 0; |
| 283 | 263 | ||
| 284 | dotmatrixClear(); |
264 | dotmatrixClear(); |
| 285 | 265 | ||
| 286 | GrLcdState.color = GLCD_COLOR_WHITE; |
266 | GrLcdState.color = GLCD_COLOR_WHITE; |
| 287 | - | ||
| 288 | /* gpio_set_out(LCD_CONTROL_RS); |
- | |
| 289 | gpio_set_out(LCD_CONTROL_RW); |
- | |
| 290 | gpio_set_out(LCD_CONTROL_E); |
- | |
| 291 | gpio_set_out(LCD_CONTROL_CS1); |
- | |
| 292 | gpio_set_out(LCD_CONTROL_CS2); |
- | |
| 293 | - | ||
| 294 | dotmatrixSetDirection(OUTPUT); |
- | |
| 295 | GrLcdState.color = GLCD_COLOR_WHITE; |
- | |
| 296 | #if KS0108_INVERT_CS == 1 |
- | |
| 297 | gpio_clr_pin(LCD_CONTROL_CS1); |
- | |
| 298 | gpio_clr_pin(LCD_CONTROL_CS2); |
- | |
| 299 | #else |
- | |
| 300 | gpio_set_pin(LCD_CONTROL_CS1); |
- | |
| 301 | gpio_set_pin(LCD_CONTROL_CS2); |
- | |
| 302 | #endif |
- | |
| 303 | dotmatrixDisable(); |
- | |
| 304 | dotmatrixDelay(); |
- | |
| 305 | //set display on |
- | |
| 306 | dotmatrixSetControls(0,0); |
- | |
| 307 | dotmatrixSetData(0x3F); |
- | |
| 308 | dotmatrixEnable(); |
- | |
| 309 | - | ||
| 310 | //set startaddress of the first row (set to row 0) |
- | |
| 311 | dotmatrixSetControls(0,0); |
- | |
| 312 | dotmatrixSetData(0xc0); |
- | |
| 313 | dotmatrixEnable(); |
- | |
| 314 | dotmatrixClear();*/ |
- | |
| 315 | } |
267 | } |
| 316 | 268 | ||
| 317 | void dotmatrixClear(){ |
269 | void dotmatrixClear(){ |
| 318 | /* Clear buffer memory */ |
270 | /* Clear buffer memory */ |
| 319 | for (uint8_t i=0; i<8; i++) |
271 | for (uint8_t i=0; i<8; i++) |
| Line 327... | Line 279... | ||
| 327 | 279 | ||
| 328 | void dotmatrixSetXY(uint8_t x, uint8_t y){ |
280 | void dotmatrixSetXY(uint8_t x, uint8_t y){ |
| 329 | GrLcdState.lcdXAddr = x; |
281 | GrLcdState.lcdXAddr = x; |
| 330 | GrLcdState.lcdYAddr = y; |
282 | GrLcdState.lcdYAddr = y; |
| 331 | GrLcdState.lcdYpage = y/8; |
283 | GrLcdState.lcdYpage = y/8; |
| - | 284 | } |
|
| 332 | 285 | ||
| 333 | /* |
- | |
| 334 | //Vi b�rjar med X. Steg 1: V�lj r�tt chip: |
- | |
| 335 | if (x > 63 && x <= 127){ |
- | |
| 336 | #if KS0108_INVERT_CS == 1 |
- | |
| 337 | gpio_set_pin(LCD_CONTROL_CS1); |
- | |
| 338 | gpio_clr_pin(LCD_CONTROL_CS2); |
- | |
| 339 | #else |
- | |
| 340 | gpio_set_pin(LCD_CONTROL_CS2); |
- | |
| 341 | gpio_clr_pin(LCD_CONTROL_CS1); |
- | |
| 342 | #endif |
- | |
| 343 | } else if (x > 127){ |
- | |
| 344 | #if KS0108_INVERT_CS == 1 |
- | |
| 345 | gpio_set_pin(LCD_CONTROL_CS1); |
- | |
| 346 | gpio_set_pin(LCD_CONTROL_CS2); |
- | |
| 347 | #else |
- | |
| 348 | gpio_clr_pin(LCD_CONTROL_CS2); |
- | |
| 349 | gpio_clr_pin(LCD_CONTROL_CS1); |
- | |
| 350 | #endif |
- | |
| 351 | } else { |
- | |
| 352 | #if KS0108_INVERT_CS == 1 |
- | |
| 353 | gpio_set_pin(LCD_CONTROL_CS2); |
- | |
| 354 | gpio_clr_pin(LCD_CONTROL_CS1); |
- | |
| 355 | #else |
- | |
| 356 | gpio_set_pin(LCD_CONTROL_CS1); |
- | |
| 357 | gpio_clr_pin(LCD_CONTROL_CS2); |
- | |
| 358 | #endif |
- | |
| 359 | } |
- | |
| 360 | - | ||
| 361 | //Steg 2: S�tt r�tt x-adress p� det aktiva chippet |
- | |
| 362 | dotmatrixSetControls(0,0); |
- | |
| 363 | dotmatrixSetData(0x40 + x%64); |
- | |
| 364 | dotmatrixEnable(); |
- | |
| 365 | - | ||
| 366 | //Steg 3: S�tt r�tt y-adress p� det aktiva chippet |
- | |
| 367 | dotmatrixSetData(0xB8 + GrLcdState.lcdYpage); |
- | |
| 368 | dotmatrixEnable();*/ |
- | |
| 369 | } |
- | |
| 370 | uint8_t dotmatrixGetX(void){ |
286 | uint8_t dotmatrixGetX(void){ |
| 371 | return GrLcdState.lcdXAddr; |
287 | return GrLcdState.lcdXAddr; |
| 372 | } |
288 | } |
| - | 289 | ||
| 373 | uint8_t dotmatrixGetY(void){ |
290 | uint8_t dotmatrixGetY(void){ |
| 374 | return GrLcdState.lcdYAddr; |
291 | return GrLcdState.lcdYAddr; |
| 375 | } |
292 | } |
| 376 | 293 | ||