|
|
View previous topic :: View next topic |
Author |
Message |
vortexe90
Joined: 26 Feb 2013 Posts: 30 Location: Algeria
|
"GLCD Font Creator" code is correct ??? |
Posted: Fri Nov 08, 2013 4:49 am |
|
|
hi guys, I used this routine to display fonts with high resolution. All the variables are 16-bit. I encode the numbers and special characters in the table "font11" from 32 to 64 ascii order. But still nothing is displayed in the GLCD by glcd_text57 against the routine works well.
Please help me
here are the codes,
the data of characters :
Code: |
//GLCD FontName : Times_New_Roman10x13
//GLCD FontSize : 10 x 13
const unsigned short font11[] = {
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x03, 0x00, 0x00, 0x1E, 0x03, 0x7E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char !
0x06, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char "
0x06, 0x90, 0x03, 0xF8, 0x00, 0x96, 0x00, 0x90, 0x03, 0xF8, 0x00, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char #
0x05, 0x9C, 0x01, 0x32, 0x02, 0xFF, 0x07, 0x62, 0x02, 0xCC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char $
0x0A, 0x00, 0x00, 0x3C, 0x00, 0x42, 0x02, 0x3C, 0x01, 0xC0, 0x00, 0x20, 0x00, 0x18, 0x00, 0xE4, 0x01, 0x12, 0x02, 0xE0, 0x01, // Code for char %
0x09, 0xC0, 0x01, 0xE0, 0x03, 0x1C, 0x03, 0x7E, 0x02, 0xE2, 0x02, 0x92, 0x01, 0xAC, 0x03, 0x60, 0x02, 0x20, 0x01, 0x00, 0x00, // Code for char &
0x03, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char '
0x04, 0xF0, 0x01, 0xF8, 0x03, 0x0C, 0x06, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char (
0x04, 0x02, 0x08, 0x04, 0x06, 0xF8, 0x03, 0xF0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char )
0x06, 0x00, 0x00, 0x08, 0x00, 0x28, 0x00, 0x1E, 0x00, 0x28, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char *
0x07, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0xFC, 0x01, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char +
0x02, 0x00, 0x0B, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ,
0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char -
0x02, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
0x03, 0x00, 0x03, 0xF8, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char /
0x05, 0xFC, 0x01, 0xFE, 0x03, 0x02, 0x02, 0xFE, 0x03, 0xFC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 0
0x05, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x03, 0xFE, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 1
0x05, 0x08, 0x02, 0x86, 0x03, 0x46, 0x03, 0x3E, 0x03, 0x1C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 2
0x05, 0x04, 0x01, 0x02, 0x02, 0x32, 0x02, 0xFE, 0x03, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 3
0x06, 0xC0, 0x00, 0xB0, 0x00, 0x88, 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 4
0x05, 0x38, 0x03, 0x36, 0x03, 0x36, 0x02, 0x76, 0x01, 0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 5
0x05, 0xF0, 0x01, 0xFC, 0x03, 0x14, 0x02, 0xF6, 0x03, 0xE2, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 6
0x05, 0x06, 0x00, 0x06, 0x00, 0x86, 0x03, 0x7E, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 7
0x05, 0xDC, 0x01, 0xFE, 0x03, 0x22, 0x02, 0xFE, 0x03, 0xDC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 8
0x05, 0x3C, 0x02, 0x7E, 0x03, 0x42, 0x01, 0xFE, 0x01, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 9
0x03, 0x00, 0x00, 0x30, 0x03, 0x30, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char :
0x03, 0x00, 0x00, 0x30, 0x0B, 0x30, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ;
0x06, 0x40, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0x10, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char <
0x06, 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char =
0x06, 0x10, 0x01, 0x10, 0x01, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char >
0x06, 0x00, 0x00, 0x0C, 0x00, 0x0E, 0x03, 0x62, 0x03, 0x3E, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ?
0x0A, 0xF0, 0x03, 0x08, 0x04, 0xC4, 0x09, 0xE2, 0x13, 0x32, 0x12, 0x12, 0x11, 0x92, 0x11, 0xE2, 0x13, 0x34, 0x09, 0xF8, 0x04 // Code for char @
};
|
The routine high resolution text:
Code: | /////////////////////////////////////////////////////////////////////////////
////// Purpose: Write text on a graphic LCD
////// Inputs: (x_origin,y_origin) - The upper left coordinate of the first letter
////// textptr - A pointer to an array of text to display
////// fgcolor - 16 bit colour of text
////// bgcolor - 16 bit colour of background
/////////////////////////////////////////////////////////////////////////////
void glcd_text(unsigned int16 x_origin, unsigned int16 y_origin, char* textptr, unsigned int16 fgcolour, unsigned int16 bgcolour)
{
unsigned int16 info_offset;
int chr_width;
int chr_bytes;
unsigned int16 chr_hight;
unsigned int16 chr_offset;
int i,j,k;
unsigned int16 x,y;
chr_hight = font11[6]; //the hight is always stored in the 6th bit
while(*textptr != '\0')
{
if(*textptr == ' ') //found a space, we will just insert a few lines
{
x_origin = x_origin + 5; //move to the next chr position
}
else
{
info_offset = (((unsigned int16)*textptr - 33) * 4) + 8; //work out how far into the font array is the info about the current chr skipping the fist 8 byts in the table
chr_width = font11[info_offset]; //the first byte contanes the width information, this is only how wide the chr is without padding
chr_offset = make16(font11[info_offset+2], font11[info_offset+1]); //The next two bytes contane the offset in the table to the bitmap of the chr
chr_bytes = chr_width / 8; //work our how many bytes wide the char is
if (chr_width % 8)
{
chr_bytes++;
}
x = x_origin; //save the start x position
y = y_origin; //save the start y position
for(i=0;i<chr_hight;i++) //loop thought vertical bytes
{
for(j=0;j<chr_bytes;j++) //loop thought horizontal bytes
{
for(k=0;k<8;k++) //loop though each bit
{
if(bit_test(font11[chr_offset],k))
{
glcd_pixel(x,y,1); //bit is set, make the pixel the text colour
}
else
{
glcd_pixel(x,y,1); //bit is not set, make it the background colour
}
x++; //move to the next vertical line
}
chr_offset++; //move to the next byte
}
x = x_origin; //move the x origin to start drawing the next horizontal bytes
y++; //move down to the next row
}
x_origin = x_origin + chr_width + 1; //move to the next chr position
}
textptr++; //move to next char in string
}
}
|
the glcd_pixel :
Code: | // glcd_pixel(x,y,c) sets pixel x,y with c color
void glcd_pixel(unsigned int8 x, unsigned int8 y, int1 c){
unsigned int8 x_H;
unsigned int8 x_L=0;
x_H = (x / 8);
x_L = 7 - (x - 8*x_H);
glcd_gotoxy(x_H+1,y,0);
if(c){
glcd_WriteCmd1(1,(LCDBitSet|x_L));
} else {
glcd_WriteCmd1(1,(LCDBitReset|x_L));
}
} |
main prog :
Code: | #include <16F877A.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT //No Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#use delay(clock=20000000)
#include "T6963KELLAL.c"
CHAR PP[]="@951";
void main() {
setup_adc(ADC_OFF); // ADC Off
setup_adc_ports(NO_ANALOGS);
set_tris_c(0x00); // graphic lcd control lines all output
glcd_init(); //Initialization
glcd_WriteByte(1, (LCDModeSet|LCDMode_XOR)); //XOR-Mode
glcd_WriteByte(1, (LCDDispMode|LCDDisp_TXT|LCDDisp_GRH)); //Text and Graphic-Mode
delay_ms(200);
While (1)
{
glcd_text(2, 30, PP, 0xFFFF, 0x0000);
delay_ms(1000);
}
} |
|
|
|
vortexe90
Joined: 26 Feb 2013 Posts: 30 Location: Algeria
|
please a help |
Posted: Fri Nov 08, 2013 8:45 am |
|
|
please a help . |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19509
|
|
Posted: Fri Nov 08, 2013 8:46 am |
|
|
Code: |
info_offset = (((unsigned int16)*textptr - 33) * 4) + 8; //work out how far into the font array is the info about the current chr skipping the fist 8 byts in the table
|
Each row is 21 bytes long. There is also no 8 byte offset. There is a 21byte offset since you start at the '!'.
Code: |
info_offset = (((int16)(*textptr))-' ')*21;
|
character value, less the value for 'space', times the number of characters per row.
So for '!' will give 1*21 = 21, and access the 3 at the start of the second row.. For '"' will give 2*21, and access the 6 at the start of the third row etc..
The maths here has to be adjusted to match the character size you are using.
chr_offset is then also wrong. It has the same offset for the first three characters, and then seems to jump around the table all over the place. You need to study what is going on here, or simply remove these and just use the character as starting in the byte after the width.
Then as a comment, for each byte, read it once, and use s mask for the bit, or rotate it. Accessing the bit with 'bit test', is very inefficient (perhaps a dozen instructions), and each array access also involves a lot of work. I'd suspect you could probably triple the write speed with a couple of minor changes here....
Best Wishes |
|
|
vortexe90
Joined: 26 Feb 2013 Posts: 30 Location: Algeria
|
|
Posted: Fri Nov 08, 2013 9:04 am |
|
|
thanks Mr Ttelmah i will do it but also nothing in GLCD i believe that the problem is in the variable of glcd_pixel it must be 16-bit I think so!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19509
|
|
Posted: Sat Nov 09, 2013 2:12 am |
|
|
No, the variable does not have to be 16 bit, but the code has to be written to correctly handle the size used.
Screaming problem is one word.
'short'.....
In CCS, a short is a _single bit_.
Change this to 'unsigned int8'.
This is why you will find experienced programmers don't use names like 'long', or 'short' for variables, but instead use _explicit_ names like 'int8', Uint8, int16 etc..
'Short', 'long' etc., have different meanings between compilers. This was a problem back when Microsoft updated VB, to VB.net, where the default meaning of long, was changed, leading to all sorts of problems when accessing external stuff in DLL's etc... |
|
|
vortexe90
Joined: 26 Feb 2013 Posts: 30 Location: Algeria
|
|
Posted: Sat Nov 09, 2013 4:19 am |
|
|
thanks Ttelmah, yes i do it but nothing too in the GLCD
I change this in the data caracters :
Code: | const unsigned int8 font11[] = {
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x03, 0x00, 0x00, 0x1E, 0x03, 0x7E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char !
0x06, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char "
0x06, 0x90, 0x03, 0xF8, 0x00, 0x96, 0x00, 0x90, 0x03, 0xF8, 0x00, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char #
0x05, 0x9C, 0x01, 0x32, 0x02, 0xFF, 0x07, 0x62, 0x02, 0xCC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char $
0x0A, 0x00, 0x00, 0x3C, 0x00, 0x42, 0x02, 0x3C, 0x01, 0xC0, 0x00, 0x20, 0x00, 0x18, 0x00, 0xE4, 0x01, 0x12, 0x02, 0xE0, 0x01, // Code for char %
0x09, 0xC0, 0x01, 0xE0, 0x03, 0x1C, 0x03, 0x7E, 0x02, 0xE2, 0x02, 0x92, 0x01, 0xAC, 0x03, 0x60, 0x02, 0x20, 0x01, 0x00, 0x00, // Code for char &
0x03, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char '
0x04, 0xF0, 0x01, 0xF8, 0x03, 0x0C, 0x06, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char (
0x04, 0x02, 0x08, 0x04, 0x06, 0xF8, 0x03, 0xF0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char )
0x06, 0x00, 0x00, 0x08, 0x00, 0x28, 0x00, 0x1E, 0x00, 0x28, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char *
0x07, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0xFC, 0x01, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char +
0x02, 0x00, 0x0B, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ,
0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char -
0x02, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char .
0x03, 0x00, 0x03, 0xF8, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char /
0x05, 0xFC, 0x01, 0xFE, 0x03, 0x02, 0x02, 0xFE, 0x03, 0xFC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 0
0x05, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x03, 0xFE, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 1
0x05, 0x08, 0x02, 0x86, 0x03, 0x46, 0x03, 0x3E, 0x03, 0x1C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 2
0x05, 0x04, 0x01, 0x02, 0x02, 0x32, 0x02, 0xFE, 0x03, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 3
0x06, 0xC0, 0x00, 0xB0, 0x00, 0x88, 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 4
0x05, 0x38, 0x03, 0x36, 0x03, 0x36, 0x02, 0x76, 0x01, 0xE2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 5
0x05, 0xF0, 0x01, 0xFC, 0x03, 0x14, 0x02, 0xF6, 0x03, 0xE2, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 6
0x05, 0x06, 0x00, 0x06, 0x00, 0x86, 0x03, 0x7E, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 7
0x05, 0xDC, 0x01, 0xFE, 0x03, 0x22, 0x02, 0xFE, 0x03, 0xDC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 8
0x05, 0x3C, 0x02, 0x7E, 0x03, 0x42, 0x01, 0xFE, 0x01, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char 9
0x03, 0x00, 0x00, 0x30, 0x03, 0x30, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char :
0x03, 0x00, 0x00, 0x30, 0x0B, 0x30, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ;
0x06, 0x40, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0x10, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char <
0x06, 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char =
0x06, 0x10, 0x01, 0x10, 0x01, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char >
0x06, 0x00, 0x00, 0x0C, 0x00, 0x0E, 0x03, 0x62, 0x03, 0x3E, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char ?
0x0A, 0xF0, 0x03, 0x08, 0x04, 0xC4, 0x09, 0xE2, 0x13, 0x32, 0x12, 0x12, 0x11, 0x92, 0x11, 0xE2, 0x13, 0x34, 0x09, 0xF8, 0x04 // Code for char @
}; |
and for this code you see it correct ??:
Code: | void glcd_text(unsigned int16 x_origin, unsigned int16 y_origin, char* textptr, unsigned int16 fgcolour, unsigned int16 bgcolour)
{
unsigned int16 info_offset;
int chr_width;
int chr_bytes;
unsigned int16 chr_hight;
unsigned int16 chr_offset;
int i,j,k;
unsigned int16 x,y;
chr_hight = font11[6]; //the hight is always stored in the 6th bit
while(*textptr != '\0')
{
if(*textptr == ' ') //found a space, we will just insert a few lines
{
x_origin = x_origin + 5; //move to the next chr position
}
else
{
info_offset = (((unsigned int16)*textptr - 33) * 4) + 8; //work out how far into the font array is the info about the current chr skipping the fist 8 byts in the table
chr_width = font11[info_offset]; //the first byte contanes the width information, this is only how wide the chr is without padding
chr_offset = make16(font11[info_offset+2], font11[info_offset+1]); //The next two bytes contane the offset in the table to the bitmap of the chr
chr_bytes = chr_width / 8; //work our how many bytes wide the char is
if (chr_width % 8)
{
chr_bytes++;
}
x = x_origin; //save the start x position
y = y_origin; //save the start y position
for(i=0;i<chr_hight;i++) //loop thought vertical bytes
{
for(j=0;j<chr_bytes;j++) //loop thought horizontal bytes
{
for(k=0;k<8;k++) //loop though each bit
{
if(bit_test(font11[chr_offset],k))
{
glcd_pixel(x,y,fgcolour); //bit is set, make the pixel the text colour
}
else
{
glcd_pixel(x,y,bgcolour); //bit is not set, make it the background colour
}
x++; //move to the next vertical line
}
chr_offset++; //move to the next byte
}
x = x_origin; //move the x origin to start drawing the next horizontal bytes
y++; //move down to the next row
}
x_origin = x_origin + chr_width + 1; //move to the next chr position
}
textptr++; //move to next char in string
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19509
|
|
Posted: Sat Nov 09, 2013 10:16 am |
|
|
You have still not done anything about char_offset....
Use your brain, rather than just hopelessly fiddling.
Feed a character number into the code.
Work out what elements it will access in the array, and then what the values it reads are. Set bits on a piece of graph paper as you read 0's and 1's.
You will see hopefully in a few seconds, that it is not accessing the data correctly.... |
|
|
Markdem
Joined: 24 Jun 2005 Posts: 206
|
|
Posted: Sun Nov 10, 2013 4:20 pm |
|
|
Looks like you are using my code
The code will work fine if you supply the right data in the font array.
At the top of my post in the library it says;
"To make the font array, have a look at http://www.mikroe.com/glcd-font-creator/. It outputs the array in microchip’s graphics library format. You want to use the “Export for TFT and new GLCD” option. "
The font array you have looks nothing like the format you need.
Try to use the font array I have posted to make sure your hardware is working fine, then try to make your own font array using the font creator.
Have fun |
|
|
in_nursery
Joined: 25 Oct 2012 Posts: 51
|
|
Posted: Thu May 05, 2016 12:27 pm |
|
|
@Markdem or other
If I had multiple font how can I choose them
for example
const unsigned int8 font11[] and const unsigned int8 font20[].
Code: | const int font11[] = {
0x00,
0x00,
0x20,0x00,
0x7F,0x00,
0x13,
0x00,....
};
const int font20[] = {
0x00,
0x00,
0x20,0x00,
0x7F,0x00,
0x19,
0x00,....
}; |
I want to select the font with the function glcd_text.
I try this with no success
Code: |
void glcd_text(unsigned int16 x_origin, unsigned int16 y_origin, char* textptr, int *fontSP, int1 color)
{
unsigned int16 info_offset;
int chr_width;
int chr_bytes;
unsigned int16 chr_hight;
unsigned int16 chr_offset;
int i,j,k;
unsigned int16 x,y;
chr_hight = fontSp[6]; //the height is always stored in the 6th bit
.....
}; |
thanks in advance |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 06, 2016 8:55 am |
|
|
Edit the existing glcd_text57() function as follows:
1. Add a 'font' parameter to the end of the parameter list.
2. Add a test at the start of the function to exit without doing anything
if the font parameter is out of range.
3. Add an if-else statement to check the font parameter. If it's 0 then
use the normal font (included in glcd.c). If it's 1, then use your own
custom font.
I am doing this the most simple way possible. I mean the quickest
to implement. It adds a little bit in code size but was quick to type.
Code: |
void glcd_text57(int x, int y, char* textptr, int size, int1 color, int8 font)
{
int i, j, k, l, m; // Loop counters
BYTE pixelData[5]; // Stores character data
if(font > 1) // Only fonts 0 and 1 are supported
return;
for(i=0; textptr[i] != '\0'; ++i, ++x) // Loop through the passed string
{
if(font == 0)
{
if(textptr[i] < 'S')
memcpy(pixelData, TEXT[textptr[i]-' '], 5);
else if(textptr[i] <= '~')
memcpy(pixelData, TEXT2[textptr[i]-'S'], 5);
else
memcpy(pixelData, TEXT[0], 5);
}
else
{
if(textptr[i] < 'S')
memcpy(pixelData, MY_FONT[textptr[i]-' '], 5);
else if(textptr[i] <= '~')
memcpy(pixelData, MY_FONT2[textptr[i]-'S'], 5);
else
memcpy(pixelData, MY_FONT[0], 5);
}
|
|
|
|
in_nursery
Joined: 25 Oct 2012 Posts: 51
|
|
Posted: Fri May 06, 2016 9:12 am |
|
|
thanks PCM programmer
finally I get work with read_program_memory(mempointer, buffer, 1); |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|