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. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    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.
     

    Attached Files:

    Last edited: Dec 6, 2010
  2. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Fixed: image soon
     

    Attached Files:

    Last edited: Dec 6, 2010
  3. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    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 ...
     
  4. dave

    Dave New Member

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


     
  5. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,019
    Likes:
    317
    Location:
    Brisbane Australia

    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.
     
  6. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Inside plot code:
    Code (text):

    //from
    d=d&(0xff-(1<<(y&7)));
    //to
    d=d|(1<<(y&7));
     
    Clear Screen function
    Code (text):

    //from
            for(j=0;j<0x40;j++)
                GLCD_Write_Data(0xff);
    //to
            for(j=0;j<0x40;j++)
                GLCD_Write_Data(0x00);
     
    PutChar

    Code (text):

    //from
    GLCD_Write_Data(0xff);
    //to
    GLCD_Write_Data(0x00);
     
    I think that was all of them heh
     
  7. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    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 (text):
        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 (text):
    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 )
     

    Attached Files:

  8. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    For the string PutMessage stuff:

    Code (text):

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

    PutMessage((rom char*)"\x16\x15\x0F Hello");
     
     
    Last edited: Dec 7, 2010
  9. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,019
    Likes:
    317
    Location:
    Brisbane Australia
    If you currently have it working and you want to invert the dispay then the only routines that need changing are,
    Code (text):

    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.
     
  10. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    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 (text):
    // 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 (text):
    SetPos(63,22);
    PC_95_5('A');
     
  11. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,019
    Likes:
    317
    Location:
    Brisbane Australia
    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.
     
  12. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    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 ?
     
  13. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,019
    Likes:
    317
    Location:
    Brisbane Australia
    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: Dec 8, 2010
  14. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    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 ?
     

    Attached Files:

    • test.h
      File size:
      9 KB
      Views:
      216
  15. Mosaic

    Mosaic Well-Known Member

    Joined:
    Jun 3, 2010
    Messages:
    2,569
    Likes:
    128
    Location:
    Caribbean
    Pommie:
    is this the best GLCD to start experimenting with, or is there a better choice now.
    thx
     
  16. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    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: Dec 9, 2010
  17. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    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,
     
  18. hamityanik

    hamityanik New Member

    Joined:
    Jul 13, 2011
    Messages:
    1
    Likes:
    0
    I've just made a PHP script called "Bmp2Glcd Converter" to convert bitmap files. It's fully online and compatible with PutLogo() function.

    http://www.malzemeara.com/tools/bmp2glcd.html

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

    Enjoy!
    Hamit.
     
    Last edited: Jul 15, 2011
  19. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    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 (text):
    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 (text):
    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,
     
  20. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,019
    Likes:
    317
    Location:
    Brisbane Australia
    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.
     
  21. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    I've tried to cast, but with no success :(
    Code (text):
    SetPos(30,15);PutString((unsigned char*)ASCII_value);
    and also tried that :
    Code (text):
    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. :confused:

    Thanks for your help,
     

Share This Page