--- LCD_driver.c.orig 2011-05-30 11:41:21.000000000 -0700 +++ LCD_driver_progmem.c 2011-05-30 12:23:19.000000000 -0700 @@ -5,6 +5,7 @@ //************************************************************************ //* Edit History //* = Mark Sproul msproul -at- jove.rutgers.edu +//* = Leigh@wa5znu.org //************************************************************************ //* Apr 2, 2010 I received my Color LCD Shield sku: LCD-09363 from sparkfun //* Apr 2, 2010 The code was written for WinAVR, I modified it to compile under Arduino @@ -12,6 +13,7 @@ //* Apr 3, 2010 Made LCDSetPixel public //* Apr 3, 2010 Working on MEGA, pin defs in nokia_tester.h //* Apr 4, 2010 Removed delays from LCDCommand & LCDCommand, increased speed by 75% +//* May 30, 2011 Converted font to progmem to save 1552 bytes of RAM. //************************************************************************ #include "LCD_driver.h" #include @@ -440,15 +442,15 @@ unsigned char Mask; unsigned int Word0; unsigned int Word1; -unsigned char *pFont; -unsigned char *pChar; +prog_uchar *pFont; +prog_uchar *pChar; // get pointer to the beginning of the selected font table -pFont = (unsigned char *)FONT8x16; +pFont = (prog_uchar *)FONT8x16; // get the nColumns, nRows and nBytes -nCols = *pFont; -nRows = *(pFont + 1); -nBytes = *(pFont + 2); +nCols = pgm_read_byte(pFont); +nRows = pgm_read_byte(pFont + 1); +nBytes = pgm_read_byte(pFont + 2); // get pointer to the last byte of the desired character pChar = pFont + (nBytes * (c - 0x1F)) + nBytes - 1; // Row address set (command 0x2B) @@ -464,7 +466,7 @@ // loop on each row, working backwards from the bottom to the top for (i = nRows - 1; i >= 0; i--) { // copy pixel row from font table and then decrement row - PixelRow = *pChar++; + PixelRow = pgm_read_byte(pChar++); // loop on each pixel in the row (left to right) // Note: we do two pixels each loop Mask = 0x80; @@ -526,7 +528,7 @@ } } -const unsigned char FONT8x16[97][16] = { +const prog_uchar FONT8x16[97][16] PROGMEM = { 0x08,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x08,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,