-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTuneLCD.h
67 lines (60 loc) · 1.59 KB
/
TuneLCD.h
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
#include "JonLib/LCD.h"
int tuneValue ( double value ) {
string valuetext;
float place = 0;
while(true) {
clearLCD();
sprintf(valuetext, "%f", value);
centerLine(0,valuetext);
switch(place) {
case -5: centerLine(1,"hund thths"); break;
case -4: centerLine(1,"ten thths"); break;
case -3: centerLine(1,"thousandths"); break;
case -2: centerLine(1,"hundredths"); break;
case -1: centerLine(1,"tenths"); break;
case 0: centerLine(1,"ones"); break;
case 1: centerLine(1,"tens"); break;
case 2: centerLine(1,"hundreds"); break;
}
if(nLCDButtons == LCD_LEFT_BUTTON) {
waitForRelease();
value = value-pow(10,place);
} else if (nLCDButtons == LCD_RIGHT_BUTTON) {
waitForRelease();
value = value+pow(10,place);
} else if (nLCDButtons == LCD_CENTRE_BUTTON) {
waitForRelease();
if(place==2)
place = -5;
else
place++;
}
else if(nLCDButtons==LCD_LEFT_RIGHT_BUTTON) {
waitForRelease();
writeDebugStream("kP: %f kI: %f kD: %f", gyroscope.kP, gyroscope.kI, gyroscope.kD);
return(value);
}
delay(50);
}
}
task LCD () {
clearLCD();
string currentValues;
while(true) {
sprintf(currentValues, "%f %f %f", gyroscope.kP, gyroscope.kI, gyroscope.kD);
centerDisplay(currentValues, "kP kI kD");
if(nLCDButtons == LCD_LEFT_BUTTON) {
waitForRelease();
gyroscope.kP = tuneValue(gyroscope.kP);
}
if(nLCDButtons == LCD_CENTRE_BUTTON) {
waitForRelease();
gyroscope.kI = tuneValue(gyroscope.kI);
}
if(nLCDButtons == LCD_RIGHT_BUTTON) {
waitForRelease();
gyroscope.kD = tuneValue(gyroscope.kD);
}
delay(60);
}
}