AnsweredHot!LCD 2x16 create custom character

Page: 12 > Showing page 1 of 2
Author
Dimitris
Super Member
  • Total Posts : 279
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
2018/03/09 07:42:33 (permalink)
0

LCD 2x16 create custom character

I'm trying to find how can i create a custom character in my lcs. And every time i will write this letter example 'θ' to create specific character in my lcd.
 
i found that i must create an array with hex inside for lcd. I cant understand how can i use the custom character inside my string. Example
 
const unsigned short MyChar5x8[] = {
  0x00, 0x00, 0x0A, 0x1F, 0x1F, 0x0E, 0x04, 0x00, // Code for char num #0
  0x0E, 0x1B, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x00, // Code for char num #1
  0x0E, 0x1B, 0x11, 0x11, 0x11, 0x1F, 0x1F, 0x00, // Code for char num #2
  0x0E, 0x1B, 0x11, 0x11, 0x1F, 0x1F, 0x1F, 0x00, // Code for char num #3
  0x0E, 0x1B, 0x11, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, // Code for char num #4
  0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, // Code for char num #5
  0x00, 0x04, 0x02, 0x1F, 0x02, 0x04, 0x00, 0x00, // Code for char num #6
  0x00, 0x00, 0x0E, 0x11, 0x11, 0x0A, 0x1B, 0x00 // Code for char num #7
};

void InitCustomChars()
{
  char i;
  LCDCommand(0x01); // Set CGRAM Address
  LCDCommand(0x01); // .. set CGRAM Address
  for (i = 0; i <= 63 ; i++)
    LCDPutStr(MyChar5x8[i],1); //1 is my starting lcd position in screen
  LCDCommand(0); // Return to Home
  LCDCommand(2); // .. return to Home
}

And inside my main


    LCDClear();
   LCDPutStr(0,1);

 
 
 
Here is my source file:
 

Attachment(s)

Attachments are not available: Download requirements not met
#1
GoEk
Senior Member
  • Total Posts : 100
  • Reward points : 0
  • Joined: 2012/09/27 00:32:28
  • Location: Sweden
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/09 08:28:39 (permalink)
+1 (1)
AFAIK you upload your custom character to a location in the LCD RAM. This RAM position is then mapped to an ASCII character number outside the normal character range. Check the LCD data sheet.
#2
davekw7x
Entropy++
  • Total Posts : 1504
  • Reward points : 0
  • Joined: 2012/01/16 12:01:07
  • Location: Left Coast, USA
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/09 09:50:22 (permalink)
+1 (1)
dimis1989
I'm trying to find how can i create a custom character...




Some few years ago, I made some notes for a colleague (my boss, actually) to illustrate the principle and to show how and why my code works.  Maybe you can use this to organize your code to do the deed.

The code examples were taken from a working program, and are still used in various projects with XC8 and XC16.

Here goes...

For n = 0,1,...,7, the CGRAM address of Special Character n is given by
    addr = (0x40 | (n << 3));

For your reference, here's a handy, dandy list of the addresses:

     Special      CGRAM
    Character    Address
    ---------------------
        0          0x40
        1          0x48
        2          0x50
        3          0x58
        4          0x60
        5          0x68
        6          0x70
        7          0x78

To arrive at the address for initializing the special chars in a program, you could put the addresses in a table or generate them on the fly (or you could hard-code the address if that suits your fancy).

Anyhow, suppose you have something like:

// Special character used to indicate active row on top level menu
// ActiveRowIndicator =  Special1
const unsigned char Special1[8] = {
    0X10, 0X18, 0X1C, 0X1E, 0X1C, 0X18, 0X10, 0X00
};


This can be initialized by

    // The "ActiveRowIndicator"
    // Address of special character 1 is
    //  0x40 | (1<<3)
    lcd_write_cmd(0x48); // CGRAM address of special character one
    for (i = 0; i < 8; i++) {
        lcd_write_data(Special1[i]);
    }


In a header, somewhere, I might define the special character symbolically:

#define ActiveRowIndicator 1


Then, assuming you have a function LCD_goto_row_col() to place the LCD cursor at a specific position, and a function LCD_write_data(),  to send a data byte to the LCD, you can put the special character on the screen like this:

    LCD_goto_row_col(thisrow, thatcol);
    LCD_write_data(ActiveRowIndicator);

 
