Unicorn GLCD demo.

Status
Not open for further replies.
Things are getting better, but not yet solved.

I'm now able to display a picture .
I'm not sure to be right, but i tried to change the display mode inside :

void GLCD_Write_Data
and
unsigned char GLCD_Read_Data(void)

I think ( but not sure ) GLCD display modes are as follow :

dat=GLCD_Data^0xff; // inverse display mode
dat=GLCD_Data; // regular display mode


Now i'm able to display Pommie's logo white on black
but i'm not able yet to display it black on white

vlines and hlines are still not working at all, maybe a display issue from plot function ?


Here is the modified project with these modifications.
 

Attachments

  • glcd_atomsoft.zip
    83.8 KB · Views: 416
Last edited:
Fixed: image soon
 

Attachments

  • glcd_atomsoft2.zip
    84 KB · Views: 431
  • Clipboard01.jpg
    124.5 KB · Views: 472
Last edited:
Can you tell me what did you change in order to invert color mode ?

I can see that logo is now visible, plot function is also working.

but i can't display any text, vline or hline ...
 
I just noticed that Jasons code doesn't have the dummy read that is required. Could it be that the displays use a different chip set?

@crocu, if you post your working code I'll show you the best place to invert it.

Mike.
 
Inside plot code:
Code:
//from
d=d&(0xff-(1<<(y&7)));
//to
d=d|(1<<(y&7));

Clear Screen function
Code:
//from
		for(j=0;j<0x40;j++)
			GLCD_Write_Data(0xff);
//to
		for(j=0;j<0x40;j++)
			GLCD_Write_Data(0x00);

PutChar

Code:
//from
GLCD_Write_Data(0xff);
//to
GLCD_Write_Data(0x00);

I think that was all of them heh
 
Hello Thanks to Pommi and Atomsoft,

I'm now almost done, here is attached my working code with a standalone 18F2620.

The major issue was fixed by adding the following into Wait_Not_Busy(void) :
Code:
	Delay();
	return;

Now all functions are working properly, please check my code i hope nothing is missing ( dummy read, maybe ? )




May i ask you some more questions please :

- Pommie, would you please show me where i should modify the code to invert color display ?

I put some comment into GLCD.c where i think modifications should be done, but i'm really not sure they are correct.


- I put in GLCD.c 3 new fonts i got from another project, can you tell me how to use them in main.c ( with PutMessage ? )

Code:
const far rom unsigned char Font2[95][5];
const far rom unsigned char FontSmall[10][7];
const far rom unsigned char Font18[12][16];

- Is it easy to create and use new fonts from Windows True Type existing fonts ?

- The circle function give oval forms ... not real circles, has someone a better one ?

- I do not understand what x16\x38\x18 is used for in :
PutMessage((rom char*)"\x16\x38\x18Demo");

When i add this line in main, "D" letter of Demo is not displayed ... and text comes up with 1 or 2 seconds delay, why ?


- Are KS108 GLCD exists with real colors pixels ? ( RGB )
 

Attachments

  • 18F2620_Ok.zip
    140.9 KB · Views: 457
For the string PutMessage stuff:

Code:
void PutMessage( static char rom *Message)
{
  while(*Message!=0)//Loop until we reach end of string aka 0x00
  {    
    if(*Message==0x16){  //If 0x16 is in string the next 2 bytes are position
        *Message++;      //next byte
        XPos=*Message++; //X Position is this byte then add 1 to current byte
        YPos=*Message++; //Y Position is this byte then add 1 to current byte
        WritePosition(); //Tell GLCD out position
    }
    else
    {
        PutChar(*Message++); //Write normal text now
    }
  }
}

to use add a space like:
Code:
PutMessage((rom char*)"\x16\x15\x0F Hello");
 
Last edited:
If you currently have it working and you want to invert the dispay then the only routines that need changing are,
Code:
unsigned char GLCD_Read(void){
        b_GLCD_E=1;
        Delay();
        dat=GLCD_Data^0xff;
	Delay();Delay();Delay();
        b_GLCD_E=0;
        Delay();
	return dat;
}

void GLCD_Write_Data (unsigned char data){
        Wait_Not_Busy();
	GLCD_Data = data^0xff;	// inverse display mode
        b_GLCD_RS=1;
        b_GLCD_RW=0;
        b_GLCD_E=1;
        Delay();
        b_GLCD_E=0;
}

Using fonts of different sizes would require a major rewrite.

If circles are oval then your displays pixels are oblong. I.E. a square will be an oblong.

