-
Notifications
You must be signed in to change notification settings - Fork 1
/
slider.c
170 lines (161 loc) · 5.98 KB
/
slider.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/************************************************************************************************************************
* [FILE NAME] : <slider.c> *
* [AUTHOR] : <Eslam EL-Naggar> *
* [DATE CREATED]: <JAN 1, 2020> *
* [Description} : <Source file for slider functions> *
************************************************************************************************************************/
/*-------------------------------------------------INCLUDES-------------------------------------------------------------*/
#include "glcd.h"
#include "slider.h"
/*----------------------------------------------------------------------------------------------------
[Function Name]: locationGenerator
[Description] : This function is responsible for location of the dot
[Args] :
[IN] :
uint8 * const originPointSlider_Ptr
This argument shall contain the address of X-cordinate of the slider
[Returns] : This function returns void
----------------------------------------------------------------------------------------------------*/
void slideMoverRight(uint8 * const originPointSlider_Ptr) {
uint8 state, counterTemp, n, counter;
//cli();
*originPointSlider_Ptr = *originPointSlider_Ptr + 4;
if (*originPointSlider_Ptr + 8 >= 128) {
*originPointSlider_Ptr = *originPointSlider_Ptr - 4;
} else {
counter = *originPointSlider_Ptr;
counterTemp = counter - 4;
while (counterTemp != counter) {
if (counterTemp < 64) {
GLCD_CTRL_PORT |= (1 << CS1); /* Select Left half of display */
GLCD_CTRL_PORT &= ~(1 << CS2);
GLCD_sendCommand(0x40 + counterTemp);
GLCD_sendCommand(0xB8 + 7);
for (n = 0; n < 2; n++) {
state = GLCD_readData();
}
GLCD_sendCommand(0x40 + counterTemp);
GLCD_sendCommand(0xB8 + 7);
GLCD_sendData(state & ~(0x80));
} else {
GLCD_CTRL_PORT |= (1 << CS2); /* Select Right half of display */
GLCD_CTRL_PORT &= ~(1 << CS1);
GLCD_sendCommand(0x40 + counterTemp - 64);
GLCD_sendCommand(0xB8 + 7);
for (n = 0; n < 2; n++) {
state = GLCD_readData();
}
GLCD_sendCommand(0x40 + counterTemp - 64);
GLCD_sendCommand(0xB8 + 7);
GLCD_sendData(state & ~(0x80));
}
counterTemp++;
sei();
cli();
}
for (; counterTemp <= counter + 8; counterTemp++) {
if (counterTemp < 64) {
GLCD_CTRL_PORT |= (1 << CS1); /* Select Left half of display */
GLCD_CTRL_PORT &= ~(1 << CS2);
GLCD_sendCommand(0x40 + counterTemp);
GLCD_sendCommand(0xB8 + 7);
for (n = 0; n < 2; n++) {
state = GLCD_readData();
}
GLCD_sendCommand(0x40 + counterTemp);
GLCD_sendCommand(0xB8 + 7);
GLCD_sendData((state & ~(0x80)) | 0x80);
} else {
GLCD_CTRL_PORT |= (1 << CS2); /* Select Right half of display */
GLCD_CTRL_PORT &= ~(1 << CS1);
GLCD_sendCommand(0x40 + counterTemp - 64);
GLCD_sendCommand(0xB8 + 7);
for (n = 0; n < 2; n++) {
state = GLCD_readData();
}
GLCD_sendCommand(0x40 + counterTemp - 64);
GLCD_sendCommand(0xB8 + 7);
GLCD_sendData((state & ~(0x80)) | 0x80);
}
sei();
cli();
}
}
//sei();
}
/*----------------------------------------------------------------------------------------------------
[Function Name]: slideMoverLeft
[Description] : This function is responsible for location of the dot
[Args] :
[IN] :
uint8 * const originPointSlider_Ptr
This argument shall contain the address of X-cordinate of the slider
[Returns] : This function returns void
----------------------------------------------------------------------------------------------------*/
void slideMoverLeft(uint8 * const originPointSlider_Ptr) {
uint8 state, counterTemp,n,counter;
//cli();
*originPointSlider_Ptr = *originPointSlider_Ptr - 4;
if (*originPointSlider_Ptr >= 128) {
*originPointSlider_Ptr = *originPointSlider_Ptr + 4;
} else {
counter = *originPointSlider_Ptr;
counterTemp = counter + 8;
for (counterTemp = counter; counterTemp <= counter + 4; counterTemp++) {
if (counterTemp < 64) {
GLCD_CTRL_PORT |= (1 << CS1); /* Select Left half of display */
GLCD_CTRL_PORT &= ~(1 << CS2);
GLCD_sendCommand(0x40 + counterTemp);
GLCD_sendCommand(0xB8 + 7);
for (n = 0; n < 2; n++) {
state = GLCD_readData();
}
GLCD_sendCommand(0x40 + counterTemp);
GLCD_sendCommand(0xB8 + 7);
GLCD_sendData((state & ~(0x80)) | 0x80);
} else {
GLCD_CTRL_PORT |= (1 << CS2); /* Select Right half of display */
GLCD_CTRL_PORT &= ~(1 << CS1);
GLCD_sendCommand(0x40 + counterTemp - 64);
GLCD_sendCommand(0xB8 + 7);
for (n = 0; n < 2; n++) {
state = GLCD_readData();
}
GLCD_sendCommand(0x40 + counterTemp - 64);
GLCD_sendCommand(0xB8 + 7);
GLCD_sendData((state & ~(0x80)) | 0x80);
}
sei();
cli();
}
for (counterTemp = counter + 8; counterTemp <= counter + 8 + 4;
counterTemp++) {
if (counterTemp < 64) {
GLCD_CTRL_PORT |= (1 << CS1); /* Select Left half of display */
GLCD_CTRL_PORT &= ~(1 << CS2);
GLCD_sendCommand(0x40 + counterTemp);
GLCD_sendCommand(0xB8 + 7);
for (n = 0; n < 2; n++) {
state = GLCD_readData();
}
GLCD_sendCommand(0x40 + counterTemp);
GLCD_sendCommand(0xB8 + 7);
GLCD_sendData(state & ~(0x80));
} else {
GLCD_CTRL_PORT |= (1 << CS2); /* Select Right half of display */
GLCD_CTRL_PORT &= ~(1 << CS1);
GLCD_sendCommand(0x40 + counterTemp - 64);
GLCD_sendCommand(0xB8 + 7);
for (n = 0; n < 2; n++) {
state = GLCD_readData();
}
GLCD_sendCommand(0x40 + counterTemp - 64);
GLCD_sendCommand(0xB8 + 7);
GLCD_sendData(state & ~(0x80));
}
sei();
cli();
}
}
//sei();
}