1 | //-------------------------------------------------------------------------------------------------
|
2 | //
|
3 | //-------------------------------------------------------------------------------------------------
|
4 | #include "sed1335.h"
|
5 | #include <util/delay.h>
|
6 |
|
7 | extern void GLCD_InitializePorts(void);
|
8 |
|
9 | //-------------------------------------------------------------------------------------------------
|
10 | // Funkcja inicjalizacji wyœwietlacza
|
11 | //-------------------------------------------------------------------------------------------------
|
12 | void GLCD_Initialize(void)
|
13 | {
|
14 | GLCD_InitializePorts();
|
15 |
|
16 | GLCD_WriteCommand(SED1335_SYSTEM_SET);
|
17 | GLCD_WriteData(SED1335_SYS_P1);
|
18 | GLCD_WriteData(SED1335_SYS_P2);
|
19 | GLCD_WriteData(SED1335_FY);
|
20 | GLCD_WriteData(SED1335_CR);
|
21 | GLCD_WriteData(SED1335_TCR);
|
22 | GLCD_WriteData(SED1335_LF);
|
23 | GLCD_WriteData(SED1335_APL);
|
24 | GLCD_WriteData(SED1335_APH);
|
25 |
|
26 | GLCD_WriteCommand(SED1335_SCROLL);
|
27 | GLCD_WriteData(SED1335_SAD1L);
|
28 | GLCD_WriteData(SED1335_SAD1H);
|
29 | GLCD_WriteData(SED1335_SL1);
|
30 | GLCD_WriteData(SED1335_SAD2L);
|
31 | GLCD_WriteData(SED1335_SAD2H);
|
32 | GLCD_WriteData(SED1335_SL2);
|
33 | GLCD_WriteData(SED1335_SAD3L);
|
34 | GLCD_WriteData(SED1335_SAD3H);
|
35 | GLCD_WriteData(SED1335_SAD4L);
|
36 | GLCD_WriteData(SED1335_SAD4H);
|
37 |
|
38 | GLCD_WriteCommand(SED1335_CSRFORM);
|
39 | GLCD_WriteData(SED1335_CRX);
|
40 | GLCD_WriteData(SED1335_CSRF_P2);
|
41 |
|
42 | GLCD_WriteCommand(SED1335_CGRAM_ADR);
|
43 | GLCD_WriteData(SED1335_SAGL);
|
44 | GLCD_WriteData(SED1335_SAGH);
|
45 |
|
46 | GLCD_WriteCommand(SED1335_CSRDIR_R);
|
47 |
|
48 | GLCD_WriteCommand(SED1335_HDOT_SCR);
|
49 | GLCD_WriteData(SED1335_SCRD);
|
50 |
|
51 | GLCD_WriteCommand(SED1335_OVLAY);
|
52 | GLCD_WriteData(SED1335_OVLAY_P1);
|
53 |
|
54 | GLCD_WriteCommand(SED1335_DISP_ON);
|
55 | GLCD_WriteData(SED1335_FLASH);
|
56 | }
|
57 | //-------------------------------------------------------------------------------------------------
|
58 | // Funkcja zapalaj¹ca piksel
|
59 | //-------------------------------------------------------------------------------------------------
|
60 | void GLCD_SetPixel(unsigned int x,unsigned int y, int color)
|
61 | {
|
62 | unsigned char tmp = 0;
|
63 | unsigned int address = SED1335_GRAPHICSTART + (40 * y) + (x/8);
|
64 | GLCD_SetCursorAddress(address);
|
65 |
|
66 | GLCD_WriteCommand(SED1335_MREAD);
|
67 | tmp = GLCD_ReadData();
|
68 |
|
69 | if(color)
|
70 | tmp |= (1 << (SED1335_FX - (x % 8)));
|
71 | else
|
72 | tmp &= ~(1 << (SED1335_FX - (x % 8)));
|
73 |
|
74 | GLCD_SetCursorAddress(address);
|
75 | GLCD_WriteCommand(SED1335_MWRITE);
|
76 | GLCD_WriteData(tmp);
|
77 | }
|
78 | //-------------------------------------------------------------------------------------------------
|
79 | // Funkcja wyswietlajaca tekst
|
80 | //-------------------------------------------------------------------------------------------------
|
81 | void GLCD_WriteText(char * tekst)
|
82 | {
|
83 | GLCD_WriteCommand(SED1335_MWRITE);
|
84 | while(*tekst)
|
85 | GLCD_WriteData(*tekst++);
|
86 | }
|
87 | //-------------------------------------------------------------------------------------------------
|
88 | // Funkcja wyœwietlaj¹ca tekst z pamiêci programu (AVR)
|
89 | //-------------------------------------------------------------------------------------------------
|
90 | void GLCD_WriteTextP(char * tekst)
|
91 | {
|
92 | GLCD_WriteCommand(SED1335_MWRITE);
|
93 | while(GLCD_ReadByteFromROMMemory(tekst))
|
94 | GLCD_WriteData(GLCD_ReadByteFromROMMemory(tekst++));
|
95 | }
|
96 | //-------------------------------------------------------------------------------------------------
|
97 | // Funkcja ustawiaj¹ca adres kursora
|
98 | //-------------------------------------------------------------------------------------------------
|
99 | void GLCD_SetCursorAddress(unsigned int address)
|
100 | {
|
101 | GLCD_WriteCommand(SED1335_CSRW);
|
102 | GLCD_WriteData((unsigned char)(address & 0xFF));
|
103 | GLCD_WriteData((unsigned char)(address >> 8));
|
104 | }
|
105 | //-------------------------------------------------------------------------------------------------
|
106 | //-------------------------------------------------------------------------------------------------
|
107 | void GLCD_TextGoTo(unsigned char x, unsigned char y)
|
108 | {
|
109 | GLCD_SetCursorAddress((y * 40) + x);
|
110 | }
|
111 | //-------------------------------------------------------------------------------------------------
|
112 | //-------------------------------------------------------------------------------------------------
|
113 | void GLCD_GraphicGoTo(unsigned int x, unsigned int y)
|
114 | {
|
115 | GLCD_SetCursorAddress(SED1335_GRAPHICSTART + (y * 40) + x/8);
|
116 | }
|
117 | //-------------------------------------------------------------------------------------------------
|
118 | //-------------------------------------------------------------------------------------------------
|
119 | void GLCD_ClearText(void)
|
120 | {
|
121 | int i;
|
122 | GLCD_TextGoTo(0,0);
|
123 | GLCD_WriteCommand(SED1335_MWRITE);
|
124 | for(i = 0; i < 1200; i++)
|
125 | GLCD_WriteData(' ');
|
126 | }
|
127 | //-------------------------------------------------------------------------------------------------
|
128 | //-------------------------------------------------------------------------------------------------
|
129 | void GLCD_ClearGraphic(void)
|
130 | {
|
131 | unsigned int i;
|
132 | GLCD_SetCursorAddress(SED1335_GRAPHICSTART);
|
133 | GLCD_WriteCommand(SED1335_MWRITE);
|
134 | for(i = 0; i < (40 * 240); i++)
|
135 | GLCD_WriteData(0x00);
|
136 | }
|
137 | //-------------------------------------------------------------------------------------------------
|
138 | //-------------------------------------------------------------------------------------------------
|
139 | void GLCD_Bitmap(char * bmp, int x, int y, int width, int height)
|
140 | {
|
141 | unsigned int i, j;
|
142 | for(i = 0; i < height ; i++)
|
143 | {
|
144 | GLCD_GraphicGoTo(x, y+i);
|
145 | GLCD_WriteCommand(SED1335_MWRITE);
|
146 | for(j = 0; j < width/8; j++)
|
147 | GLCD_WriteData(GLCD_ReadByteFromROMMemory(bmp+j+(40*i)));
|
148 | }
|
149 | }
|
150 | //-------------------------------------------------------------------------------------------------
|
151 | //-------------------------------------------------------------------------------------------------
|