Subversion Repositories HomeAutomation

Rev

Rev 1793 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1793 Rev 1794
Line 4... Line 4...
4
#include <stdio.h>
4
#include <stdio.h>
5
#include <stdlib.h>
5
#include <stdlib.h>
6
 
6
 
7
#include <avr/pgmspace.h>
7
#include <avr/pgmspace.h>
8
 
8
 
9
#ifndef GRAPHICSDRIVER
9
#ifndef GRAPHICS_DRIVER
10
#define GRAPHICSDRIVER KS0108
10
#define GRAPHICS_DRIVER KS0108
11
#warning Please define GRAPHICSDRIVER in your config.inc
11
#error Please define GRAPHICS_DRIVER in your config.inc, see config.inc.template
12
#endif
12
#endif
13
 
13
 
-
 
14
#ifndef GRAPHICS_WIDTH
-
 
15
#define GRAPHICS_WIDTH KS0108_WIDTH
-
 
16
#error Please define GRAPHICS_WIDTH in your config.inc, KS0108_WIDTH should be replaced
-
 
17
#endif
-
 
18
 
-
 
19
#ifndef GRAPHICS_HEIGHT
-
 
20
#define GRAPHICS_HEIGHT KS0108_HIGHT
-
 
21
#error Please define GRAPHICS_HEIGHT in your config.inc, KS0108_HIGHT should be replaced
-
 
22
#endif
-
 
23
 
-
 
24
 
14
#if GRAPHICSDRIVER==KS0108
25
#if GRAPHICS_DRIVER==KS0108
15
#include "ks0108.h"
26
#include "ks0108.h"
16
#elif GRAPHICSDRIVER==DOTMATRIX
27
#elif GRAPHICS_DRIVER==DOTMATRIX
17
#include "dotmatrix.h"
28
#include "dotmatrix.h"
18
#else
29
#else
19
#error Non supported graphics driver
30
#error Non supported graphics driver
20
#endif
31
#endif
21
 
32
 
Line 40... Line 51...
40
//      which can be found at http://www.gnu.org/licenses/gpl.txt
51
//      which can be found at http://www.gnu.org/licenses/gpl.txt
41
//
52
//
42
//*****************************************************************************
53
//*****************************************************************************
43
 
54
 
44
void glcdSetColor(uint8_t color){
55
void glcdSetColor(uint8_t color){
45
#if GRAPHICSDRIVER==KS0108
56
#if GRAPHICS_DRIVER==KS0108
46
  ks0108SetColor(color);
57
  ks0108SetColor(color);
47
#elif GRAPHICSDRIVER==DOTMATRIX
58
#elif GRAPHICS_DRIVER==DOTMATRIX
48
  dotmatrixSetColor(color);
59
  dotmatrixSetColor(color);
49
#endif
60
#endif
50
}
61
}
51
 
62
 
52
uint8_t glcdGetColor(void){
63
uint8_t glcdGetColor(void){
53
#if GRAPHICSDRIVER==KS0108
64
#if GRAPHICS_DRIVER==KS0108
54
  return ks0108GetColor();
65
  return ks0108GetColor();
55
#elif GRAPHICSDRIVER==DOTMATRIX
66
#elif GRAPHICS_DRIVER==DOTMATRIX
56
  return dotmatrixGetColor();
67
  return dotmatrixGetColor();
57
#endif
68
#endif
58
}
69
}
59
 
70
 
60
void glcdWriteData(uint8_t data, uint8_t color){
71
void glcdWriteData(uint8_t data, uint8_t color){
61
#if GRAPHICSDRIVER==KS0108
72
#if GRAPHICS_DRIVER==KS0108
62
    ks0108WriteData(data, color);
73
    ks0108WriteData(data, color);
63
#elif GRAPHICSDRIVER==DOTMATRIX
74
#elif GRAPHICS_DRIVER==DOTMATRIX
64
    dotmatrixWriteData(data, color);
75
    dotmatrixWriteData(data, color);
65
#endif
76
#endif
66
}
77
}
67
 
78
 
68
void glcdWriteDataTransparent(uint8_t inputdata, uint8_t color){
79
void glcdWriteDataTransparent(uint8_t inputdata, uint8_t color){
69
#if GRAPHICSDRIVER==KS0108
80
#if GRAPHICS_DRIVER==KS0108
70
    ks0108WriteDataTransparent(inputdata, color);
81
    ks0108WriteDataTransparent(inputdata, color);
71
#elif GRAPHICSDRIVER==DOTMATRIX
82
#elif GRAPHICS_DRIVER==DOTMATRIX
72
    dotmatrixWriteDataTransparent(inputdata, color);
83
    dotmatrixWriteDataTransparent(inputdata, color);
73
#endif
84
#endif
74
}
85
}
75
 
86
 
76
uint8_t glcdReadData(void){
87
uint8_t glcdReadData(void){
77
#if GRAPHICSDRIVER==KS0108
88
#if GRAPHICS_DRIVER==KS0108
78
    return ks0108ReadData();
89
    return ks0108ReadData();
79
#elif GRAPHICSDRIVER==DOTMATRIX
90
#elif GRAPHICS_DRIVER==DOTMATRIX
80
    return dotmatrixReadData();
91
    return dotmatrixReadData();
81
#endif
92
#endif
82
}
93
}
83
 
94
 
