Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Unicorn GLCD demo.

Status
Not open for further replies.
Hi,

I have a problem to display images, while for others it works.
Here is the image I want to see:

Code:
const rom unsigned char UP_BUTTON[]={
 40 /*width */,
 9 /* height */,
 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xE7,
 0xFF , 0xFF , 0xFF , 0xFF , 0xC3 , 0xFF , 0xFF , 0xFF,
 0xFF , 0x81 , 0xFF , 0xFF , 0xFF , 0xFF , 0x00 , 0xFF,
 0xFF , 0xFF , 0xFF , 0xE7 , 0xFF , 0xFF , 0xFF , 0xFF,
 0xE7 , 0xFF , 0xFF , 0xFF , 0xFF , 0xE7 , 0xFF , 0xFF,
 0xFF , 0xFF , 0xFF , 0xFF , 0xFF
};

by:

Code:
PutLogo((rom char*)UP_BUTTON);

and here is my function:

Code:
void PutLogo(char rom *logo){
unsigned char w,h,bitcount,Byte;
	w=*logo++;
	h=*logo++;
	bitcount=0;
	do{
		for(i=0;i<w;i++){
			if(bitcount==0){
				bitcount=8;
				Byte=*logo++;
			}
			if(Byte&1) plot(XPos,YPos);
			XPos++;
			Byte/=2;
			bitcount--;
		}
		YPos++;
		XPos-=w;
	}while(--h);
}

and when I work mode step by step, I realized that it took as the value of "w" and "h" the value "0".

Have you any idea? because I tried everything and nothing happens, it always does, and I think it is that it takes an image of size 0x0.

Thank you in advance.
 
I had a problem with that as well. I changed the 'w' to another letter because 'w' is reserved. Hope that helps. Also, make sure you call SetPos before PutLogo.
 
Hi,

thank you for your help, i change the "w" in "l" ans the "W" in "LL",
but I still have the same phenomenon, when I do "PutLogo" it takes to "0" for variable "h" and "l" ...

I take "PutLogo" before, and my "xpos" and "ypos" variables make the right values but when the instruction "PutLogo" it does not take into account the size defined ...
you have an idea?
thank you in advance
 
Last edited:
Hi,
I have another concern, I changed the name of my variable w and sometimes it takes me more inconsistent values for width and height.
For example, for this picture:
Code:
const rom unsigned char CODE_CONTRUCTEUR_FR[]={
 128, /*width */
 9,   /*height*/
 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF,
 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF,
 0x1F , 0x0C , 0x06 , 0x07 , 0x1F , 0x0C , 0xE6 , 0x06,
 0x81 , 0xE0 , 0x9C , 0x41 , 0x20 , 0xC8 , 0x09 , 0xFE,
 0xCF , 0xE7 , 0x64 , 0xE6 , 0xCF , 0xE7 , 0xC4 , 0xF2,
 0xE7 , 0xCC , 0x9C , 0xFC , 0x39 , 0xCF , 0xC9 , 0xFC,
 0xCF , 0xE7 , 0xE4 , 0xE4 , 0xCF , 0xE7 , 0x84 , 0xF2,
 0xE7 , 0xCC , 0x9C , 0xFC , 0x39 , 0xCF , 0xC9 , 0xFC,
 0xCF , 0xE7 , 0xE4 , 0x04 , 0xCF , 0xE7 , 0x14 , 0x86,
 0xE7 , 0xCC , 0x9C , 0xFC , 0x39 , 0xC8 , 0xC9 , 0xFC,
 0xCF , 0xE7 , 0xE4 , 0xE4 , 0xCF , 0xE7 , 0x34 , 0x3E,
 0xE7 , 0xE0 , 0x9C , 0xFC , 0x39 , 0xCF , 0x09 , 0xFE,
 0xCF , 0xE7 , 0x64 , 0xE6 , 0xCF , 0xE7 , 0x74 , 0x3E,
 0xE7 , 0xE4 , 0x9C , 0xFC , 0x39 , 0xCF , 0x49 , 0xFE,
 0x1F , 0x0C , 0x06 , 0x07 , 0x1F , 0x0C , 0xF6 , 0x82,
 0xE7 , 0xCC , 0xC1 , 0xC1 , 0x39 , 0x18 , 0xCC , 0xFC,
 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF,
 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF
};
It takes me to:
larg = 230;
haut = 106;

here is my function "PutLogo":
Code:
void PutLogo(char rom *logo){
unsigned char larg,haut,bitcount,Byte;
	larg=*logo++;
	haut=*logo++;
	bitcount=0;
	do{
		for(i=0;i<larg;i++){
			if(bitcount==0){
				bitcount=8;
				Byte=*logo++;
			}
			if(Byte&1) plot(XPos,YPos);
			XPos++;
			Byte/=2;
			bitcount--;
		}
		YPos++;
		XPos-=larg;
	}while(--haut);
}

