19264 GLC FONT HELP
19264 GLC FONT HELP
I have a PIC18F46K22 displaying on a 192x64 GLCD. I have code to initiate it, write bitmaps and lines etc.
I need help to get started reading the font tables that MIKROC for PIC has under Uses\P18. I need to read the font then display it like GLCD_Write_Text does etc.
Can anyone direct me to a tutorial on how to do that?
I need help to get started reading the font tables that MIKROC for PIC has under Uses\P18. I need to read the font then display it like GLCD_Write_Text does etc.
Can anyone direct me to a tutorial on how to do that?
- filip.grujcic
- Posts: 822
- Joined: 14 May 2018 08:34
Re: 19264 GLC FONT HELP
Hello,
There is an example for this on the path:
C:\Users\Public\Documents\Mikroelektronika\mikroPascal PRO for PIC\Examples\Development Systems\EASYPIC7\Glcd
Is this what you are looking for?
Regards,
There is an example for this on the path:
C:\Users\Public\Documents\Mikroelektronika\mikroPascal PRO for PIC\Examples\Development Systems\EASYPIC7\Glcd
Is this what you are looking for?
Regards,
Filip Grujcic
Re: 19264 GLC FONT HELP
First I apologize, I should have picked mikroC for PIC forum but it has the same information you pointed out.
That information is for using the GLCD Library, because I am using a 192x64 GLCD it does not apply.
I have to write my own routines to access a font table and display it on the GLCD. It has 3 chip selects.
I have a routine for displaying a bitmap but not one to access the font tables that the GLCD Library uses for 128x64 GLCD. It has 2 chip selects.
I am not experienced in that so I need help to get me started.
That information is for using the GLCD Library, because I am using a 192x64 GLCD it does not apply.
I have to write my own routines to access a font table and display it on the GLCD. It has 3 chip selects.
I have a routine for displaying a bitmap but not one to access the font tables that the GLCD Library uses for 128x64 GLCD. It has 2 chip selects.
I am not experienced in that so I need help to get me started.
Re: 19264 GLC FONT HELP
There are two types of fonts in __Lib_GlcdFonts.c - simple fonts fitting in 8-pixel 'page' that are used by Glcd_Write_Text and advanced font used by Glcd_Write_Text_Adv function.
The former are simply bitmaps of characters - for example, in FontSystem5x7 there will be 5 bytes for every character, every byte an 8-pixel column on GLCD. In Font_Glcd_System3x5 there will be 3 bytes for every character, and in Font_Glcd_Character8x7, 8 bytes for every character.
The latter type of fonts, represented by only one font in __Lib_GlcdFonts.c, namely the Glcd_defaultFont, follows Microchip Graphic Library fonts format (see here). Naturally, one may create any font of this type with help of the GLCD Font Creator from mE - using the option 'Export for TFT and New GLCD (new library)'.
The default option ' Export for GLCD' creates simple bitmap fonts, the bitmaps being as large as necessary to cover larger fonts - a real waste of code space but useful source for generating own font files, like I do to prepare fonts for my uGLCD library.
Re: 19264 GLC FONT HELP
I am looking to use the uGLCD from replacement Libraries but I can't find the package manager to start the installation. Can you help me with that.
I have downloaded the .mpkg files etc.
I have downloaded the .mpkg files etc.
Re: 19264 GLC FONT HELP
I found the package manager under tools but it is greyed out, not available.
Re: 19264 GLC FONT HELP
Hi,
If you downloaded the uGLCD library from my mP tips website, not Libstock, then please download it again - I've apparently forgotten to upload newest version for mC there. As for the Package Manager, latest version is available on mE's website (link).
BTW, the uGLCD library contains driver for displays with 3 KS107 controllers.
If you downloaded the uGLCD library from my mP tips website, not Libstock, then please download it again - I've apparently forgotten to upload newest version for mC there. As for the Package Manager, latest version is available on mE's website (link).
BTW, the uGLCD library contains driver for displays with 3 KS107 controllers.
Re: 19264 GLC FONT HELP
I downloaded the uGLCD and program manager and got all installed.
I assumed that the KS107_3 is for the 3 chip selects.
I ran a test using:
But it displays "Hello" twice looks like 64 bits apart starting at 64.
Any idea?
I assumed that the KS107_3 is for the 3 chip selects.
I ran a test using:
Code: Select all
uGLCD_Set_Font(&Arial14x16);
strcpy(someText,"Hello");
uGLCD_Write_Text(someText,0,0,uGLCD_tsWrite);
Any idea?
Re: 19264 GLC FONT HELP
Apparently data is written to two segments at the same time. Please check whether the uGLCD_CSx pins are correctly declared in your code and how the display you use defines active CSx signal. If necessary, you can adjust the 'driver' part of the library (uGLCD_KS107_3.c) to your display as the source code is included in the package. The uGLCD_Set_Side routine is responsible for choosing the chip select pins and it assumes active-low logic of CSx pins
Obviously, if the logic is reversed, two segments will be addressed at the same time. Strange effects may also result in declaring the CSx pins as POTRx.Bx instead of LATx.Bx. There are also displays with just two CS pins addressing 3 segments but that doesn't seem to be the case here.
Code: Select all
void static uGLCD_Set_Side(unsigned short s) {
#ifdef RAMdraw
if (uGLCD_RAMdraw) return;
#endif
if (s.B7) { // x >= 128 ?
uGLCD_CS1 = 1;
uGLCD_CS2 = 1;
uGLCD_CS3 = 0;
last_s = 128;
}
else {
if (s.B6) { // ...no, x >= 64 ?
uGLCD_CS1 = 1;
uGLCD_CS2 = 0;
uGLCD_CS3 = 1;
last_s = 64;
}
else { // ...no, x < 64
uGLCD_CS1 = 0;
uGLCD_CS2 = 1;
uGLCD_CS3 = 1;
last_s = 0;
}
}
}
Re: 19264 GLC FONT HELP
I believe I have the GLCD called correctly, here is my code:
My GLCD is active high so that may be the problem. Do I use the code you attached by reversing the chip select values, if so where do I put the code in my program?
Code: Select all
// Glcd module connections
sfr unsigned short volatile uGLCD_dataPORT at PORTD; // data port assignments
sfr unsigned short uGLCD_dataTRIS at TRISD;
sfr unsigned short uGLCD_ctrLAT at LATB; // control lines port declarations (not
sfr unsigned short uGLCD_ctrTRIS at TRISB; // directly used by uGLCD lib)
// GLCD control lines (pin numbers)
#define uGD_RS B7
#define uGD_RW B6
#define uGD_EN B5
#define uGD_CS1 B4
#define uGD_CS2 B3
#define uGD_CS3 B2
#define uGD_RST B1
sbit uGLCD_CS1 at uGLCD_ctrLAT.uGD_CS1; // control lines assignments
sbit uGLCD_CS2 at uGLCD_ctrLAT.uGD_CS2;
sbit uGLCD_CS3 at uGLCD_ctrLAT.uGD_CS3;
sbit uGLCD_RS at uGLCD_ctrLAT.uGD_RS;
sbit uGLCD_RW at uGLCD_ctrLAT.uGD_RW;
sbit uGLCD_EN at uGLCD_ctrLAT.uGD_EN;
sbit uGLCD_RST at uGLCD_ctrLAT.uGD_RST;
sbit uGLCD_CS1_Dir at uGLCD_ctrTRIS.uGD_CS1;
sbit uGLCD_CS2_Dir at uGLCD_ctrTRIS.uGD_CS2;
sbit uGLCD_CS3_Dir at uGLCD_ctrTRIS.uGD_CS3;
sbit uGLCD_RS_Dir at uGLCD_ctrTRIS.uGD_RS;
sbit uGLCD_RW_Dir at uGLCD_ctrTRIS.uGD_RW;
sbit uGLCD_EN_Dir at uGLCD_ctrTRIS.uGD_EN;
sbit uGLCD_RST_Dir at uGLCD_ctrTRIS.uGD_RST;
// End Glcd module connections
Re: 19264 GLC FONT HELP
Yes, the pin declarations seem correct. If your GLCD has active-high chip select lines then you need to introduce changes to the 'driver' part of the library (uGLCD_KS107_3.c). It's located in compiler directory inside Packages\uGLCDlib\Uses sub-directory.
Changes should be made to all functions using the uGLCD_CSx sbits, namely uGLCD_Init, uGLCD_On, uGLCD_Off, and finally uGLCD_Set_Side. Simply exchange 0 for 1 and 1 for 0 in assignments to uGLCD_CS1, uGLCD_CS2, and uGLCD_CS3, like I did below in uGLCD_Set_Side functionso that only one segment (or none) is active at a time. Then save the driver and use Rebuild All Sources to compile your project.
Changes should be made to all functions using the uGLCD_CSx sbits, namely uGLCD_Init, uGLCD_On, uGLCD_Off, and finally uGLCD_Set_Side. Simply exchange 0 for 1 and 1 for 0 in assignments to uGLCD_CS1, uGLCD_CS2, and uGLCD_CS3, like I did below in uGLCD_Set_Side function
Code: Select all
void static uGLCD_Set_Side(unsigned short s) {
#ifdef RAMdraw
if (uGLCD_RAMdraw) return;
#endif
if (s.B7) { // x >= 128 ?
uGLCD_CS1 = 0;
uGLCD_CS2 = 0;
uGLCD_CS3 = 1;
last_s = 128;
}
else {
if (s.B6) { // ...no, x >= 64 ?
uGLCD_CS1 = 0;
uGLCD_CS2 = 1;
uGLCD_CS3 = 0;
last_s = 64;
}
else { // ...no, x < 64
uGLCD_CS1 = 1;
uGLCD_CS2 = 0;
uGLCD_CS3 = 0;
last_s = 0;
}
}
}
Re: 19264 GLC FONT HELP
Thanks for your help, that worked as it should.
Now I am off to figure out the fonts. I am looking to use first the mE's GLCD library "const unsigned short Character8x7[]" that fits my needs right now.
My understanding is I will have to modify it to use it. I will view the help file for info.
Now I am off to figure out the fonts. I am looking to use first the mE's GLCD library "const unsigned short Character8x7[]" that fits my needs right now.
My understanding is I will have to modify it to use it. I will view the help file for info.
Re: 19264 GLC FONT HELP
The standard chars of Character8x7 (chars with ASCII code from 32 to 128 plus degree char) are contained in font Bold7x8 included in uGLCD library. If you need other chars present in font Character8x7 then you indeed need to modify it to work with uGLCD but the modification is simple. A short header is added to every fixed-width font:
Best open the font file uGlcdFonts.c that comes with the library to see how it's done for the fonts contained there.
Code: Select all
Font header structure:
byte 0 - 0x81 - fixed font, y-scan
byte 1 - No of chars in font table
byte 2 - width of char
byte 3 - height of char
Re: 19264 GLC FONT HELP
I tried this:
Instead of seeing Hello on the screen it showed Hfmmp, why?
If the font wasn't set correctly I would have thought I would get garbage on the GLCD.
Code: Select all
uGLCD_Set_Font(Bold7x8);
strcpy(someText,"Hello");
uGLCD_Write_Text(someText,0,0,uGLCD_tsWrite);
If the font wasn't set correctly I would have thought I would get garbage on the GLCD.
Re: 19264 GLC FONT HELP
Looks like the font is missing one character between 'H' and 'e' so the lower case letters in 'Hello' are offset by one char. But I just checked this font and don't see any missing chars. Could you check the font file you use?