The x16\x38\x18 is setting the position. 0x16 = set position, 0x38 = decimal 56 and 0x18 = decimal 24.
In "\x16\x38\x18Demo" the D is a valid hex character and so gets interpreted as 0x18d. Change it to, "\x16\x38\x18\tDemo" and it will display correctly (\t becomes a tab which is ignored).

Mike.
 
Thanks Pommie, inverted display mode works perfectly.


I'm now trying a Font i got another project ( Font 95_5 )

So i'm writting a new function : PC_95_5 cloned from PutChar, the only difference will be the Font name called in the function : ( Font_95_5 )

Code:
// PutChar clone for Font_95_5 :

void PC_95_5(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=[COLOR="Red"]Font_95_5[/COLOR][data-32][i];
                        if(d!=0x55){
                                d=~d;                                
                                GLCD_Write_Data(d);
                                MoveRight();
                        }
                }
                GLCD_Write_Data(0x00);               				 
                MoveRight();
        }
}

I'm not sure it will be enough to display one character from this new font because when i try to display 'A' character i get a strange and non readable character instead ...

Do you know why ? Maybe more things need change ?

--->

Code:
SetPos(63,22);
PC_95_5('A');
 
Fonts are normally defined as the first byte is the top row but in this case the first byte is the left column. Without knowing how the font is defined it's difficult to give an answer. However as each character is 5 bytes you should change the for loop to for(i=0;i<4;i++){.

Mike.
 
I tried to change the loop from 0 to 4, indeed character is smaller but still not readable ...

How was the original font from this library generated ?

Is it possible to create a font from a Windows True Type existing font and then adapt PutChar function in order to use it ?
 
How was the original font from this library generated ?

Is it possible to create a font from a Windows True Type existing font and then adapt PutChar function in order to use it ?

I can't remember as it was 4 years ago.

Converting a true type font isn't possible, well not easily. Have a look around the internet for suitable fonts but anything bigger than 7*7 will require a rewrite.

Edit, have a look at the swordfish basic ks0108 module as I seem to remember it had multiple fonts.

Mike.
 
Last edited:
I found a link for font creation but i was designed for Atmega :

GLCDFontCreator2 java program

This soft can create .h file from True Type font,
I tired to generate a font, the result is test.h

Do you think values can be used from this file ?
 

Attachments

  • test.h
    9 KB · Views: 488
Pommie:
is this the best GLCD to start experimenting with, or is there a better choice now.
thx
 
Hello

KS108 controller is very popular and GLCDs can easily be found in the market.

I think this is a very good choice.
 
Last edited:
Has anyone an experience with touchscreen on a GLCD ?

Since my GLCD is working well, i really would like to add an touchscreen on it.
I found some in Ebay stores and i looks there is also i2c touchscreen controller : AK4183

Maybe it would be much easier to buy a "ready to go" GLCD with touchscreen ?

Has someone wrote a test code in C18 to get it working ?


Many Thanks,
 
I've just made a PHP script called "Bmp2Glcd Converter" to convert bitmap files. It's fully online and compatible with PutLogo() function.

**broken link removed**

I'm waiting your feedback to make this script perfect!

Enjoy!
Hamit.
 
Last edited:
Hello,

I'm back on that post because i'm experiencing problem :

When i try to display a converted short int to a string with Putstring function i get outstanding things displayed.

ultoi conversation works properly ( result tested ok from my debugger watch window ) but when i try to display my converted string in the GLCD, it display a number that is totaly different !

Code:
void PutString(char *Message){
        while(*Message!=0)
                if(*Message==0x16){
                        *Message++;
                        XPos=*Message++;
                        YPos=*Message++;
                        WritePosition();
                }
                else
                        PutChar(*Message++);
}

First i convert a 16 bit short int into a character table :

Code:
unsigned short int INT_value;
unsigned char ASCII_value;
...
uitoa(INT_value,ASCII_value);
SetPos(30,15);PutString(ASCII_value);
Has someone an idea about this problem ?
Should i not use PutString properly ?

Thanks for your help,
 
I'm just on my way out but I'll try and take a look in the morning. I think it's a mix up of rom/ram pointers.

Mike.
 
I've tried to cast, but with no success
Code:
SetPos(30,15);PutString((unsigned char*)ASCII_value);
and also tried that :
Code:
SetPos(30,15);PutString((far rom unsigned char*)ASCII_value);
Maybe there's something to modify in the PutString function, if so my skills in C are not good enough.

Thanks for your help,
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…