View Single Post
Old 10-04-2010, 08:49 AM   #3 (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
Have I mentioned to you lately that you're an awesome, godlike entity? I mean, in the most literal sense. Think about it. Everyone always says God works in mysterious ways you may not understand. So while I'm sitting here scouring over your code and being like "what on earth is going on here?", I only later realize just what, exactly, on earth is going on there.

It just took a little help from a simple green plant friend to get my mind in "code mode" where I can figure out all these interrelated systems. Standing next to my fridge with a huge case of the munchies I figured out that the math probably isn't floating-point math at all, and that the results I saw by running all the params through format() showed such erratic figures because format() *creates* decimal points based on val*1000. Oy.

Then there was the mystery of pointers and arrays, though. Where I come from in PHPland, an array is a type of data that can contain any other sort of data, and PHP knows what to do with it (feed an integer into a character/string function and it magically becomes a numeric "string"). Now I'm beginning to understand how arrays work. Pointers? Hell, I'm lost on that. I can't figure out for the life of me why this code:
Code:
  LCD::print(getStr(PSTR("OpenGauge       ")));
  LCD::gotoXY(0, 1);
  LCD::print(getStr(PSTR("  MPGuino  v0.86")));
...creates a pointer to, for example, the string "OpenGauge" (+spaces), then immediately passes that pointer to getStr, which itself calls a function that reads the specified pointer from Flash memory...
Instead of simply:
Code:
  LCD::print("OpenGauge       ");
  LCD::gotoXY(0, 1);
  LCD::print("  MPGuino  v0.86");
... which is the way it's done everywhere else in the program. *scratches head* Is there a reason behind that?

I modified the hell out of the tank miles code (the problem code above) and made use of init64 (which I seem to have figured out as you were writing that reply!), and it compiles fine now using tmp1-3, but the display is still 0. Quite likely because I still had no concept about the 1000-based computations, so base MPG is still 17.9999999...

Fun, fun!
  Reply With Quote