Note that you might want to embed a special character in a "string" to write to the LCD (for example: using "\x01", for special character number 1).  That would work, fine and dandy, for special characters 1 through 7, but you can not (that's not) embed special character zero in a "string," since \x00 will terminate the "string."


Regards,

Dave


post edited by davekw7x - 2018/03/09 10:19:39

Sometimes I just can't help myself...
#3
1and0
Access is Denied
  • Total Posts : 8337
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/09 10:21:45 (permalink)
0
davekw7x
Note that you might want to embed a special character in a "string" to write to the LCD (for example: using "\x01", for special character number 1), but you can not (that's not) embed special character zero in a "string," since \x00 will terminate the "string."

Excellent explanation, Dave.  For character zero, use "\x08" since all 8 custom characters are mapped to 0x08 to 0x0F as well.  That said, recently I asked if there's any use for octal these days, this may be one use. ;)
 
#4
Dimitris
Super Member
  • Total Posts : 279
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/09 12:43:02 (permalink)
0
Thank you for nice explanation. But i have two questions. 
First after Lcd command, should i quit with another lcd command?
Second question in my case i dont know if it have any affect but my code is using position inside the Lcd_write data. 
My code is  LCDPutStr("My project",1);    the '1' after the string belong to the starting position.
 
So my code should look like 
 
 


const unsigned char Special1[8] = {
    0X10, 0X18, 0X1C, 0X1E, 0X1C, 0X18, 0X10, 0X00
};


 

LCDCommand(0x48); // CGRAM address of special character one
    for (i = 0; i < 8; i++) {
        LCDPutStr(Special1[i],1);
    }


 

LCDPutStr(Special,1);


 

 
But i dont get any clear character on my lcd i get right on my lcd Adran Ai--May company's name
#5
qɥb
Monolothic Member
  • Total Posts : 3329
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/09 16:13:51 (permalink)
0
I think you have misunderstood the whole concept.
The hardware supports eight custom characters. You write bit patterns to special addresses to customise how these characters look.
Once you have done that, you can embed these custom characters into normal strings.
The first one can be encoded as character 0x00 or 0x08
The second one is encoded as 0x01 or 0x09, and so on up to 0x07 or 0x0F.
 
Wherever you insert character 0x00 or 0x08 in your string, you will actually see whatever shape has been placed into the first custom character location.
 
So to get "Adran AiθMa" you would actually write "Adran Ai\x08Ma" to the LCD
(assuming "θ" is your first custom character.)
 
 
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
#6
cea
Starting Member
  • Total Posts : 80
  • Reward points : 0
  • Joined: 2006/02/17 00:01:25
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/09 18:09:45 (permalink)
+2 (2)
Here is my 2x16 LCD character interface that initializes the character generator RAM in the HD44780:
/*
 * File:   init.h
 * Author:
 * Target: PIC18F4550
 *
 */
#ifndef INIT_H
#define INIT_H
/*   Specify the System clock frequency in Hz */
#define FSYS (48000000UL)
    
/*   Specify the Peripheral clock frequency in Hz */
#define FCYC (FSYS/4UL)

#define _XTAL_FREQ FSYS

#endif

/*
 * File:   lcd.h
 * Author:
 * Target: PIC18F4550
 *
 */
#ifndef LCD_H
#define LCD_H

/* Define the LCD interface and character size */
#define LCD_FORMAT (FOUR_BIT & LINES_5X7)

/* Define the LCD port pins */
#define LCD_POWER_EN        LATDbits.LATD7
#define E_PIN               LATDbits.LATD6
#define RW_PIN              LATDbits.LATD5
#define RS_PIN              LATDbits.LATD4
#define LCD_DATA_BITS       0x0F
#define LCD_PORT_IN         PORTD
#define LCD_PORT_OUT        LATD

#define LCD_POWER_EN_DIR    TRISDbits.TRISD7
#define E_PIN_DIR           TRISDbits.TRISD6
#define RW_PIN_DIR          TRISDbits.TRISD5
#define RS_PIN_DIR          TRISDbits.TRISD4
#define LCD_PORT_DIR        TRISD

/* Clear display command */
#define CLEAR_DISPLAY 0b00000001

/* Return home command */
#define RETURN_HOME 0b00000010

/* Display ON/OFF Control defines */
#define DON         0b00001111   /* Display on      */
#define DOFF        0b00001011   /* Display off     */
#define CURSOR_ON   0b00001111   /* Cursor on       */
#define CURSOR_OFF  0b00001101   /* Cursor off      */
#define BLINK_ON    0b00001111   /* Cursor Blink    */
#define BLINK_OFF   0b00001110   /* Cursor No Blink */

/* Cursor or Display Shift defines */
#define SHIFT_CUR_LEFT    0b00010011   /* Cursor shifts to the left   */
#define SHIFT_CUR_RIGHT   0b00010111   /* Cursor shifts to the right  */
#define SHIFT_DISP_LEFT   0b00011011   /* Display shifts to the left  */
#define SHIFT_DISP_RIGHT  0b00011111   /* Display shifts to the right */

/* Function Set defines */
#define FOUR_BIT   0b00101111   /* 4-bit Interface               */
#define EIGHT_BIT  0b00111111   /* 8-bit Interface               */
#define LINE_5X7   0b00110011   /* 5x7 characters, single line   */
#define LINE_5X10  0b00110111   /* 5x10 characters               */
#define LINES_5X7  0b00111011   /* 5x7 characters, multiple line */

/* Start address of each line */
#define LINE_ONE    0x00
#define LINE_TWO    0x40

void LCD_Init(void);
void LCD_SetCGRamAddr(unsigned char data);
void LCD_SetDDRamAddr(unsigned char data);
void LCD_WriteCmd(unsigned char data);
void LCD_WriteData(unsigned char data);
void LCD_WriteConstString(const unsigned char * prString);
void LCD_WriteString(unsigned char * pString);

#endif

/*
 * File:   lcd.c
 * Author:
 *
 * Target: PIC18F4550
 */

#include <xc.h>
#include "init.h"
#include "lcd.h"

#if (LCD_DATA_BITS == 0x0F)
  #define LCD_DATA_ON_LOW_4_BITS
#else
  #if (LCD_DATA_BITS == 0xF0)
    #define LCD_DATA_ON_HIGH_4_BITS
  #else
    #error LCD interface supports 4-bit mode only on high or low 4-bits of one port
  #endif
#endif

static unsigned char LCD_BusyBit;

static const unsigned char CGRAM_Table[] =
{
    0b10000000, /* CGRAM character 1 */
    0b10000100,
    0b10000010,
    0b10001111,
    0b10000010,
    0b10000100,
    0b10000000,
    0b10011111,

    0b10001110, /* CGRAM character 2 */
    0b10010001,
    0b10010000,
    0b10010000,
    0b10010001,
    0b10001110,
    0b10000000,
    0b10011111,

    0b10001110, /* CGRAM character 3 */
    0b10010001,
    0b10010000,
    0b10010011,
    0b10010001,
    0b10001110,
    0b10000000,
    0b10011111,

    0b10000000, /* CGRAM character 4 */
    0b10001110,
    0b10001010,
    0b10001010,
    0b10001110,
    0b10000000,
    0b10000000,
    0b10011111,

    0b10011110, /* CGRAM character 5 */
    0b10010001,
    0b10010001,
    0b10011110,
    0b10010010,
    0b10010001,
    0b10000000,
    0b10011111,

    0b10001110, /* CGRAM character 6 */
    0b10010001,
    0b10010001,
    0b10011111,
    0b10010001,
    0b10010001,
    0b10000000,
    0b10011111,

    0b10010001, /* CGRAM character 7 */
    0b10011011,
    0b10010101,
    0b10010101,
    0b10010001,
    0b10010001,
    0b10000000,
    0b10011111,

    0b10000000, /* CGRAM character 8 */
    0b10000100,
    0b10001000,
    0b10011110,
    0b10001000,
    0b10000100,
    0b10000000,
    0b10011111,

    0b00000000  /* End of table marker */
};

static void LCD_E_Pulse(void)
{
    E_PIN = 1;
    __delay_us(4);
    E_PIN = 0;
    __delay_us(4);
}

static void LCD_DelayPOR(void)
{
    __delay_ms(15);
}

static void LCD_Delay(void)
{
    __delay_ms(5);
}

static unsigned char LCD_GetByte(void)
{
    unsigned char LCD_Data;
    
    LCD_PORT_DIR |= LCD_DATA_BITS; /* make LCD data bits inputs */
    RW_PIN = 1;
    
    E_PIN = 1;
    __delay_us(4);
    LCD_Data = LCD_PORT_IN & LCD_DATA_BITS;
    E_PIN = 0;
    __delay_us(4);
    
    LCD_Data = ((LCD_Data >> 4) | (LCD_Data << 4));
    
    E_PIN = 1;
    __delay_us(4);
    LCD_Data |= LCD_PORT_IN & LCD_DATA_BITS;
    E_PIN = 0;
    __delay_us(4);

#ifdef LCD_DATA_ON_HIGH_4_BITS
    LCD_Data = ((LCD_Data >> 4) | (LCD_Data << 4));
#endif
    return LCD_Data;
}

static void LCD_PutByte(unsigned char LCD_Data)
{
#ifdef LCD_DATA_ON_HIGH_4_BITS
    LCD_Data = ((LCD_Data >> 4) | (LCD_Data << 4));
#endif

    LCD_PORT_DIR &= ~LCD_DATA_BITS; /* make LCD data bits outputs */
    RW_PIN = 0;
    
    /* send first nibble */
    LCD_PORT_OUT &= ~LCD_DATA_BITS;
    LCD_PORT_OUT |= ((LCD_Data >> 4) | (LCD_Data << 4)) & LCD_DATA_BITS;
    LCD_E_Pulse();
    
    LCD_PORT_OUT &= ~LCD_DATA_BITS;
    LCD_PORT_OUT |= (LCD_Data) & LCD_DATA_BITS;
    LCD_E_Pulse();

    LCD_PORT_DIR |= LCD_DATA_BITS; /* make LCD data bits inputs */
}

static void LCD_Busy(void)
{
    if (LCD_BusyBit)
    {
        unsigned char LCD_Data;
    
        LCD_PORT_DIR |= LCD_DATA_BITS; /* make LCD data bits inputs */
        LCD_Data = 0;

        RS_PIN = 0;
        RW_PIN = 1;
        do
        {
            LCD_Data = LCD_GetByte();
        } while (LCD_Data & LCD_BusyBit);
    }
    else
    {
        LCD_Delay(); /* use 5ms delay when busy bit is unknown */
    }
}

void LCD_Init(void)
{
    unsigned char LCD_Data;
    
    LCD_BusyBit = 0;
    LCD_PORT_DIR &= ~LCD_DATA_BITS; /* make LCD data bits outputs */
    E_PIN_DIR = 0;                  /* make LCD Enable strobe an output */
    RW_PIN_DIR = 0;                 /* make LCD Read/Write select an output */
    RS_PIN_DIR = 0;                 /* make LCD Register select an output */
#ifdef LCD_POWER_EN_DIR
    LCD_POWER_EN_DIR = 0;           /* make LCD Power enable an output */
#endif
    E_PIN = 0;                      /* set LCD Enable strobe to not active */
    RW_PIN = 0;                     /* set LCD Read/Write select to Write */
    RS_PIN = 0;                     /* set LCD Register select to command group */
    LCD_PORT_OUT &= ~LCD_DATA_BITS; /* set LCD data bits to zero */
#ifdef LCD_POWER_EN
    LCD_POWER_EN = 1;               /* Turn on LCD power */
#endif
    LCD_DelayPOR();                 /* wait for LCD power on to complete */

    /* Force LCD to 8-bit mode */
    LCD_PORT_OUT &= ~LCD_DATA_BITS; /* set LCD data bits to zero */
    LCD_PORT_OUT |= (0b00110011 & LCD_DATA_BITS);
    LCD_E_Pulse();
    LCD_Delay();
    LCD_E_Pulse();
    LCD_Delay();
    
    /* Set LCD to 4-bit mode */
    LCD_PORT_OUT &= ~LCD_DATA_BITS; /* set LCD data bits to zero */
    LCD_PORT_OUT |= (0b00100010 & LCD_DATA_BITS);
    LCD_E_Pulse();
    LCD_Delay();

    /* Initialize LCD mode */
    LCD_WriteCmd(LCD_FORMAT);

    /*
     * Find position of busy bit.
     * Required when using 4-bit mode.
     */
    LCD_SetDDRamAddr(LINE_ONE+1);
    LCD_Busy();
    RS_PIN = 0;
    LCD_Data = LCD_GetByte();

    if (LCD_Data == 0x01)
    {
        LCD_BusyBit = 0x80;
    }
    else
    {
        if (LCD_Data == 0x10)
        {
            LCD_BusyBit = 0x08;
        }
    }

    /* Turn on display, Setup cursor and blinking */
    LCD_WriteCmd(DOFF & CURSOR_OFF & BLINK_OFF);
    LCD_WriteCmd(DON & CURSOR_OFF & BLINK_OFF);
    LCD_WriteCmd(CLEAR_DISPLAY);
    LCD_WriteCmd(SHIFT_CUR_LEFT);

    /* Initialize the character generator RAM */
    LCD_SetCGRamAddr(0);
    LCD_WriteConstString(CGRAM_Table);
    
    /* Set first position on line one, left most character */
    LCD_SetDDRamAddr(LINE_ONE);
}

void LCD_SetCGRamAddr(unsigned char data)
{
    LCD_Busy();
    RS_PIN = 0;            
    LCD_PutByte(data | 0x40);
}

void LCD_SetDDRamAddr(unsigned char data)
{
    LCD_Busy();
    RS_PIN = 0;
    LCD_PutByte(data | 0x80);
}

void LCD_WriteCmd(unsigned char data)
{
    LCD_Busy();
    RS_PIN = 0;
    LCD_PutByte(data);
}

void LCD_WriteData(unsigned char data)
{
    LCD_Busy();
    RS_PIN = 1;
    LCD_PutByte(data);
    RS_PIN = 0;
}

void LCD_WriteConstString(const unsigned char * prString)
{
    while(*prString)
    {
        LCD_WriteData(*prString);
        prString++;
    }
}

void LCD_WriteString(unsigned char * pString)
{
    while(*pString)
    {
        LCD_WriteData(*pString);
        pString++;
    }
}



#7
Dimitris
Super Member
  • Total Posts : 279
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/10 05:17:16 (permalink)
0
Cant i ovveride-replace an already existing character? 
#8
1and0
Access is Denied
  • Total Posts : 8337
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/10 05:37:58 (permalink)
+1 (1)
dimis1989
Cant i ovveride-replace an already existing character? 

No, you cannot replace the characters encoded as 0x10 to 0xFF. The LCD has only 8 custom characters at any given time; if you change any of these it will update the display too.
#9
Dimitris
Super Member
  • Total Posts : 279
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/10 06:00:47 (permalink)
0
Also how can i define my DATA input-output pins? example in your code you have latd and portd
 
My pins for data are in RC1-data7  RC2-Data6  Rc3-Data5  RC4-Data4 
#10
Gort2015
Klaatu Barada Nikto
  • Total Posts : 2645
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/10 06:05:27 (permalink)
-1 (1)
Here's one in 16bit assembly language.
 
int lcd_cgr(int Start, const char *Data, int Count);
Parameters:
Start: Start character between 0 and 7
Data: The byte data array
Count: How many characters to set
 
i.e. program #2, #3 and #4
lcd_cgr(2, chardata, 3);
 
.include "LCDLib2.inc"
.global _lcd_cgr
.section lcdcode,code
;----------------------------------------------------
.equ arg_Ascii,          w0
.equ arg_pData,        w1
.equ arg_Chars,        w2
.equ tmp,                 w3
.equ pdata,              w5
.equ count,              w8
;rtn error,                w0

_lcd_cgr:  ;int lcd_cgr(int Start, const char *Data, int Count);
    ;check if already opened
    btss    LCD_Flag,#LCDFLAG_OPEN
    retlw   #LCDERROR_NOTOPEN,w0
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cp0     arg_pData
    bra     nz,$+4
    retlw   #LCDERROR_CGINULL,w0
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ;check ascii code
    cp      arg_Ascii,#8
    bra     ltu,$+4
    retlw   #LCDERROR_CGIASCIICODE,w0
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ;check char count
    cp0     arg_Chars
    bra     nz,$+4
    retlw   #LCDERROR_CGICNT,w0
    add        arg_Ascii,arg_Chars,tmp
    cp        tmp,#8
    bra        leu,$+4
    retlw   #LCDERROR_CGIASCIICODE,w0
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ;program cg
    push    count
    mov     arg_pData,pdata
    sl      arg_Chars,#3,count
    sl      arg_Ascii,#3,w0
    add     #LCD_CGRAM,w0
    rcall   _lcd_instruct
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~
loop:
    mov.b   [pdata++],w0
    rcall   _lcd_putcdevice
    dec     count,count
    bra     nz,loop
    pop        count
    retlw   #LCDERROR_OK,w0
;----------------------------------------------------
.end


MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
#11
1and0
Access is Denied
  • Total Posts : 8337
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/10 06:21:35 (permalink)
+1 (1)
dimis1989
Also how can i define my DATA input-output pins? example in your code you have latd and portd
 
My pins for data are in RC1-data7  RC2-Data6  Rc3-Data5  RC4-Data4 

You should had connected the data pins in the proper order. Having your data pins connected in the way you have will only make your code more complicated and less efficient. Now, you can either set each pin individually or reverse reorder the bit order of the data/command byte.
 
Use LATx (if your PIC has it) for output and PORTx for input.
post edited by 1and0 - 2018/03/10 06:26:59
#12
Dimitris
Super Member
  • Total Posts : 279
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/14 02:39:08 (permalink)
0
What lines should i change from cea source for make it work with my pins?
 
Till now i tried to change
 

in header 
#define LCD_DATA_BITS       0x78
#define LCD_PORT_DIR        TRISC
 
in source
#if (LCD_DATA_BITS == 0x78)
 
 
 

#13
Dimitris
Super Member
  • Total Posts : 279
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/14 03:11:43 (permalink)
0
Or how can i send 8 custom characters using my source file? 
I should sent first an lcd command in lcd? and then to write characters in first 4 bit?
#14
Dimitris
Super Member
  • Total Posts : 279
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/14 04:04:46 (permalink)
0
Also how can i select another custom character?http://fab.cba.mit.edu/cl...863.06/11.13/44780.pdf
#15
Dimitris
Super Member
  • Total Posts : 279
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/14 05:14:34 (permalink)
0
Any Suggestion? Sorry i cant't edit, i get error
#16
qɥb
Monolothic Member
  • Total Posts : 3329
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/14 05:31:13 (permalink)
0
You cannot edit posts which contain a live link.
(Microchip didn't do this deliberately, it's a bug in their firewall that they are clueless to fix)
Read more at: How to avoid errors when editing posts
 
Have you got normal text display working on your LCD first?
I still feel that you are totally misunderstanding the whole "custom character" facility, even though multiple people have tried to explain it to you.
You have ONLY eight custom characters. Wherever you place one of the eight custom character codes within your text, it will display one of the eight custom characters.
You've already been told how to write to the RAM which defines each custom character.
Try writing the data for just the first custom character. It will then appear wherever you put the character code 0x00 or 0x08 in your text.
0x08 is more common, because you cannot embed character 0x00 within a C string.
 
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
#17
Dimitris
Super Member
  • Total Posts : 279
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/14 05:37:11 (permalink)
0
Sorry qɥb for the link. 
I have understand that i cant write more than 8 characters in cgram.
The problem is that i dont know how to use it inside my code.
Single test strings work very well. Example LCDPutString("TEST"); IT works perfectly! Also my commands work too.
But i dont know how to read a custom character... I will use same method without quotes?LCDPutString(0x08);???
And how can i write a custom character in cgram?? According to the datasheet I need to use an LCDCommand for my cgram location.
then to write my data and after that to return. Pls qɥb look my uploaded source file! 
#18
qɥb
Monolothic Member
  • Total Posts : 3329
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/14 05:48:52 (permalink)
0
If you wanted the third character to be the first custom character, you would do this
LCDPutString("TE\x08T")
so as I've been saying you just use character code 0x08 instead of an ASCII character.
 
Have a rest, then read the posts above with a clear mind to see how to write to CGRAM to define the characters.
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
#19
Dimitris
Super Member
  • Total Posts : 279
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: LCD 2x16 create custom character 2018/03/14 05:58:24 (permalink)
0
Thank you reading with your example LCDPutString("TE\x08T") works very well! but i'm still misunderstood how can i write just one only character on one cgram location.
 
Example lets say that i want to x08 position character  'θ' 
I need to use LCDCommand with my location and my characters right?
 
This is the easiest example which i found but it doesnt work

const unsigned short MyChar5x8[] = {
0x00, 0x00, 0x0A, 0x1F, 0x1F, 0x0E, 0x04, 0x00}; // Code for char num #0
LCDCommand(0x08);
for (int i = 0; i <= 7 ; i++)
{
LCDPutStr2(MyChar5x8[i]);}
LCDCommand(0);

post edited by dimis1989 - 2018/03/14 06:07:37
#20
Page: 12 > Showing page 1 of 2
Jump to:
© 2018 APG vNext Commercial Version 4.5