View Single Post
Old 10-04-2010, 09:20 AM   #5 (permalink)
FalconFour
EcoModding Lurker
 
FalconFour's Avatar
 
Join Date: Sep 2010
Location: Fresno, CA
Posts: 78

LEAF - '11 Nissan LEAF
Thanks: 4
Thanked 9 Times in 7 Posts
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);
  }
}
Attached Thumbnails
Click image for larger version

Name:	20101004061503.jpg
Views:	104
Size:	126.5 KB
ID:	6982  
  Reply With Quote