hi guys, so I'm still a noob to C++ and having trouble with some basics. have a rough idea about some pointers but still havent fully grasped the idea yet.
I have a nokia 6100 LCD and Arduino, it works great, but what I want to do is alter the default font table and instead of it being a 8x16 font I want a 16x32 font. modifying the font table is easy enough. would be helpfull if anyone can tell me a good font to binary converter though so I dont have to do it manually.
the part I'm having trouble with, is understanding where in the following code it is defined/limited to 8x16.
I assume it may also have something to do with the following
97 is pretty close to the length of the font table (I didnt count, that's an assumption), and I'm assuming 16 is the number of bytes per character. the hex values in the code above are for the character "$". I thought it best to leave out the rest of the font table and just have one as an example
I've spent hours looking up code sites for any clues/hints that help me understand this better, and it has helped a bit. but pointers are still a bit confusing. mainly * and it's used allot in this.
I have a nokia 6100 LCD and Arduino, it works great, but what I want to do is alter the default font table and instead of it being a 8x16 font I want a 16x32 font. modifying the font table is easy enough. would be helpfull if anyone can tell me a good font to binary converter though so I dont have to do it manually.
the part I'm having trouble with, is understanding where in the following code it is defined/limited to 8x16.
Rich (BB code):
void setChar(char c, int x, int y, int fColor, int bColor)
{
//y = (COL_HEIGHT - 1) - y; // make display "right" side up
//x = (ROW_LENGTH - 2) - x;
int i,j; //integer up to -32K -> +32Kish
unsigned int nCols; //unsigned 0 -> 65Kish
unsigned int nRows;
unsigned int nBytes;
unsigned char PixelRow;
unsigned char Mask;
unsigned int Word0;
unsigned int Word1;
unsigned char *pFont;
unsigned char *pChar;
// get pointer to the beginning of the selected font table
pFont = (unsigned char *)FONT8x16;
// get the nColumns, nRows and nBytes
nCols = *pFont;
nRows = *(pFont + 1);
nBytes = *(pFont + 2);
// get pointer to the last byte of the desired character
pChar = pFont + (nBytes * (c - 0x1F)) + nBytes - 1;
// Row address set (command 0x2B)
LCDCommand(PASETP);
LCDData(x);
LCDData(x + nRows - 1);
// Column address set (command 0x2A)
LCDCommand(CASETP);
LCDData(y);
LCDData(y + nCols - 1);
// WRITE MEMORY
LCDCommand(P_RAMWR);
// 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++;
// loop on each pixel in the row (left to right)
// Note: we do two pixels each loop
Mask = 0x80;
for (j = 0; j < nCols; j += 2)
{
// if pixel bit set, use foreground color; else use the background color
// now get the pixel color for two successive pixels
if ((PixelRow & Mask) == 0)
Word0 = bColor;
else
Word0 = fColor;
Mask = Mask >> 1;
if ((PixelRow & Mask) == 0)
Word1 = bColor;
else
Word1 = fColor;
Mask = Mask >> 1;
// use this information to output three data bytes
LCDData((Word0 >> 4) & 0xFF);
LCDData(((Word0 & 0xF) << 4) | ((Word1 >> 8) & 0xF));
LCDData(Word1 & 0xFF);
}
}
}
Rich (BB code):
const unsigned char FONT8x16[97][16] = {
0x0C,0x0C,0x3E,0x63,0x61,0x60,0x3E,0x03,0x03,0x43,0x63,0x3E,0x0C,0x0C,0x00,0x00,
}
I've spent hours looking up code sites for any clues/hints that help me understand this better, and it has helped a bit. but pointers are still a bit confusing. mainly * and it's used allot in this.