Rev 1803 | Rev 1808 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1803 | Rev 1805 | ||
|---|---|---|---|
| Line 31... | Line 31... | ||
| 31 | 31 | ||
| 32 | #define OUTPUT 0 |
32 | #define OUTPUT 0 |
| 33 | #define INPUT 1 |
33 | #define INPUT 1 |
| 34 | 34 | ||
| 35 | volatile GrLcdStateType GrLcdState; |
35 | volatile GrLcdStateType GrLcdState; |
| 36 | uint8_t dotmatrixFramebuf[ |
36 | uint8_t dotmatrixFramebuf[8][dotmatrixSIZEX/8]; |
| 37 | uint8_t dotmatrixRowCounter=0; |
37 | uint8_t dotmatrixRowCounter=0; |
| 38 | uint16_t dotmatrixBrightness=0; |
38 | uint16_t dotmatrixBrightness=0; |
| 39 | 39 | ||
| 40 | /* Write a byte on SPI */ |
40 | /* Write a byte on SPI */ |
| 41 | void dotmatrixSPIWrite(uint8_t data) { |
41 | void dotmatrixSPIWrite(uint8_t data) { |
| Line 54... | Line 54... | ||
| 54 | 54 | ||
| 55 | uint8_t dotmatrixGetColor(void){ |
55 | uint8_t dotmatrixGetColor(void){ |
| 56 | return GrLcdState.color; |
56 | return GrLcdState.color; |
| 57 | } |
57 | } |
| 58 | 58 | ||
| 59 | /* Sets data into framebuffer, data arrives in a byte as a column |
59 | /* Sets data into framebuffer, data arrives in a byte as a column */ |
| 60 | void dotmatrixSetData(uint8_t Data) |
60 | void dotmatrixSetData(uint8_t Data) |
| 61 | { |
61 | { |
| 62 | /* Which ledmodule */ |
62 | /* Which ledmodule */ |
| 63 | uint8_t module = GrLcdState.lcdXAddr |
63 | uint8_t module = GrLcdState.lcdXAddr>>3; |
| 64 | /* Which column in ledmodule */ |
64 | /* Which column in ledmodule */ |
| 65 | uint8_t column = GrLcdState.lcdXAddr |
65 | uint8_t column = GrLcdState.lcdXAddr%8; |
| 66 | /* Which row */ |
66 | /* Which row */ |
| 67 |
|
67 | // uint8_t row = GrLcdState.lcdYAddr%8; |
| 68 | 68 | ||
| 69 | /* Repeat for each row */ |
- | |
| 70 | for (uint8_t i=0; i<8; i++) |
- | |
| 71 | { |
- | |
| 72 | /* Check panel size */ |
69 | /* Check panel size */ |
| 73 |
|
70 | if ((column < dotmatrixSIZEY) && (module < dotmatrixSIZEX/8)) |
| 74 | { |
71 | { |
| 75 | /* Shift one bit */ |
- | |
| 76 | Data = Data>>1; |
- | |
| 77 | /* Mask bit */ |
- | |
| 78 | uint8_t databit = Data&0x1; |
- | |
| 79 | if (databit==0) |
- | |
| 80 | { |
- | |
| 81 | /* Clear bit */ |
- | |
| 82 | dotmatrixFramebuf[row+i][module] &= ~(databit<<column); |
- | |
| 83 | } |
- | |
| 84 | else |
- | |
| 85 | { |
- | |
| 86 | /* Set bit */ |
- | |
| 87 |
|
72 | dotmatrixFramebuf[column][module] = Data; |
| 88 | } |
- | |
| 89 | } |
- | |
| 90 | } |
73 | } |
| 91 | } |
74 | } |
| 92 | 75 | ||
| 93 | uint8_t dotmatrixGetData(void){ |
76 | uint8_t dotmatrixGetData(void){ |
| 94 | uint8_t input = 0; |
- | |
| 95 | /* Which ledmodule */ |
77 | /* Which ledmodule */ |
| 96 | uint8_t module = GrLcdState.lcdXAddr |
78 | uint8_t module = GrLcdState.lcdXAddr>>3; |
| 97 | /* Which column in ledmodule */ |
79 | /* Which column in ledmodule */ |
| 98 | uint8_t column = GrLcdState.lcdXAddr |
80 | uint8_t column = GrLcdState.lcdXAddr%8; |
| 99 | /* Which row */ |
81 | /* Which row */ |
| 100 |
|
82 | // uint8_t row = GrLcdState.lcdYAddr%8; |
| 101 | 83 | ||
| 102 | /* Repeat for each row */ |
- | |
| 103 | for (uint8_t i=0; i<8; i++) |
- | |
| 104 | { |
- | |
| 105 | /* Check panel size */ |
84 | /* Check panel size */ |
| 106 |
|
85 | if ((column < dotmatrixSIZEY) && (module < dotmatrixSIZEX/8)) |
| 107 | { |
86 | { |
| 108 | /* Shift column and the into returndata */ |
- | |
| 109 |
|
87 | return (dotmatrixFramebuf[column][module]); |
| - | 88 | } |
|
| - | 89 | else |
|
| - | 90 | { |
|
| - | 91 | return 0; |
|
| 110 | } |
92 | } |
| 111 | } |
- | |
| 112 | - | ||
| 113 | return input; |
- | |
| 114 | } |
93 | } |
| 115 | 94 | ||
| 116 | void dotmatrixWriteData(uint8_t data, uint8_t color){ |
95 | void dotmatrixWriteData(uint8_t data, uint8_t color){ |
| 117 | if (color == GLCD_COLOR_CLEAR) |
96 | if (color == GLCD_COLOR_CLEAR) |
| 118 | { |
97 | { |
| Line 197... | Line 176... | ||
| 197 | gpio_clr_pin(dotmatrixROW_IO6); |
176 | gpio_clr_pin(dotmatrixROW_IO6); |
| 198 | gpio_clr_pin(dotmatrixROW_IO7); |
177 | gpio_clr_pin(dotmatrixROW_IO7); |
| 199 | gpio_clr_pin(dotmatrixROW_IO8); |
178 | gpio_clr_pin(dotmatrixROW_IO8); |
| 200 | 179 | ||
| 201 | /* Write one column of frame buffer to shift registers */ |
180 | /* Write one column of frame buffer to shift registers */ |
| 202 | dotmatrixSPIWrite(dotmatrixFramebuf[ |
181 | dotmatrixSPIWrite(dotmatrixFramebuf[dotmatrixRowCounter][0]); |
| 203 | dotmatrixSPIWrite(dotmatrixFramebuf[ |
182 | dotmatrixSPIWrite(dotmatrixFramebuf[dotmatrixRowCounter][1]); |
| 204 | dotmatrixSPIWrite(dotmatrixFramebuf[ |
183 | dotmatrixSPIWrite(dotmatrixFramebuf[dotmatrixRowCounter][2]); |
| 205 | dotmatrixSPIWrite(dotmatrixFramebuf[ |
184 | dotmatrixSPIWrite(dotmatrixFramebuf[dotmatrixRowCounter][3]); |
| 206 | /* Add more here to support 8-module panels */ |
185 | /* Add more here to support 8-module panels */ |
| 207 | 186 | ||
| 208 | /* Toggle shift register latch */ |
187 | /* Toggle shift register latch */ |
| 209 | gpio_clr_pin(dotmatrixLATCHCLOCK_IO); |
188 | gpio_clr_pin(dotmatrixLATCHCLOCK_IO); |
| 210 | gpio_set_pin(dotmatrixLATCHCLOCK_IO); |
189 | gpio_set_pin(dotmatrixLATCHCLOCK_IO); |
| Line 278... | Line 257... | ||
| 278 | UCSR0B = (1<<RXEN0)|(1<<TXEN0); |
257 | UCSR0B = (1<<RXEN0)|(1<<TXEN0); |
| 279 | UBRR0 = 0; |
258 | UBRR0 = 0; |
| 280 | 259 | ||
| 281 | dotmatrixClear(); |
260 | dotmatrixClear(); |
| 282 | 261 | ||
| 283 | GrLcdState.color = |
262 | GrLcdState.color = GLCD_COLOR_BLACK; |
| 284 | } |
263 | } |
| 285 | 264 | ||
| 286 | void dotmatrixClear(){ |
265 | void dotmatrixClear(){ |
| 287 | /* Clear buffer memory */ |
266 | /* Clear buffer memory */ |
| 288 | for (uint8_t i=0; i<8; i++) |
267 | for (uint8_t i=0; i<8; i++) |