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* "
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* "
Thanks Pommie, it works now.
I've forgotten to declare the ascii variable as a table instead of a character.
By the way, i've tried to modify PutString function in order to display the result with smaller or larger fonts : i've just replaced PutChar by PutSmallChar or PutHChar but i get outstanding display.
Can you tell me why PutString is not compatible with other fonts ?
Is it easy to add new fonts to the GLCD driver, i need a small characters font and another one with large ones.
Code:
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();
}
}
New fonts should work fine but remember, they are stored different to most fonts. The first character is the left hand column with the LSB at the top of the column. They're also stored inverted.
Mike.... I know that.. but it was a question of trying to print a string literal..... if the string is a constant.... it's not so easy to cast as a variable.... All I was saying was convert the string first with sprintf();
This is exactly what you are doing in post #343..... Manually!!
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 ?
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.
I was hoping to finish off the documentation this weekend and post some example code.
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.
It would not take long to port this to the KS0108 controller. However I have not done this yet (as it says above). You cannot just copy and paste the fonts from my code to Pommie's and expect it to work.
thanks pommie for your code. everything is going good (Logo, Lines, Box) but when I try to write text it dosen't come on right location. Like simply if i try:-
SetPos(0,2);
PutMessage((rom char*)"Hello");
it would display "Hello" but at (0,0). If I set (10,5) it comes on(10,0) If I try (10,9) it comes on (10,8), it's only taking multiple of 8 steps in vertical coordinates. I haven't changed anything still can't understand why this is happening. I have tried this also:- PutMessage((rom char*)"\x16\x10\x05 Hello");
Note that rewriting the code to work like this makes it much slower and much less efficient, this can't really be avoided. Pommie's code is the best way to draw text if you want speed and smaller code size.
I use your GLCD driver and i need a very small font.
I've tried to import a Truetype font but the result is not good ! (missing pixels, some characters are getting shifted )
I've tried many GLCD font generator without success, maybe some of them are not compliant with your code ?
Is there a method to get a Truetype font working with your GLCD driver ?
If not, did you create one by chance and you will be willing to share it here ?
You could use a smaller font but it would probably have to be drawn by hand. You would also need to rewrite the putchar routine to work on pixel boundaries.
I have got a font that is 5 by 3 pixels that was used on another project. See attachment.