I'm using an LCD1604 screen to make a video game(crap idea, I know, but its really just a learning exercise) and I'm running out of local memory so in the hopes of improving this situation I've resorted to F()'s and PROGMEM.
the only constants I have that are not defined using #define are LCD special characters
const byte datRunner[8][8] PROGMEM =
{ { B00100, // RUN 0
B00101,
B11111,
B10100,
B10100,
B01100,
B01010,
B01010
},
{ B00100, // RUN 1
B10100,
B11111,
B00101,
B00101,
B00110,
B01010,
B01010
},
{ B00100, // STAND
B00100,
B01110,
B01110,
B10101,
B00100,
B01010,
B01010
},
{ B00101, // Shoot Up
B00101,
B01110,
B01100,
B01100,
B00110,
B01010,
B01010
},
{ B00100, // Shoot Down
B00100,
B01110,
B10101,
B00101,
B01101,
B01010,
B01010
},
{ B00000, // Shoot Left
B00010,
B00010,
B11110,
B00010,
B01100,
B10100,
B10011
},
{ B00000, // Shoot Right
B01000,
B01000,
B01111,
B01000,
B00110,
B00101,
B11001
},
{ B11111, // Wall
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
}
};
[\code]
and so I've written a function to access this data before setting that as Special Characters for the LCD1604.
[code]
byte* chrDatRunner(int intIndex)
{
byte bytRetVal[8];
for (byte bytCounter = 0; bytCounter < 8; bytCounter++)
bytRetVal[bytCounter] = pgm_read_word_near(8 * intIndex + bytCounter);
return bytRetVal;
}
void charInit()
{
for (int intCharCounter = 0; intCharCounter < defSpecChar_NumChars; intCharCounter++)
{
byte *bytSpecialCharacter = chrDatRunner(intCharCounter);
lcd.createChar(intCharCounter, bytSpecialCharacter);
}
}
I'm not sure whether its a pointer issue or a memory addressing issue but I've tried variations of the latter and still get a set of funky characters on the screen for both the player character (7 or 8 of these special characters) and the Wall. so, I don't know what I'm doing wrong.