1. 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.
    Dismiss Notice

Unicorn GLCD demo.

Discussion in 'Microcontrollers' started by Pommie, Jun 20, 2007.

  1. jorg1n

    jorg1n New Member

    Joined:
    Feb 11, 2009
    Messages:
    29
    Likes:
    0
    Hi,

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

    Code (text):
    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 (text):
    PutLogo((rom char*)UP_BUTTON);  
    and here is my function:

    Code (text):
    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.
     
  2. superbrew

    superbrew Member

    Joined:
    Oct 1, 2007
    Messages:
    117
    Likes:
    2
    Location:
    Nashua, NH
    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.
     
  3. jorg1n

    jorg1n New Member

    Joined:
    Feb 11, 2009
    Messages:
    29
    Likes:
    0
    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: Mar 9, 2009
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. jorg1n

    jorg1n New Member

    Joined:
    Feb 11, 2009
    Messages:
    29
    Likes:
    0

    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 (text):
    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 (text):
    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
     
  6. superbrew

    superbrew Member

    Joined:
    Oct 1, 2007
    Messages:
    117
    Likes:
    2
    Location:
    Nashua, NH
    Try this:
    Code (text):
    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);
    }
     
  7. jorg1n

    jorg1n New Member

    Joined:
    Feb 11, 2009
    Messages:
    29
    Likes:
    0
    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 ...
     
  8. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    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 (text):

    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.
     
  9. jorg1n

    jorg1n New Member

    Joined:
    Feb 11, 2009
    Messages:
    29
    Likes:
    0
    Thank you,

    I will test this.
    I am using a PIC 18F6722.
    Thank you again
     
  10. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    That has 128k of program space and so the far pointer may fix it. Let us know the outcome.

    Mike.
     
  11. jorg1n

    jorg1n New Member

    Joined:
    Feb 11, 2009
    Messages:
    29
    Likes:
    0
    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 ...
     
  12. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    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.
     
  13. jorg1n

    jorg1n New Member

    Joined:
    Feb 11, 2009
    Messages:
    29
    Likes:
    0
    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
     
  14. jorg1n

    jorg1n New Member

    Joined:
    Feb 11, 2009
    Messages:
    29
    Likes:
    0
    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 (text):

    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
     
  15. superbrew

    superbrew Member

    Joined:
    Oct 1, 2007
    Messages:
    117
    Likes:
    2
    Location:
    Nashua, NH
    I use this. You will need to convert your number to an integer, though.
    Code (text):
    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.
     
  16. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    The sprintf function in C18 does not support floating point. I suggest you look around for a ftoa function.

    Mike.
     
  17. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    I had a play with this and here is the result. A quick and dirty ftoa routine.

    Code (text):

    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.
     
  18. juanog

    juanog New Member

    Joined:
    Feb 16, 2009
    Messages:
    6
    Likes:
    0
    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
     
  19. juanog

    juanog New Member

    Joined:
    Feb 16, 2009
    Messages:
    6
    Likes:
    0
    bmp to C

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

    Attached Files:

  20. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    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.
     
  21. superbrew

    superbrew Member

    Joined:
    Oct 1, 2007
    Messages:
    117
    Likes:
    2
    Location:
    Nashua, NH

Share This Page