Try the inbuilt function "sprintf()" I know it takes up room but allows you to take a constant and place it in a stream (buffer) for easy manipulation... C18 isn't all that good when casting " rom char* " or even just " const char* "
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Try the inbuilt function "sprintf()" I know it takes up room but allows you to take a constant and place it in a stream (buffer) for easy manipulation... C18 isn't all that good when casting " rom char* " or even just " const char* "
unsigned char Buffer[10];
TestInt=12345;
itoa(TestInt,&Buffer[0]);
i=0;
while(Buffer[i])
PutChar(Buffer[i++]);
void PutSmallChar(unsigned char data){
unsigned char i,d;
if(data<32){
switch(data){
case 13:
XPos=0;
case 10:
XPos=0;
YPos+=8;
YPos=YPos&63;
}
WritePosition();
}
else{
for(i=0;i<7;i++){
d=FontSmall[data-48][i];
if(d!=0x55){
//d=~d; // Black on white
GLCD_Write_Data(d);
MoveRight();
}
}
GLCD_Write_Data(0x00); // Black on white
//GLCD_Write_Data(0xff); // White on black
MoveRight();
}
}
void PutHChar(unsigned char data){
unsigned char i,d;
if(data<32){
switch(data){
case 13:
XPos=0;
case 10:
XPos=0;
YPos+=8;
YPos=YPos&63;
}
WritePosition();
}
else{
for(i=0;i<8;i++){
d=Font18[data-46][i];
if(d!=0x55){
GLCD_Write_Data(d);
MoveRight();
}
}
MoveDown ();
for(i=8;i<16;i++){
d=Font18[data-46][i];
if(d!=0x55){
GLCD_Write_Data(d);
MoveRight();
}
}
GLCD_Write_Data(0x00); //Black on white
MoveRightH();
}
}
GLCD_Write_Data (0xf1);
GLCD_Write_Data (0xf5);
GLCD_Write_Data (0xf1);
111 LSB
000
010
000
111
111
111
111 MSB
^-----0xf1
-^----0xf5
--^---0xf1
Pommie,
I do not understand well how PutSmallChar and PutHChar works depending of the font size.
Would you please comment the functions for me, it would help me a lot.
If a convert a windows true type font with a software, then what should adapt in Putchar function in order to use that font with the GLCD ?
Do you have other fonts + functions ready to go, if so could you post them here ?
Please note that the example picture is running on a different screen. I haven't ported it to Pommie's GLCD code yet but all it needs is a compliant glcd_pixel function, so that would take a few minutes at most.
Thanks edeca, but are these fonts compatible with Pommie's GLCD driver ?
In your fonts, the definition of each character looks very different as the font included in the Pommie's library.
Yes, it only puts characters on byte boundaries. It could be rewritten to make it cross byte boundaries but that is quite difficult.
void PutChar(unsigned char data){
unsigned char i,d;
if(data<32){
switch(data){
case 13:
XPos=0;
case 10:
XPos=0;
YPos+=4;
YPos=YPos&63;
}
WritePosition();
}
else{
for(i=0;i<7;i++){ //7
d=Font_3[data-32][i];
if(d!=0x55){
d=~d; // ADD pour Noir sur Blanc
GLCD_Write_Data(d);
MoveRight();
}
}
GLCD_Write_Data(0x00); // Noir sur Blanc
//GLCD_Write_Data(0xff); // Blanc sur Noir
MoveRight();
}
}