-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathData.ino
80 lines (73 loc) · 2.02 KB
/
Data.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
void LoadData(){
LoadLevel();
LoadValuation();
LoadLevelThreshold();
LoadInvertation();
LoadAP();
}
void LoadLevel() {
calibrationX = readIntFromEEPROM(EEPROM_LEVEL_X);
calibrationY = readIntFromEEPROM(EEPROM_LEVEL_Y);
if (calibrationX == 0xffff || calibrationY == 0xffff) {
calibrationX = -150;
calibrationY = -125;
StoreLevel();
}
Serial.print(F("Loaded X: "));
Serial.print(calibrationX);
Serial.print(F(" Y: "));
Serial.println(calibrationY);
}
void LoadValuation() {
valuationX = readIntFromEEPROM(EEPROM_VALUATION_X);
valuationY = readIntFromEEPROM(EEPROM_VALUATION_Y);
if (valuationX == 0xffff || valuationY == 0xffff) {
valuationX = 271;
valuationY = 267;
StoreLevelValuation();
}
Serial.print(F("Loaded Valuation: "));
Serial.print(F(" X: "));
Serial.print(valuationX);
Serial.print(F(" Y: "));
Serial.println(valuationY);
}
void LoadLevelThreshold() {
levelThreshold = EEPROM.read(EEPROM_LEVEL_THRESHOLD);
if (levelThreshold == 0xff || levelThreshold == 0)
levelThreshold = 5;
Serial.print(F("Loaded Threshold: "));
Serial.println(levelThreshold);
}
void LoadInvertation() {
invertAxis = EEPROM.read(EEPROM_LEVEL_INVERTATION);
Serial.print(F("Loaded Inverted Axis: "));
Serial.println(invertAxis);
}
void LoadAP() {
useAcessPointMode = EEPROM.read(EEPROM_LEVEL_ACCESSPOINT);
Serial.print(F("Loaded AccessPoint: "));
Serial.println(useAcessPointMode);
}
void StoreLevel() {
writeIntIntoEEPROM(EEPROM_LEVEL_X, calibrationX);
writeIntIntoEEPROM(EEPROM_LEVEL_Y, calibrationY);
EEPROM.commit();
}
void StoreLevelValuation() {
writeIntIntoEEPROM(EEPROM_VALUATION_X, valuationX);
writeIntIntoEEPROM(EEPROM_VALUATION_Y, valuationY);
EEPROM.commit();
}
void StoreLevelThreshold() {
EEPROM.write(EEPROM_LEVEL_THRESHOLD, levelThreshold);
EEPROM.commit();
}
void StoreInvertation() {
EEPROM.write(EEPROM_LEVEL_INVERTATION, invertAxis);
EEPROM.commit();
}
void StoreAP() {
EEPROM.write(EEPROM_LEVEL_ACCESSPOINT, useAcessPointMode);
EEPROM.commit();
}