Updated both mods... tank remaining MPG now actually works (yay! d'oh), learned a little too late about the 64-bit, integer-based *1000 math that was used in MPGuino... so all the calculations were screwed up. All fixed now with sane math and a better understanding of how to follow MPGuino as it runs around the room...
Also updated clock to fix the bug I noticed as I was posting it. Still not functional; tomorrow I'll work on a menu that allows you to set the time. Already added a menu as in the photo. Will work on adding clock- and tank-setting menus tomorrow!
BTW, here's as small as I could get the menu code: (sorry, haven't gotten around to commenting it - but check out that pos-pointer statement! Hint: press L/R to go to the 4 corners.)
Code:
void setupGuino() { // setup menu
LCD::gotoXY(0,0);
//LCD::print(" ");
LCD::print("Params | Clock");
LCD::gotoXY(0,1);
LCD::print("Tank | Exit");
LCD::LcdCommandWrite(0b00001110);
byte p=3;
byte keyLock=1;
while (true) {
if (p < 4)
LCD::gotoXY((bitRead(p,0)*15), bitRead(p,1));
if (keyLock == 0) {
if (!(buttonState & lbuttonBit)) {// left
p--;
if (p == 255) p = 3;
}
else if (!(buttonState & rbuttonBit)) {// right
p++;
if (p == 4) p = 0;
}
else if (!(buttonState & mbuttonBit)) {// middle
LCD::LcdCommandWrite(0b00001100);
if (p == 0) { // params
initGuino();
return;
}
else if (p == 1) { // clock
// tbd
return;
}
else if (p == 2) { // tank
// tbd
return;
}
else if (p == 3) { // exit
return;
}
}
if (buttonState != buttonsUp) keyLock = 1;
} else {
keyLock = 0;
}
buttonState = buttonsUp;
delay2(125);
}
}