Subversion Repositories HomeAutomation

Rev

Rev 1796 | Rev 1799 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1796 Rev 1798
Line 49... Line 49...
49
}
49
}
50
 
50
 
51
void dotmatrixSetColor(uint8_t color){
51
void dotmatrixSetColor(uint8_t color){
52
  GrLcdState.color=color;
52
  GrLcdState.color=color;
53
}
53
}
-
 
54
 
54
uint8_t dotmatrixGetColor(void){
55
uint8_t dotmatrixGetColor(void){
55
  return GrLcdState.color;
56
  return GrLcdState.color;
56
}
57
}
-
 
58
 
-
 
59
void dotmatrixSetData(uint8_t Data)
-
 
60
{
-
 
61
//  dotmatrixFramebuf[8][4]
-
 
62
}
-
 
63
 
-
 
64
uint8_t dotmatrixGetData(void){
-
 
65
    uint8_t input = 0;
-
 
66
 
-
 
67
    return input;
-
 
68
}
-
 
69
 
57
void dotmatrixWriteData(uint8_t data, uint8_t color){
70
void dotmatrixWriteData(uint8_t data, uint8_t color){
58
/*  dotmatrixSetControls(1,0);
71
/*  dotmatrixSetControls(1,0);
59
    if (color == GLCD_COLOR_CLEAR)
72
    if (color == GLCD_COLOR_CLEAR)
60
      data = ~data;
73
      data = ~data;
61
    if (GrLcdState.color == GLCD_COLOR_BLACK)
74
    if (GrLcdState.color == GLCD_COLOR_BLACK)
62
      dotmatrixSetData(data);
75
      dotmatrixSetData(data);
63
    else
76
    else
64
      dotmatrixSetData(~data);
77
      dotmatrixSetData(~data);
65
    dotmatrixEnable();
78
    dotmatrixEnable();
66
    GrLcdState.lcdXAddr++;
79
    GrLcdState.lcdXAddr++;
67
 
80
 
68
    if (GrLcdState.lcdXAddr == 64 ){
81
    if (GrLcdState.lcdXAddr == 64 ){
69
        dotmatrixSetXY(GrLcdState.lcdXAddr,GrLcdState.lcdYAddr);
82
        dotmatrixSetXY(GrLcdState.lcdXAddr,GrLcdState.lcdYAddr);
70
    }
83
    }
71
#if KS0108_WIDTH > 128
84
#if KS0108_WIDTH > 128
72
else if (GrLcdState.lcdXAddr == 128 ){
85
else if (GrLcdState.lcdXAddr == 128 ){
73
        dotmatrixSetXY(GrLcdState.lcdXAddr,GrLcdState.lcdYAddr);
86
        dotmatrixSetXY(GrLcdState.lcdXAddr,GrLcdState.lcdYAddr);
74
    }
87
    }
75
#endif
88
#endif
76
    if (GrLcdState.lcdXAddr > KS0108_WIDTH ){
89
    if (GrLcdState.lcdXAddr > KS0108_WIDTH ){
77
        dotmatrixSetXY(0,GrLcdState.lcdYAddr+8);
90
        dotmatrixSetXY(0,GrLcdState.lcdYAddr+8);
78
    }*/
91
    }*/
79
}
92
}
80
void dotmatrixWriteDataTransparent(uint8_t inputdata, uint8_t color){
93
void dotmatrixWriteDataTransparent(uint8_t inputdata, uint8_t color){
81
/*  uint8_t data = 0;
94
/*  uint8_t data = 0;
82
    dotmatrixSetDirection(INPUT);
95
    dotmatrixSetDirection(INPUT);
Line 94... Line 107...
94
    dotmatrixSetControls(1,0);
107
    dotmatrixSetControls(1,0);
95
    dotmatrixSetDirection(OUTPUT);
108
    dotmatrixSetDirection(OUTPUT);
96
    dotmatrixSetXY(GrLcdState.lcdXAddr, GrLcdState.lcdYAddr);
109
    dotmatrixSetXY(GrLcdState.lcdXAddr, GrLcdState.lcdYAddr);
97
    dotmatrixSetControls(1,0);
110
    dotmatrixSetControls(1,0);
98
    if (color == GLCD_COLOR_CLEAR)
111
    if (color == GLCD_COLOR_CLEAR)
99
      data = data&(~inputdata);
112
      data = data&(~inputdata);
100
    else
113
    else
101
      data = data|inputdata;
114
      data = data|inputdata;
102
    if (GrLcdState.color == GLCD_COLOR_BLACK)
115
    if (GrLcdState.color == GLCD_COLOR_BLACK)
103
      dotmatrixSetData(data);
116
      dotmatrixSetData(data);
104
    else
117
    else
105
      dotmatrixSetData(~data);
118
      dotmatrixSetData(~data);
Line 142... Line 155...
142
 
155
 
143
/* Callback run periodically to manage rows.
156
/* Callback run periodically to manage rows.
144
   For each time callback is run, the next row is enabled and the last disabled
157
   For each time callback is run, the next row is enabled and the last disabled
145
 */
158
 */
146
void dotmatrixRefresh()
159
void dotmatrixRefresh()
147
{
160
{
148
    /* Increase row counter */
161
    /* Increase row counter */
149
    if (dotmatrixRowCounter++ == 8) {dotmatrixRowCounter = 0;}
162
    if (dotmatrixRowCounter++ == 8) {dotmatrixRowCounter = 0;}
150
 
163
 
151
    /* Disable all rows */
164
    /* Disable all rows */
152
    gpio_clr_pin(dotmatrixROW_IO1);
165
    gpio_clr_pin(dotmatrixROW_IO1);
153
    gpio_clr_pin(dotmatrixROW_IO2);
166
    gpio_clr_pin(dotmatrixROW_IO2);
154
    gpio_clr_pin(dotmatrixROW_IO3);
167
    gpio_clr_pin(dotmatrixROW_IO3);
155
    gpio_clr_pin(dotmatrixROW_IO4);
168
    gpio_clr_pin(dotmatrixROW_IO4);
Line 166... Line 179...
166
    /* Add more here to support 8-module panels */
179
    /* Add more here to support 8-module panels */
167
 
180
 
168
    /* Toggle shift register latch */
181
    /* Toggle shift register latch */
169
    gpio_clr_pin(dotmatrixLATCHCLOCK_IO);
182
    gpio_clr_pin(dotmatrixLATCHCLOCK_IO);
170
    gpio_set_pin(dotmatrixLATCHCLOCK_IO);
183
    gpio_set_pin(dotmatrixLATCHCLOCK_IO);
171
 
184
 
172
    /* Enable one row */
185
    /* Enable one row */
173
    switch (dotmatrixRowCounter)
186
    switch (dotmatrixRowCounter)
174
    {
187
    {
175
        case 0:
188
        case 0:
176
            gpio_set_pin(dotmatrixROW_IO1);
189
            gpio_set_pin(dotmatrixROW_IO1);
Line 237... Line 250...
237
    UCSR0C = (1<<UMSEL01)|(1<<UMSEL00)|(0<<UCPHA0)|(0<<UCPOL0);
250
    UCSR0C = (1<<UMSEL01)|(1<<UMSEL00)|(0<<UCPHA0)|(0<<UCPOL0);
238
    UCSR0B = (1<<RXEN0)|(1<<TXEN0);
251
    UCSR0B = (1<<RXEN0)|(1<<TXEN0);
239
    UBRR0 = 0;
252
    UBRR0 = 0;
240
 
253
 
241
    dotmatrixClear();
254
    dotmatrixClear();
-
 
255
 
-
 
256
    GrLcdState.color = GLCD_COLOR_WHITE;
242
   
257
   
243
/*  gpio_set_out(LCD_CONTROL_RS);
258
/*  gpio_set_out(LCD_CONTROL_RS);
244
    gpio_set_out(LCD_CONTROL_RW);
259
    gpio_set_out(LCD_CONTROL_RW);
245
    gpio_set_out(LCD_CONTROL_E);
260
    gpio_set_out(LCD_CONTROL_E);
246
    gpio_set_out(LCD_CONTROL_CS1);
261
    gpio_set_out(LCD_CONTROL_CS1);
Line 279... Line 294...
279
        }
294
        }
280
    }
295
    }
281
}
296
}
282
 
297
 
283
void dotmatrixSetXY(uint8_t x, uint8_t y){
298
void dotmatrixSetXY(uint8_t x, uint8_t y){
284
/*  GrLcdState.lcdXAddr = x;
299
    GrLcdState.lcdXAddr = x;
285
    GrLcdState.lcdYAddr = y;
300
    GrLcdState.lcdYAddr = y;
286
    GrLcdState.lcdYpage = y/8;
301
    GrLcdState.lcdYpage = y/8;
287
 
302
 
-
 
303
/*
288
    //Vi b�rjar med X. Steg 1: V�lj r�tt chip:
304
    //Vi b�rjar med X. Steg 1: V�lj r�tt chip:
289
    if (x > 63 && x <= 127){
305
    if (x > 63 && x <= 127){
290
#if KS0108_INVERT_CS == 1
306
#if KS0108_INVERT_CS == 1
291
    gpio_set_pin(LCD_CONTROL_CS1);
307
    gpio_set_pin(LCD_CONTROL_CS1);
292
    gpio_clr_pin(LCD_CONTROL_CS2);
308
    gpio_clr_pin(LCD_CONTROL_CS2);