-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfeature.ino
219 lines (204 loc) · 4.44 KB
/
feature.ino
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/*
* GUIGUR 2015 - 2017
*/
# include "margoulinade.h"
void checkMem()
{
if(EEPROM.read(0) != 0)
{
lcd.print(F("RESET EEPROM"));
for (int i = 0 ; i < 1023 ; i++)
{
EEPROM.write(i, 0);
}
lcd.setCursor(0, 1);
lcd.print(F("OK"));
wait4button();
}
}
void eepromDebug()
{
int value;
int address;
while(wait4button)
{
value = EEPROM.read(address);
lcd.print(address);
lcd.print(F(":"));
lcd.print(value);
lcd.print(F("|"));
lcd.print(EEPROM.length());
lcd.print(F("."));
address++;
delay(500);
lcd.clear();
}
wait4button();
}
void selectMenu()
{
}
void checkPassword()
{
lcd.clear();
int i = 0;
char storedpasswd[PASSWDLENGHT + 2] = "";
Serial.print(PASSWDLENGHT);
if (EEPROM.read(1) == 1)
{
lcd.print(F("Enter passwd"));
lcd.setCursor(0, 1);
while(i < PASSWDLENGHT)
{
while(digitalRead(encButton))
{
int newPosition = myEnc.read();
if ((newPosition != oldPosition) )
{
oldPosition = newPosition;
if(oldPosition > (PASSWDELEMENTS * ENCODERSTEPS) - 1)
{
myEnc.write(0);
}
else if(oldPosition < 0)
{
myEnc.write(PASSWDELEMENTS * ENCODERSTEPS - 1);
}
Serial.println(newPosition / ENCODERSTEPS);
lcd.clear();
lcd.print(F("Enter passwd"));
}
lcd.setCursor(0, 1);
lcd.print(storedpasswd);
lcd.setCursor(i, 1);
lcd.print(passwdChars[newPosition / ENCODERSTEPS]);
storedpasswd[i] = passwdChars[newPosition / ENCODERSTEPS];
}
beep(50);
delay(200);
i++;
}
verifPasswd(storedpasswd);
}
}
int verifPasswd(char storedpasswd[PASSWDLENGHT + 2])
{
Serial.print(storedpasswd);
lcd.clear();
Serial.print(">");
Serial.print(storedpasswd);
Serial.print("<>");
Serial.print(password);
Serial.print("<");
if (strcmp(storedpasswd, password) == 0)
{
Serial.println(F("\n\nDONE ! passwd is ok"));
lcd.print(F("Happy hacking :)"));
lcd.clear();
beep(50);
beep(50);
beep(50);
}
else
{
Serial.println(F("\n\Wrong passwd"));
lcd.print(F("Wrong password"));
beep(200);
beep(200);
checkPassword();
}
delay(250);
}
void password_enable_disble_eeprom()
{
lcd.print(F("Password"));
lcd.setCursor(0, 1);
if (EEPROM.read(1) == 1)
{
lcd.print(F("DISABLE"));
}
else
{
lcd.print(F("ENABLE"));
}
wait4button();
if (EEPROM.read(1) == 1)
{
EEPROM.put(1, 0);
}
else
{
EEPROM.put(1, 1);
}
}
void about()
{
lcd.print(F("By guigur&oborotev"));
lcd.setCursor(0, 1);
lcd.print(F("2015-2016 china"));
wait4button();
}
void buzzer_eeprom()
{
lcd.print(F("Buzzer"));
lcd.setCursor(0, 1);
if (EEPROM.read(3) == 0)
{
lcd.print(F("DISABLE"));
}
else
{
lcd.print(F("ENABLE"));
}
wait4button();
if (EEPROM.read(3) == 0)
{
EEPROM.put(3, 1);
}
else
{
EEPROM.put(3, 0);
silentMode = false;
}
}
void batStatus()
{
delay(250);
while (digitalRead(encButton))
{
lcd.setCursor(0, 0);
if (digitalRead(BatFull) == 0 && digitalRead(BatCharg) == 0)
{
Serial.println(F("Error charging circuit"));
lcd.print(F("chrg circ. fail"));
}
else if (digitalRead(BatFull) == 1 && digitalRead(BatCharg) == 0)
{
Serial.println(F("Charging"));
lcd.print(F(" Charging "));
}
else if (digitalRead(BatFull) == 0 && digitalRead(BatCharg) == 1)
{
Serial.println(F("Battery full"));
lcd.print(F(" Battery full "));
}
else
{
Serial.println(F("On battery"));
lcd.print(F(" On battery "));
}
lcd.setCursor(0, 1);
lcd.print(F("V : "));
int v = map(analogRead(A1), 0, 1023, 0, 859);
lcd.print(v/100);
lcd.print(F("."));
lcd.print(v%100);
lcd.setCursor(9 ,1);
lcd.print(F("% : "));
lcd.print(map(map(analogRead(A1), 0, 1023, 0, 859), 0,470, 0, 100));
delay(200);
}
lcd.clear();
beep(50);
delay(250);
}