I got my Nokia 5110 screen up and running and I have made a count-down timer for the game Alias. The program has a menu where you can change parametes and a main screen which consists of a big custom font that shows the remaining time.
The problem is that I can´t figure out how to change the big font.
Each big font is stored in a two dimensional array, for example:
static const byte fontti1[][48] =
{
{0xC0, 0xF0, 0xFC, 0x3E, 0x0E, 0x07, 0x03, 0x03, 0x03, 0x07, 0x0E, 0x3E, 0xFC, 0xF0, 0xC0,0x00, //nolla
0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,0x00,
0x01, 0x07, 0x1F, 0x3E, 0x38, 0x70, 0x60, 0x60, 0x60, 0x70, 0x38, 0x3E, 0x1F, 0x07, 0x01,0x00
},
{0x00, ..... and so on
My function for plotting the character works really well as long as I only use one font. When I want to be able to change the font (meaning using a different 2 dimensional, same size array) the whole program crashes from the beginning and I get only gibberish on the screen. This happends allso in the menu where only the basic 5x8 ASCII characters are used. Why is this happening??
The function that draws a big number on the screen is below. It is the perfectly working version, but it can only use "fontti2"
// this function goes to the demanded XY position and draws a big character from a 2 dimensional array
int i = 0;
byte j = 16; // määrittää kuinka monta hexaa käsitellään /rivi
for(byte k = 1; k < 4;k++) //kirjottaa joka riville oikeen tiedon
{
gotoXY(paikka, k);
for(i; i < j; i++)
{
Lahetys(DCd, fontti2[character][i]); //this function send a byte of data to the screen
}
j = j+16;
}
If I add the following code anywhere in the program, the whole Arduino just goes wild! It either will draw something random or just leave a blank screen no matter which buttons I push (one is an interrupt which goes to the menu).
// fonttiNum tells which font to use, fonttiBuffer = byte fonttiBuffer[11][48], character = a number between 0-10 to tell which character wants to be copied.
if(fonttiNum == 1){memcpy(fonttiBuffer, fontti1[character], sizeof(byte)*50);}
if(fonttiNum == 2){memcpy(fonttiBuffer, fontti2[character], sizeof(byte)*50);}
Then again, the memcpy(...) WORKS, IF I remove the fonttinum == 2 statement.
This happens no matter how I put my code. I have tried doing the font change in the main menu directly after changing "fonttiNum" and in the function which draws the big character on the screen. The result is still the same.
I tried allso to do the copying manually by saying, in a for sentence : fonttiBuffer[k][j] = fontti1[k][j]. The same error happends.
Please help me with the problem! I have no idea what I could do.