Have you any idea? I can not understand why?
I'm really stuck on my project, I was not going ...

Thank you in advance
 
Try this:
Code:
void PutLogo(char rom *logo){
unsigned char larg,haut,bitcount,Byte;
	larg=*logo++;
	haut=*logo++;
	bitcount=8;
	do{
		for(i=0;i<larg;i++){
			if(bitcount==8){
				bitcount=0;
				Byte=*logo++;
			}
			if(Byte&0x80) plot(XPos,YPos);
			XPos++;
			Byte*=2;
			bitcount++;
		}
		YPos++;
		XPos-=larg;
	}while(--haut);
}
 
Hello,

I just test the function that you sent me, but this function sends the logos inverted over a width of 8 pixels.
But the thing I do not understand is that the function that I use works, but sometimes for certain logos, I see things he inconsistent, or even the time it takes to size "0x0".

Thank you for your help ...
 
The only way I can see that it could be inconsistent is if the logo data was in a far area. Try changing the pointers to far pointers and see if that fixes it.
Code:
const [COLOR="red"]far[/COLOR] rom unsigned char CODE_CONTRUCTEUR_FR[]={
void PutLogo(char [COLOR="Red"]far[/COLOR] rom *logo){
You will have to change it in a few other places as well.

BTW, which pic chip are you using?

Mike.
 
Thank you Pommie ...
Everything works correctly, I added the "far" in all my statements and functions PutLogo ", and it works ...
A big thank you because I was beginning to despair ...
By against, could you explain why? What does the term "far"? I suppose it is the memory access ...

But in any case, thank you very much ...
 
The chip that you chose has 128k of memory and most compilers assume that you will use a chip that has no more than 64k. With 64k of memory the address fits in 16 bits and so we can use near pointers (16 bit). When the address space gets bigger then we need bigger pointers. The far directive tells the compiler to use 24 bits as a pointer.

You must have lots of data in your project. May I ask what it is?

Mike.
 
My project has many variables (900 bytes in data memory), and approximately 97,656 bytes of program data.
My application has several configuration menu and allows to measure several types of informations.
Thank you for your help Pommie
 
Pommie, I have a little question to ask:
- I want to display a "float" or "int" is that I convert my string variable, but I get a string of cloud of points.
That's how I proceeded:

Code:
char DATAtoLCD[30];
float voltage;
[...]
voltage = 6.654;
[...]
sprintf (DATAtoLCD,"%6.2f",voltage);
SetPos(73,19);                                           
PutMessage(DATAtoLCD);

I use the Microchip C18 compiler for more information.
Thank you in advance
 
I use this. You will need to convert your number to an integer, though.
Code:
void displayNum(int x, int y, int theValue) {
    char toPrint[4];
    
    toPrint[0] = (theValue/1000)+48;
    toPrint[1] = ((theValue%1000)/100)+48;
    toPrint[2] = ((theValue%100)/10)+48;
    toPrint[3] = (theValue%10)+48;
    
    SetPos(x,y);
    PutChar(toPrint[0]);
    PutChar(toPrint[1]);
    PutChar(toPrint[2]);
    PutChar(toPrint[3]);
}

I believe this is faster than using sprintf.
 
The sprintf function in C18 does not support floating point. I suggest you look around for a ftoa function.

Mike.
 
I had a play with this and here is the result. A quick and dirty ftoa routine.

Code:
void ftoa(float f,char* String,char Places){
long power;
char n,i;
    power=1;
    while(power*10<=f)
        power*=10;
    while(power>=1){
        n=(char)(f/power);
        f-=n*power;
        power/=10;
        *String++=n+'0';
    }
    *String++='.';
    for(i=0;i<Places;i++){
        f*=10;
        n=(char)f;
        f-=n;
        *String++=n+'0';
    }
    *String=0;
}
If you're sure your number will never go over 99,999 then you can change power to an int.

Mike.
 
Hi AtomSoft, I used your function void loadimg(rom char *image); and the mikroelectronica bitmap generator, I'm using C18 compiler, but when I build the project I have this message of error: Error - section '.idata_main.o' can not fit the section. Section '.idata_main.o' length=0x00000400

Waht can I do? thanks
 
bmp to C

Please Pommie can you convert my logo to use in GLCD...thanks
 

Attachments

  • BUHO.JPG
    BUHO.JPG
    2 KB · Views: 711
Ive been out of the field for a while but if i remember its a memory issue.Like a linker issue.Ask pommie or futz.They helped me with a similar issue. If i remember ill be sure to post the information for you.
 
Status
Not open for further replies.

Latest threads

Back
Top