Go Back   EcoModder Forum > EcoModding > Instrumentation > OpenGauge / MPGuino FE computer
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 09-26-2009, 03:59 AM   #11 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location: ÿ
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
lcd_gotoXY probably needs a tweak for 4x20 to get the lcd addressing right, here is the original 2x16 version
/*
* LCD functions
*/
// x=0..16, y=0..1
void lcd_gotoXY(byte x, byte y)
{
byte dr=0x80+x;
if(y!=0) // save 2 bytes compared to "if(y==1)"
dr+=0x40;
lcd_commandWrite(dr);
}

__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 09-26-2009, 04:04 AM   #12 (permalink)
EcoModding Lurker
 
Join Date: Sep 2009
Location: Melbourne, Australia
Posts: 15
Thanks: 1
Thanked 10 Times in 8 Posts
Quote:
Originally Posted by dcb View Post
if(y!=0) // save 2 bytes compared to "if(y==1)"
dr+=0x40;
Oh yeah, that's the problem right there. It assumes that if it's not the first row it must be the second.

Thanks DCB!

I'm running in 16x2 mode at the moment but once I've finished mucking around with the datalogging and GPS code I'll have a look at that.

Cheers :-)

Jonathan Oxer
  Reply With Quote
Old 09-26-2009, 06:59 AM   #13 (permalink)
EcoModding Lurker
 
Join Date: Sep 2009
Location: Melbourne, Australia
Posts: 15
Thanks: 1
Thanked 10 Times in 8 Posts
I've fixed the lcd_gotoXY function so it works correctly with 20x4 displays, but at the cost of an extra 54 bytes. That's a lot of extra memory for something that not many people will want, so maybe there should be two versions of the function and the correct one is selected at compile time based on the value of LCD_ROWS.

This is the new version of the function:

Code:
void lcd_gotoXY(byte x, byte y)
{
  if ( y > LCD_ROWS )
    y = LCD_ROWS - 1;    // Safety check for calls beyond the LCD

  byte row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
  byte dr=0x80+x + row_offsets[y];

  lcd_commandWrite(dr);
}
8 bytes of that extra volume is the check for calls to a row beyond that allowed for the given LCD size. Without that check in place it's possible for a call to this function to read random memory beyond the end of the offset array, and send that data to the LCD.

This function can probably be optimized but it's working fine for me on a 20x4 and since I'm running on an ATmega1280 with 128K of memory the size doesn't really matter to me. If someone else wants to have a go at putting it on a diet, go for it!
  Reply With Quote
The Following 2 Users Say Thank You to jonoxer For This Useful Post:
dewasha (07-16-2013), ECONORAM (03-18-2014)
Old 09-26-2009, 07:34 PM   #14 (permalink)
EcoModding Apprentice
 
Join Date: Aug 2009
Location: terra firma
Posts: 138
Thanks: 4
Thanked 24 Times in 22 Posts
here you go:

//byte row_offsets is unused
byte dr = 0x80 + x + (y&1 ? 0x40 : 0) + (y&2 ? 0x14 : 0);
//32 bytes saved (burp)


edit: this one appears to save 18 more:

byte dr = 0x80 + x;
if (y&1) dr+= 0x40;
if (y&2) dr+= 0x14;

Last edited by nickdigger; 09-26-2009 at 07:40 PM..
  Reply With Quote
The Following User Says Thank You to nickdigger For This Useful Post:
Froggy (09-27-2009)
Old 09-26-2009, 09:11 PM   #15 (permalink)
EcoModding Lurker
 
Join Date: Apr 2009
Location: Debolt, Alberta
Posts: 78
Thanks: 1
Thanked 2 Times in 2 Posts
Thanks for the hard work guys. I log in to see what's up and see some great looking code already posted.

Using Nickdiggers code, it only costs 4 more bytes. (Zero increase for two line displays if we exclude the second if statement.) Very nice.
  Reply With Quote
Old 09-26-2009, 11:53 PM   #16 (permalink)
EcoModding Lurker
 
Join Date: Sep 2009
Location: Melbourne, Australia
Posts: 15
Thanks: 1
Thanked 10 Times in 8 Posts
nickdigger, you're a champion.

Code:
byte dr = 0x80 + x;
if (y&1)  dr+= 0x40;
if (y&2)  dr+= 0x14;
Tested on my 20x4 and works perfectly. I've committed that to my copy of the OBDuino32KMega tree.

Cheers :-)

Jonathan Oxer
http://jon.oxer.com.au/
  Reply With Quote
The Following User Says Thank You to jonoxer For This Useful Post:
dewasha (07-16-2013)
Old 09-27-2009, 11:11 AM   #17 (permalink)
EcoModding Lurker
 
Join Date: Apr 2009
Location: Debolt, Alberta
Posts: 78
Thanks: 1
Thanked 2 Times in 2 Posts
I have checked in the revised OBDuino32k code that allows 4 line displays to function correctly. (version 165)

Thanks to all involved in the correction.
  Reply With Quote
Old 09-27-2009, 11:35 PM   #18 (permalink)
EcoModding Lurker
 
Join Date: Apr 2009
Location: Debolt, Alberta
Posts: 78
Thanks: 1
Thanked 2 Times in 2 Posts
That's quite the impressive Google Earth display. There's a lot of potential there.
  Reply With Quote
Old 09-27-2009, 11:44 PM   #19 (permalink)
EcoModding Lurker
 
Join Date: Sep 2009
Location: Melbourne, Australia
Posts: 15
Thanks: 1
Thanked 10 Times in 8 Posts
Thanks Froggy.

I did a blog post about it on Practical Arduino yesterday, too:

Practical Arduino: News - Car engine datalogger project update

I ran the logger again this morning on my trip to work, and now that I have everything in place it only takes a few seconds to plug in the memory stick, run the conversion script, and open it in Google Earth to see a trip visualization. This morning I had a few work colleagues looking over my shoulder as I flew around the trip and they thought it was pretty cool.

Cheers :-)

Jonathan Oxer
  Reply With Quote
Old 10-04-2009, 06:27 AM   #20 (permalink)
EcoModding Lurker
 
Join Date: Jun 2009
Location: outskirts
Posts: 17
Thanks: 0
Thanked 1 Time in 1 Post
Thanks for this fantastic addition to the OBDuino project.
You might be interested in connecting those three buttons wirelessly via
basic strap on style steering wheel remote kit, in that fashion you can easily cycle through the different PID and contrast settings on the LCD and still be safely focused with both hands on driving.

some links:
steering wheel remote - Google Search


Last edited by Mesuge; 10-04-2009 at 06:37 AM..
  Reply With Quote
Reply  Post New Thread


Tags
arduino, mega, obd, obduino



Similar Threads
Thread Thread Starter Forum Replies Last Post
OBDuino working with ELM327 Magister OpenGauge / MPGuino FE computer 49 12-28-2020 11:00 AM
OBDuino CAN version only, progress! Magister OpenGauge / MPGuino FE computer 26 01-19-2011 09:03 AM
OBDuino Feature Request... electromike OpenGauge / MPGuino FE computer 13 07-23-2009 02:46 PM
OBDuino mod - no need of 'uino' Dominik OpenGauge / MPGuino FE computer 4 06-19-2009 10:41 AM
OBDuino and the 328p? gone22 OpenGauge / MPGuino FE computer 0 04-12-2009 09:56 PM



Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com