View Single Post
Old 03-29-2011, 01:46 PM   #14 (permalink)
mcmancuso
EcoModding Lurker
 
mcmancuso's Avatar
 
Join Date: Mar 2010
Location: TN-USA
Posts: 61

Green Metro - '99 Chevrolet Metro LSi Sedan
90 day: 32.78 mpg (US)

Metro Vert - '91 Geo Metro LSi Convertible
90 day: 50.52 mpg (US)
Thanks: 0
Thanked 1 Time in 1 Post
I just got my MPGuino and have been working on these changes as well, incorporating the round big font into the .86 build I did just last night, and I started on incorporating the save to eeprom/graphs etc.. functions. I can send you my code, either complete, or just the changes. Here's the modified (changed to proper .cpp format) code for the round big font (copied from the hacks page with corrections):


Start by adding this line near the top of the mpguino.pde file:

#define CFG_BIGFONT_TYPE 2 // 1=Default 2=Modified

By setting this to '1' before you compile, you'll get the current font. Set it to '2' and then recompile, and you get the new, 'rounder' big font. The big font adds about 20 bytes to the compiled code size.

Find the declaration for bignumchars1 and bignumchars2. Delete these lines. Now add the following code near the top of the file, probably right underneath the CFG_BIGFONT_TYPE line you see above.

#if (CFG_BIGFONT_TYPE == 1)
//32 = 0x20 = space
const unsigned char LcdNewChars = 5;
const unsigned char LcdCharHeightPix = 8;
char bignumchars1[]={4,1,4,0, 1,4,32,0, 3,3,4,0, 1,3,4,0, 4,2,4,0, 4,3,3,0, 4,3,3,0, 1,1,4,0, 4,3,4,0, 4,3,4,0};
char bignumchars2[]={4,2,4,0, 2,4,2,0, 4,2,2,0, 2,2,4,0, 32,32,4,0, 2,2,4,0, 4,2,4,0, 32,4,32,0, 4,2,4,0, 2,2,4,0};
#elif (CFG_BIGFONT_TYPE == 2)
//255 = 0xFF = all black character
const unsigned char LcdNewChars = 8;
const unsigned char LcdCharHeightPix = 8;
char bignumchars1[]={7,1,8,0, 1,255,32,0, 3,3,8,0, 1,3,8,0, 255,2,255,0, 255,3,3,0, 7,3,3,0, 1,1,6,0, 7,3,8,0, 7,3,8,0};
char bignumchars2[]={4,2,6,0, 32,255,32,0, 255,2,2,0, 2,2,6,0, 32,32,255,0, 2,2,6,0, 4,2,6,0, 32,7,32,0, 4,2,6,0, 2,2,6,0};
#endif

The above will eventually tell the LCD how to represent the new characters. bignumchars1 is line 1 of the LCD, and bignumchars2 is line 2. Each grouping of four numbers ("null-terminated" with a zero) points to the new characters we will define next. So for example, the large font number zero consists of:

Special character 7, 1, and 8 on line 1, and special characters 4, 2, and 6 on line 2.

Entries above like 255 and 32 point to already-existing characters in the LCD. 255 (or 0xFF in hex) points to a character that is a solid block. 32 (0x20) is a space (empty character).

Now find the chars[] declaration. Delete it, and replace it with this:

#if (CFG_BIGFONT_TYPE == 1)
static byte chars[] PROGMEM = {
0b11111,0b00000,0b11111,0b11111,0b00000,
0b11111,0b00000,0b11111,0b11111,0b00000,
0b11111,0b00000,0b11111,0b11111,0b00000,
0b00000,0b00000,0b00000,0b11111,0b00000,
0b00000,0b00000,0b00000,0b11111,0b00000,
0b00000,0b11111,0b11111,0b11111,0b01110,
0b00000,0b11111,0b11111,0b11111,0b01110,
0b00000,0b11111,0b11111,0b11111,0b01110};
#elif (CFG_BIGFONT_TYPE == 2)
/* XXX: For whatever reason I can not figure out how
* to store more than 8 chars in the LCD CGRAM */
static byte chars[] PROGMEM = {
0b11111, 0b00000, 0b11111, 0b11111, 0b00000, 0b11111, 0b00111, 0b11100,
0b11111, 0b00000, 0b11111, 0b11111, 0b00000, 0b11111, 0b01111, 0b11110,
0b00000, 0b00000, 0b00000, 0b11111, 0b00000, 0b11111, 0b11111, 0b11111,
0b00000, 0b00000, 0b00000, 0b11111, 0b00000, 0b11111, 0b11111, 0b11111,
0b00000, 0b00000, 0b00000, 0b11111, 0b00000, 0b11111, 0b11111, 0b11111,
0b00000, 0b00000, 0b00000, 0b11111, 0b01110, 0b11111, 0b11111, 0b11111,
0b00000, 0b11111, 0b11111, 0b01111, 0b01110, 0b11110, 0b11111, 0b11111,
0b00000, 0b11111, 0b11111, 0b00111, 0b01110, 0b11100, 0b11111, 0b11111};
#endif

The above are binary representations of the pixels for the custom characters that we will upload to a special scratch area in the LCD. Each 'block' above is a number in the character generator RAM starting with 1 and going up to 8.

Now find the code that looks like this below, and either alter it so it looks EXACTLY like this, or just delete it and replace it with this:

/* write the character data to the character generator ram */
for(byte x=0;x<LcdNewChars;x++) {
for(byte y=0;y<LcdCharHeightPix;y++) {
LcdDataWrite(pgm_read_byte(&chars[y*LcdNewChars+x]));
}
}

I could not figure out how to cram more than eight characters into the LCD's CGRAM. If anyone can help with this I would add a few more characters to make this font even nicer. By following the above structure, you can see how to add a CFG_BIGFONT_TYPE 3, and create your own font variant.
(adapted from skelly)


I can also provide the complete .cpp with this change already in it, or the .cpp with this change and the "Save Current Tank Data / Archive Tank Summary / Track Gas-Used per Speed Range" code added(this part of code still has some errors, but its all in the right place ready to be corrected)

Last edited by mcmancuso; 03-29-2011 at 01:52 PM.. Reason: typos
  Reply With Quote