84
void glcdClear(){
95
void glcdClear(){
85
#if GRAPHICSDRIVER==KS0108
96
#if GRAPHICS_DRIVER==KS0108
86
    ks0108Clear();
97
    ks0108Clear();
87
#elif GRAPHICSDRIVER==DOTMATRIX
98
#elif GRAPHICS_DRIVER==DOTMATRIX
88
    dotmatrixClear();
99
    dotmatrixClear();
89
#endif
100
#endif
90
}
101
}
91
 
102
 
92
void glcdSetXY(uint8_t x, uint8_t y){
103
void glcdSetXY(uint8_t x, uint8_t y){
93
#if GRAPHICSDRIVER==KS0108
104
#if GRAPHICS_DRIVER==KS0108
94
    ks0108SetXY(x, y);
105
    ks0108SetXY(x, y);
95
#elif GRAPHICSDRIVER==DOTMATRIX
106
#elif GRAPHICS_DRIVER==DOTMATRIX
96
    dotmatrixSetXY(x, y);
107
    dotmatrixSetXY(x, y);
97
#endif
108
#endif
98
}
109
}
99
 
110
 
100
uint8_t glcdGetX(void){
111
uint8_t glcdGetX(void){
101
#if GRAPHICSDRIVER==KS0108
112
#if GRAPHICS_DRIVER==KS0108
102
    return ks0108GetX();
113
    return ks0108GetX();
103
#elif GRAPHICSDRIVER==DOTMATRIX
114
#elif GRAPHICS_DRIVER==DOTMATRIX
104
    return dotmatrixGetX();
115
    return dotmatrixGetX();
105
#endif
116
#endif
106
}
117
}
107
 
118
 
108
uint8_t glcdGetY(void){
119
uint8_t glcdGetY(void){
109
#if GRAPHICSDRIVER==KS0108
120
#if GRAPHICS_DRIVER==KS0108
110
    return ks0108GetY();
121
    return ks0108GetY();
111
#elif GRAPHICSDRIVER==DOTMATRIX
122
#elif GRAPHICS_DRIVER==DOTMATRIX
112
    return dotmatrixGetY();
123
    return dotmatrixGetY();
113
#endif
124
#endif
114
}
125
}
115
 
126
 
116
void glcdInit(void)
127
void glcdInit(void)
-
 
128
{
-
 
129
#if GRAPHICS_DRIVER==KS0108
-
 
130
    ks0108Init();
-
 
131
#elif GRAPHICS_DRIVER==DOTMATRIX
-
 
132
    dotmatrixInit();
-
 
133
#endif
-
 
134
}
-
 
135
 
-
 
136
void glcdRefresh(void)
117
{
137
{
118
#if GRAPHICSDRIVER==KS0108
138
#if GRAPHICS_DRIVER==KS0108
119
    ks0108Init();
139
    /* No refresh needed */
120
#elif GRAPHICSDRIVER==DOTMATRIX
140
#elif GRAPHICS_DRIVER==DOTMATRIX
121
    dotmatrixInit();
141
    dotmatrixRefresh();
122
#endif
142
#endif
123
}
143
}
124
 
144
 
125
void glcdWriteChar(char c, uint8_t color)
145
void glcdWriteChar(char c, uint8_t color)
126
{
146
{
127
    uint8_t i = 0;
147
    uint8_t i = 0;
128
    if (glcdGetX() > (KS0108_WIDTH-5))
148
    if (glcdGetX() > (GRAPHICS_WIDTH-5))
129
    {
149
    {
130
        glcdSetXY(0, glcdGetY() + 8);
150
        glcdSetXY(0, glcdGetY() + 8);
131
    }
151
    }
132
 
152
 
133
    for(i=0; i<5; i++)
153
    for(i=0; i<5; i++)
Line 144... Line 164...
144
    }
164
    }
145
}
165
}
146
void glcdWriteCharTransparent(char c, uint8_t color)
166
void glcdWriteCharTransparent(char c, uint8_t color)
147
{
167
{
148
    uint8_t i = 0;
168
    uint8_t i = 0;
149
    if (glcdGetX() > (KS0108_WIDTH-5))
169
    if (glcdGetX() > (GRAPHICS_WIDTH-5))
150
    {
170
    {
151
        glcdSetXY(0, glcdGetY() + 8);
171
        glcdSetXY(0, glcdGetY() + 8);
152
    }
172
    }
153
 
173
 
154
    for(i=0; i<5; i++)
174
    for(i=0; i<5; i++)
Line 365... Line 385...
365
void glcdInvert(void) {
385
void glcdInvert(void) {
366
    if(glcdGetColor() == GLCD_COLOR_BLACK)
386
    if(glcdGetColor() == GLCD_COLOR_BLACK)
367
        glcdSetColor(GLCD_COLOR_WHITE);
387
        glcdSetColor(GLCD_COLOR_WHITE);
368
    else
388
    else
369
        glcdSetColor(GLCD_COLOR_BLACK);
389
        glcdSetColor(GLCD_COLOR_BLACK);
370
    glcdInvertRect(0,0,KS0108_WIDTH-1,KS0108_HIGHT-1);
390
    glcdInvertRect(0,0,GRAPHICS_WIDTH-1,GRAPHICS_HEIGHT-1);
371
}
391
}
372
 
392
 
373
void glcdSetDot(uint8_t x, uint8_t y, uint8_t color) {
393
void glcdSetDot(uint8_t x, uint8_t y, uint8_t color) {
374
    glcdSetXY(x, y-y%8);                    // read data from display memory
394
    glcdSetXY(x, y-y%8);                    // read data from display memory
375
    glcdWriteDataTransparent(0x01 << (y%8), GLCD_COLOR_SET);
395
    glcdWriteDataTransparent(0x01 << (y%8), GLCD_COLOR_SET);