21 #include "test_routines.h"
24 #include "avrlibdefs.h"
28 #include <avr/interrupt.h>
31 #define WELCOME 0 // Must be 0
32 #define BASE_SPEED_TWEAK 1
33 #define LINE_TRACK_TWEAK 2
36 #define PAN_TILT_TWEAK 5
37 #define TRACTOR_OVERSHOOT_DELAY_TWEAK 6
38 #define u08_TEMP_TWEAK 7
39 #define u16_TEMP_TWEAK 8
40 #define TEST_MODE_TWEAK 9
42 #define NUM_TWEAK_MODES 10
44 #define DELTA_SLOPE_COEF 8
45 #define DELTA_TEMP_2 2
47 static uint8_t tweakMode;
49 #define turnOnRemoteLight() sbi(PORTD, 7)
50 #define turnOffRemoteLight() cbi(PORTD, 7)
52 static inline void updateTweaks(
void);
53 static inline void printValues(
void);
54 static inline void toggleTweakMode(uint8_t modeIncrement);
56 inline void runTetherUI(
void)
62 lcdWriteStr(
"Welcome, T-mode:", 0, 0);
74 if (bothRightButtonsPressed())
78 if (bothLeftButtonsPressed())
87 if (tweakMode != WELCOME)
96 inline void updateTweaks(
void)
100 case BASE_SPEED_TWEAK:
111 case LINE_TRACK_TWEAK:
113 slopeCoef += DELTA_SLOPE_COEF;
115 slopeCoef -= DELTA_SLOPE_COEF;
155 case TRACTOR_OVERSHOOT_DELAY_TWEAK:
157 tractorOvershootDelay += 50;
159 tractorOvershootDelay -= 50;
168 tempTweak2 += DELTA_TEMP_2;
170 tempTweak2 -= DELTA_TEMP_2;
184 case TEST_MODE_TWEAK:
196 inline void printValues(
void)
200 case BASE_SPEED_TWEAK:
201 lcdPrintHex(l_base, 1, 5);
202 lcdPrintHex(r_base, 1, 14);
204 case LINE_TRACK_TWEAK:
205 lcdPrintHex(slopeCoef >> 8, 1, 3);
206 lcdPrintHex(slopeCoef, 1, 5);
207 lcdPrintHex(offCoef >> 8, 1, 11);
208 lcdPrintHex(offCoef, 1, 13);
211 lcdPrintHex(dampCoef, 1, 5);
212 lcdPrintHex(lineCenter, 1, 13);
215 lcdPrintHex(turnPoint, 1, 3);
216 lcdPrintHex(turnSubtract, 1, 12);
219 lcdPrintHex(panOffset, 1, 5);
220 lcdPrintHex(tiltOffset, 1, 13);
222 case TRACTOR_OVERSHOOT_DELAY_TWEAK:
223 lcdPrintHex(tractorOvershootDelay >> 8, 1, 4);
224 lcdPrintHex(tractorOvershootDelay, 1, 6);
227 lcdPrintHex(tempTweak1, 1, 3);
228 lcdPrintHex(tempTweak2, 1, 12);
231 lcdPrintHex(tempTweak3 >> 8, 1, 3);
232 lcdPrintHex(tempTweak3, 1, 5);
233 lcdPrintHex(tempTweak4 >> 8, 1, 11);
234 lcdPrintHex(tempTweak4, 1, 13);
242 inline void toggleTweakMode(uint8_t modeIncrement)
245 tweakMode += modeIncrement;
246 if (tweakMode == NUM_TWEAK_MODES)
250 else if (tweakMode == 0 || tweakMode == 255)
252 tweakMode = NUM_TWEAK_MODES - 1;
258 case BASE_SPEED_TWEAK:
259 lcdWriteStr(
"Base speed tweak", 0, 0);
260 lcdWriteStr(
"Left: Right: ", 1, 0);
262 case LINE_TRACK_TWEAK:
263 lcdWriteStr(
"Slp & Offst Cnst", 0, 0);
264 lcdWriteStr(
"sc: oc: ", 1, 0);
267 lcdWriteStr(
"Damping & Center", 0, 0);
268 lcdWriteStr(
"damp: cntr: ", 1, 0);
271 lcdWriteStr(
"Turn tweak ", 0, 0);
272 lcdWriteStr(
"pt: subt: ", 1, 0);
275 lcdWriteStr(
"Pan,Tilt Offsets", 0, 0);
276 lcdWriteStr(
"Pan: tilt: ", 1, 0);
278 case TRACTOR_OVERSHOOT_DELAY_TWEAK:
279 lcdWriteStr(
"Tractor Os Delay", 0, 0);
280 lcdWriteStr(
"dly: ", 1, 0);
283 lcdWriteStr(
"uint8_t Temp Tweaks ", 0, 0);
284 lcdWriteStr(
"T1: T2: ", 1, 0);
287 lcdWriteStr(
"u16 Temp Tweaks ", 0, 0);
288 lcdWriteStr(
"T3: T4: ", 1, 0);
290 case TEST_MODE_TWEAK:
291 lcdWriteStr(
"Test mode tweak ", 0, 0);