Unicorn GLCD demo.

Status
Not open for further replies.
You must have changed some other part of the code as it works perfectly on mine. What happens if you call ClearScreen before printing the text?

Mike.
 
what is your current code for:
Code:
void ClearScreen(void)

also pommie shouldnt this be more like:

Code:
void GLCD_Write_Data (unsigned char data){
	Wait_Not_Busy();
	GLCD_Data = [B]~(data)[/B];
	b_GLCD_RS=1;
	b_GLCD_RW=0;
	b_GLCD_E=1;
	Delay();
	b_GLCD_E=0;
}

unsigned char GLCD_Read_Data(void){
	Wait_Not_Busy();
	TRIS_Data=0xff;
	b_GLCD_RS=1;
	b_GLCD_RW=1;
	b_GLCD_E=1;
	Delay();
	W=[B]~(GLCD_Data)[/B];
	b_GLCD_E=0;
	TRIS_Data=0x00;
	return W;
}
 
Last edited:
Pommie it gives the same result.

ClearScreen when called actually turns the screen complete black. Is it possible that my screen is running in inverted mode already. When (in proteus) the screen is powered on, it gives black background.



AtomSoft: Its the same thing, gives the same result I tried what you said earlier before asking question here on forum
 
Is this your GLCD clear screen?
Code:
void ClearScreen(void){
unsigned char i,j;
	b_GLCD_GCS1=1;
	b_GLCD_GCS2=1;	
	for(i=0;i<8;i++){
		GLCD_Write_Cmd(0x40);	//y=0
		GLCD_Write_Cmd(0xb8+i);	//x=0
		for(j=0;j<0x40;j++)
			GLCD_Write_Data(0x00);
	}
	SetPos(0,0);
}
 
AtomSoft: It doesnt actually make any difference.

I have tried

GLCD_Write_Data(0x00);
and
GLCD_Write_Data(~(0x00));
and
GLCD_Write_Data(0xFF);


Still gives the same result
 
If you are then try this:



also revert all the data back to normal, meaning If you changed the read data and others put them back to normal.... the only thing that should be changed is:

Code:
void GLCD_Write_Data (unsigned char data){
	Wait_Not_Busy();
	[B]GLCD_Data =~data;[/B]
	b_GLCD_RS=1;
	b_GLCD_RW=0;
	b_GLCD_E=1;
	Delay();
	b_GLCD_E=0;
}

 

Attachments

  • glcd.jpg
    68.8 KB · Views: 595
  • Clipboard03.jpg
    320.1 KB · Views: 768
Last edited:
Thank you so much

It finally works by changing the initial contents of Ram.

Will this work in real GLCD project aswell (i hope so)
 
it should heh.... and your welcome

ill test it out later on or tomorrow and ill take some pictures
 
Last edited:
had 10 min free so here it is: (Tried it on 18F4620 tho)
From design to creation:



 

Attachments

  • glcd.jpg
    207.8 KB · Views: 573
Last edited:
Thank you AtomSoft, its seems like you are an expert .

I am working on an image based display for Fan percentages

I have attached a small image (128 x 64) pixels which might give a little clearer idea.

Its kinda like volume bars going up and down according to input.

Will this be possible to make or are there some limitations that i might need to know prior to a result in vain.
 

Attachments

  • Untitled-1.jpg
    1.3 KB · Views: 306
ShoulD be simple to do.. i would suggest using the line command. mainly because images take up a lot of space... you can have 1 function draw the bars .
 
Last edited:
Is there any function to print numbers on the LCD?

I've just the one below, but doesn't work. It prints a junk of meaningless ASCII characters.
Code:
void glcd_Write8BitNumber(unsigned char num)
{
	unsigned char hundreds = 0, tens = 0;
	char szNum[4];
	
	if (num >= 200)
	{
		hundreds += 2;
		num -= 200;
	}
	else if (num >= 100)
	{
		hundreds++;
		num -= 100;
	}
	
	while (num >= 10)
	{
		num -= 10;
		tens++;
	}
	
	hundreds += 0x30;
	tens += 0x30;
	num += 0x30;
	
	szNum[0] = hundreds;
	szNum[1] = tens;
	szNum[2] = num;
	szNum[3] = 0;
	
	PutMessage((rom char*) szNum);
}
 
heh easy one now

sprintf like...

Code:
    contrast = 57;

    sprintf(tempStr, "Contrast: %d",contrast);
    // lcd code to place string on lcd here
 
Last edited:
^ Now it's worse. It clears out the screen when I try to print the string.

Code:
	while (1)
	{
		glcd_ClearScreen();
		glcd_SetPosition(0, 0);
		
		ADCON0 |= 0x02;
		while(ADCON0 & 0x02);
		
		glcd_PutMessage((rom char*) "The temperature is: ");
		//glcd_Write8BitNumber(ADRESH);
		//glcd_Write8BitNumber(ADRESL);
		glcd_Write8BitNumber(20);
		Delay10KTCYx(0);
	}

Code:
void glcd_Write8BitNumber(unsigned char num)
{
	char szNum[40];	// I think 40 is large enough
	sprintf(szNum, "%d", num);
	glcd_PutMessage((rom char*) szNum);
}

I see the string "The temperature is:" for half a second, then the screen is wiped out.
 
You can't use PutMessage to print a string that is in RAM as it expects a ROM pointer. What you need to do is,
Code:
void glcd_Write8BitNumber(unsigned char num)
{
unsigned char szNum[40],i;	// I think 40 is large enough
    sprintf(szNum, "%d", num);
    for(i=0;szNum[i]!=0;i++)
        PutChar(szNum[i]);
}
But, I would make it print a signed integer,
Code:
void glcd_WriteInt(int num)
{
unsigned char szNum[7],i;       //can contain up to 6 characters with the sign
    sprintf(szNum, "%d", num);
    for(i=0;szNum[i]!=0;i++)
        PutChar(szNum[i]);
}
Mike.
 
you could also create a new "glcd_PutMessage" and name it "glcd_PutMsg" but have it accept local non rom variables
 
I have a little problem making the lines.

When i put code:

box(120,0,128,0);
box(120,7,128,7);

It only displays one line. The problem is that the offset of the two lines needs to be more than 8 pixels. Is there any option of drawing boxes smaller than 8 pixels?

For example, according to my understanding, the following command should make a four pixel thick box but it doesnt.

box(0,0,128,4);
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…