Ahoj kamarádi.
Už třetí den bojuju s fontem u tohoto displeje.
Displej funguje, ale chtěl bych mít druhý font, velké čísla, ale nedaří se.
Problém bych viděl u funkcí, které jsem se snažil přidat. Jde o tyto:
void LCD_writeChar_megaFont ( unsigned char character );
void LCD_writeString_megaFont ( unsigned char *string );
Font s velkýma číslama mám zde:
//******* VERY LARGE FONTS **********
//used here for displaying temperature
static const unsigned char number[13][3][16] PROGMEM = {
{{0,128,192,224,224,96,224,224, //'0'
192,128,0,0,0,0,0,0}
,
{112,255,255,1,0,0,0,0,
255,255,254,0,0,0,0,0}
,
{0,15,31,60,56,48,56,56,
31,15,3,0,0,0,0,0}
},
{
{0,0,0,0,128,224,224,0, //'1'
0,0,0,0,0,0,0,0}
,
{0,0,3,3,3,255,255,0,
0,0,0,0,0,0,0,0}
,
{0,0,56,56,56,63,63,56,
56,56,0,0,0,0,0,0}
},
{
{0,192,192,224,96,96,224,224, //'2'
192,128,0,0,0,0,0,0}
,
{0,1,0,0,128,192,224,249,
63,31,0,0,0,0,0,0}
,
{0,60,62,63,63,59,57,56,
56,56,56,0,0,0,0,0}
},
{
{0,192,224,224,96,96,224,224, //'3'
192,192,0,0,0,0,0,0}
,
{0,1,0,0,48,48,56,125,
239,207,0,0,0,0,0,0}
,
{0,28,56,56,48,48,56,60,
31,15,1,0,0,0,0,0}
},
{
{0,0,0,0,0,128,192,224, //'4'
224,0,0,0,0,0,0,0}
,
{224,240,248,222,207,199,193,255,
255,192,192,0,0,0,0,0}
,
{0,0,0,0,0,0,0,63,
63,0,0,0,0,0,0,0}
},
{
{0,224,224,224,224,224,224,224, //'5'
224,224,224,0,0,0,0,0}
,
{0,63,63,63,56,56,48,112,
240,224,0,0,0,0,0,0}
,
{0,28,56,56,48,48,56,60,
31,15,1,0,0,0,0,0}
},
{
{0,0,128,192,192,224,96,96, //'6'
224,224,0,0,0,0,0,0}
,
{224,254,255,55,57,24,24,56,
240,240,192,0,0,0,0,0}
,
{0,15,31,28,56,48,48,56,
31,15,7,0,0,0,0,0}
},
{
{0,224,224,224,224,224,224,224, //'7'
224,224,224,0,0,0,0,0}
,
{0,0,0,0,128,224,248,126,
31,7,1,0,0,0,0,0}
,
{0,0,56,62,31,7,1,0,
0,0,0,0,0,0,0,0}
},
{
{0,128,192,224,224,96,96,224, //'8'
192,192,0,0,0,0,0,0}
,
{0,207,255,127,56,48,112,112,
255,239,199,0,0,0,0,0}
,
{3,15,31,60,56,48,48,56,
31,31,15,0,0,0,0,0}
},
{
{0,128,192,224,224,96,224,224, //'9'
192,128,0,0,0,0,0,0}
,
{12,63,127,241,224,192,192,225,
255,255,254,0,0,0,0,0}
,
{0,0,56,48,48,56,56,30,
15,7,0,0,0,0,0,0}
},
{
{0,0,0,0,0,0,0,0, //'.'
0,0,0,0,0,0,0,0}
,
{0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0}
,
{60,60,60,0,0,0,0,0,
0,0,0,0,0,0,0,0}
},
{
{0,0,0,0,0,0,0,0, //'+'
0,0,0,0,0,0,0,0}
,
{0,0,64,64,64,64,64,254,
254,64,64,64,64,64,0,0}
,
{0,0,0,0,0,0,0,15,
15,0,0,0,0,0,0,0}
},
{
{0,0,0,0,0,0,0,0, //'-'
0,0,0,0,0,0,0,0}
,
{0,64,64,64,64,64,64,0,
0,0,0,0,0,0,0,0}
,
{0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0}
}};
Dvě zmíněné funkce jsou zde. Upravil jsem je pro knihovnu, kterou používám.
/*--------------------------------------------------------------------------------------------------
Name : LCD_writeChar_megaFont
Description : Displays a character at current cursor location and increment cursor location.
Argument(s) : ch -> Character to write.
Return value : None.
--------------------------------------------------------------------------------------------------*/
unsigned char char_start;
void LCD_writeChar_megaFont (unsigned char ch)
{
unsigned char i, j;
if(ch == '.')
ch = 10;
else if (ch == '+')
ch = 11;
else if (ch == '-')
ch = 12;
else
ch = ch & 0x0f;
for(i=0;i<3;i++)
{
LcdGotoXYFont (4 + char_start, i+2);
for(j=0; j<16; j++)
LcdSend( number[ch][i][j],LCD_DATA);
}
if(ch == '.')
char_start += 5;
else
char_start += 12;
}
/*--------------------------------------------------------------------------------------------------
Name : LCD_writeString_megaFont
Description : Displays a character at current cursor location
Argument(s) : string -> Pointer to ASCII string (stored in RAM)
Return value : None.
--------------------------------------------------------------------------------------------------*/
void LCD_writeString_megaFont ( unsigned char *string )
{
char_start = 0;
while ( *string )
LCD_writeChar_megaFont( *string++ );
LcdGotoXYFont(char_start+6, 3);
}
A jednotlivé funkce, které jsou funkční a ověřené, že fungují a jsou použity ve funkcích výše jsou zde:
byte LcdGotoXYFont ( byte x, byte y )
{
/* Boundary check, slow down the speed but will guarantee this code wont fail */
/* Version 0.2.5 - Fixed on Dec 25, 2008 (XMAS) */
if( x > 14)
return OUT_OF_BORDER;
if( y > 6)
return OUT_OF_BORDER;
/* Calculate index. It is defined as address within 504 bytes memory */
LcdCacheIdx = ( x - 1 ) * 6 + ( y - 1 ) * 84;
return OK;
}
static void LcdSend ( byte data, LcdCmdData cd )
{
/* Enable display controller (active low). */
LCD_PORT &= ~( _BV( LCD_CE_PIN ) );
if ( cd == LCD_DATA )
{
LCD_PORT |= _BV( LCD_DC_PIN );
}
else
{
LCD_PORT &= ~( _BV( LCD_DC_PIN ) );
}
/* Send data to display controller. */
SPDR = data;
/* Wait until Tx register empty. */
while ( (SPSR & 0x80) != 0x80 );
/* Disable display controller. */
LCD_PORT |= _BV( LCD_CE_PIN );
}
A když už toto mám v, tak v kódu to volám takto:
LcdGotoXYFont(3,3);
LCD_writeString_megaFont ( tempDisplay );
LcdUpdate();
A tempDisplay je deklrovaná takto:
unsigned char* tempDisplay = 5;
Jestli se najde dobrá duše a poradí, kde dělám chybu, budu určitě rád.