CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

call your own marks using GCRAM 2x16 LCD with PIC? [SOLVED]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

call your own marks using GCRAM 2x16 LCD with PIC? [SOLVED]
PostPosted: Thu Jun 16, 2016 6:30 am     Reply with quote

Hello ,
so I have PIC16F877A controlling 2x16 text LCD display ...

everything works fine I can write to it ... ok normal text...

but when I do my own mark to GCRAM I don't understand how I can call it
to show maybe line 0 character 0 ...

upper line characters are address 0 ... 0x15
and lower line 0x40 ... 0x4F

I made this pattern:

//pattern 5 x 8
// 0B000 00000
// 0B000 00000
// 0B000 11111 (= 31)
// 0B000 11111
// 0B000 11111
// 0B000 11111
// 0B000 00000
// 0B000 00000



my question is how I can use it and call it to LCD display into
some position ?

I don't understand that procedure how to make your own marks
and call them to some place in LCD display.

I'll be very pleased if someone can help me !

best of all to he all !

arto
from finland


Last edited by artohautala on Mon Jun 20, 2016 4:55 am; edited 1 time in total
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Thu Jun 16, 2016 7:07 am     Reply with quote

There are many different displays, some may do it, some may not. Do you know for certain that your display supports that? If so, then the datasheet will tell you how to do it.
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jun 16, 2016 7:25 am     Reply with quote

Code:

//custom characters
//0=off, 1=on
const int8 lcd_custom_chars[] =
{
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000001,
  0b00000011,
  0b00000111,
  0b00001111,
  0b00011111,

  0b00000000,
  0b00000000,
  0b00000000,
  0b00010000,
  0b00011000,
  0b00011100,
  0b00011110,
  0b00011111,

  0b00011111,
  0b00001111,
  0b00000111,
  0b00000011,
  0b00000001,
  0b00000000,
  0b00000000,
  0b00000000,

  0b00011111,
  0b00011110,
  0b00011100,
  0b00011000,
  0b00010000,
  0b00000000,
  0b00000000,
  0b00000000,

  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,

  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,

  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,

  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
};

void lcd_load_custom_chars(void)
{
int8 i;

// Set address counter pointing to CGRAM address 0.
lcd_send_byte(0, 0x40); 

// Load custom lcd character data into CGRAM.
// 8 characters x 8 bytes = 64 bytes total
for(i = 0; i <=63; i++)
   {
    lcd_send_byte(1, lcd_custom_chars[i]);
   }

// Set address counter pointing back to the DDRAM.
lcd_send_byte(0, 0x80);
}




The above code 'snippet' is what I've used to load 8 custom characters into a 4 by 20 LCD module. Most 'LCD units' allow up to 8 user defined characters. In my case the 8 are 'segments' used to make large characters on the 4by20 display

now this...
Code:

void jay3()      //4 row high #3
{
   lcd_gotoxy(x_pos_state+0,1);
     lcd_putc(0);
     lcd_putc(5);
     lcd_putc(5);
     lcd_putc(1);
   lcd_gotoxy(x_pos_state+0,2);
     lcd_putc(7);
     lcd_putc(7);
     lcd_putc(4);
     lcd_putc(3);
   lcd_gotoxy(x_pos_state+0,3);
     lcd_putc(7);
     lcd_putc(7);
     lcd_putc(5);
     lcd_putc(1);
   lcd_gotoxy(x_pos_state+0,4);
     lcd_putc(2);
     lcd_putc(4);
     lcd_putc(4);
     lcd_putc(3);
}

is used to display a BIG '3' on the LCD.
the line
lcd_putc(3);
tells the LCD to display the 'custom character' stored in LCD memory location number 3. Just remember they are from 0 to 7 !

It helps to use binary for the character 'map' as the '1's and '0's show you what the custom character should look like.


Jay
PM me if you want the 'driver'.It might help you understand what's going on.
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Thu Jun 16, 2016 7:46 am     Reply with quote

temtronic wrote:
Code:

//custom characters
//0=off, 1=on
const int8 lcd_custom_chars[] =
{
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000001,
  0b00000011,
  0b00000111,
  0b00001111,
  0b00011111,

  0b00000000,
  0b00000000,
  0b00000000,
  0b00010000,
  0b00011000,
  0b00011100,
  0b00011110,
  0b00011111,

  0b00011111,
  0b00001111,
  0b00000111,
  0b00000011,
  0b00000001,
  0b00000000,
  0b00000000,
  0b00000000,

  0b00011111,
  0b00011110,
  0b00011100,
  0b00011000,
  0b00010000,
  0b00000000,
  0b00000000,
  0b00000000,

  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,

  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,

  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,

  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
};

void lcd_load_custom_chars(void)
{
int8 i;

// Set address counter pointing to CGRAM address 0.
lcd_send_byte(0, 0x40); 

// Load custom lcd character data into CGRAM.
// 8 characters x 8 bytes = 64 bytes total
for(i = 0; i <=63; i++)
   {
    lcd_send_byte(1, lcd_custom_chars[i]);
   }

// Set address counter pointing back to the DDRAM.
lcd_send_byte(0, 0x80);
}




The above code 'snippet' is what I've used to load 8 custom characters into a 4 by 20 LCD module. Most 'LCD units' allow up to 8 user defined characters. In my case the 8 are 'segments' used to make large characters on the 4by20 display

now this...
Code:

void jay3()      //4 row high #3
{
   lcd_gotoxy(x_pos_state+0,1);
     lcd_putc(0);
     lcd_putc(5);
     lcd_putc(5);
     lcd_putc(1);
   lcd_gotoxy(x_pos_state+0,2);
     lcd_putc(7);
     lcd_putc(7);
     lcd_putc(4);
     lcd_putc(3);
   lcd_gotoxy(x_pos_state+0,3);
     lcd_putc(7);
     lcd_putc(7);
     lcd_putc(5);
     lcd_putc(1);
   lcd_gotoxy(x_pos_state+0,4);
     lcd_putc(2);
     lcd_putc(4);
     lcd_putc(4);
     lcd_putc(3);
}

is used to display a BIG '3' on the LCD.
the line
lcd_putc(3);
tells the LCD to display the 'custom character' stored in LCD memory location number 3. Just remember they are from 0 to 7 !

It helps to use binary for the character 'map' as the '1's and '0's show you what the custom character should look like.


Jay
PM me if you want the 'driver'.It might help you understand what's going on.


OK so I understand there is custom characters 0...7

and they are loaded 0...63 CGRAM to those addressis...
<PM me if you want the 'driver'.It might help you understand what's going on>

that would help ...
but I do not understand how to call my customized characters into LCD
example row 0 character 0 ... ?

thank for your patience and good advice ...

-arto-
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jun 16, 2016 7:54 am     Reply with quote

...
lcd_goto(1,1);
lcd_putc(3);
...

Will display the 3rd 'custom character' at the LCD screen positon of line 1, first position.

Jay
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Thu Jun 16, 2016 8:37 am     Reply with quote

temtronic wrote:
...
lcd_goto(1,1);
lcd_putc(3);
...

Will display the 3rd 'custom character' at the LCD screen positon of line 1, first position.

Jay


Thank's for your answer ...

is it so that I have to write my custom marks to memory 0 ...to 7
and then read my custom marks and then send them to memory 0x40
if first line first character ?

sorry my missing brains ...


-arto-
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jun 16, 2016 8:43 am     Reply with quote

yes...
just start with a simple program,
maybe copy/paste my code 'chunks' into a small program( you'll need the
LCD driver of course though you must have that working..

small steps.... and then the 'light' will come on !!

Jay
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Thu Jun 16, 2016 9:10 am     Reply with quote

temtronic wrote:
yes...
just start with a simple program,
maybe copy/paste my code 'chunks' into a small program( you'll need the
LCD driver of course though you must have that working..

small steps.... and then the 'light' will come on !!

Jay


Thank you so much ... I can write strings to my LCD dislay very well ...

(I have 4 bits connection ... to my LCD display... it works well)

So I have to store my custom pattern to LCD memory locations 0... 7
and then read my custom pattern and send it to location 0x40 if I want it
to see in location row 0 character 0 in my LCD

< small steps.... and then the 'light' will come on !!>

this is very good advice to do
Razz
YEAH

all the best for you

-arto-
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Sun Jun 19, 2016 9:48 am     Reply with quote

temtronic wrote:
yes...
just start with a simple program,
maybe copy/paste my code 'chunks' into a small program( you'll need the
LCD driver of course though you must have that working..

small steps.... and then the 'light' will come on !!

Jay

HI,

I have tried everything but still I don't understand how it works ...

I can not call those custom characters ... right way ... when I call them there's
mismatchs in LCD display ... and I do not know how to call my custom characters...
Code:

const int8 lcd_custom_chars[] =
{
 
  //this balk
  0b00000000,
  0b00000000,
  0B00011111,                               
  0B00011111,
  0B00011111,
  0B00011111, 
  0b00000000,
  0b00000000,
 
 
  0b00000000,
  0b00000000,
  0b00000000,
  0b00010000,
  0b00011000,
  0b00011100,
  0b00011110,
  0b00011111,

  0b00011111,
  0b00001111,
  0b00000111,
  0b00000011,
  0b00000001,
  0b00000000,
  0b00000000,
  0b00000000,

  0b00011111,
  0b00011110,
  0b00011100,
  0b00011000,
  0b00010000,
  0b00000000,
  0b00000000,
  0b00000000,

  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,

  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,

  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,
  0b00011111,

  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
  0b00000000,
};       
     
  int8 i;

      // Load custom lcd character data into CGRAM.
      // 8 characters x 8 bytes = 64 bytes total
     
      //data write, cursor auto increment:// Set address counter pointing to CGRAM address 0:
     
      output_low(RS);
     
      PORTD = 0B10000000;      //MSB first
      enable_lcd();
      PORTD = 0B00000000;     
      enable_lcd();     
       
       output_high(RS);     
     
      for(i = 0; i <=63; i++){
         
          //lcd_send_byte(1, lcd_custom_chars[i]);
         
          PORTD = lcd_custom_chars[i];                     //MSB first     
          enable_lcd();     
         
          PORTD = lcd_custom_chars[i] <<=4 ;               //then LSB       
          enable_lcd();               
      }

      // Set address counter pointing back to the DDRAM address 0B10000000:
     
      output_low(RS);
     
      PORTD = 0B10000000;      //MSB first
      enable_lcd();
      PORTD = 0B00000000;     
      enable_lcd();     
     
}

So I copy/paste this but I do not know how TO CALL it right way ...

My functions show_mark() and show_text() works OK ... in LCD screen ...

But I don't understand how I can call my custom characters to right place in LCD ?

pls help me !

-arto-
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 19, 2016 11:15 am     Reply with quote

This thread has examples of how to do it:
http://www.ccsinfo.com/forum/viewtopic.php?t=40565
Ttelmah



Joined: 11 Mar 2010
Posts: 19339

View user's profile Send private message

PostPosted: Sun Jun 19, 2016 11:39 am     Reply with quote

and, understand the custom characters are just another character, so you position then with lcd_goto, just as for any other character. Smile
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 20, 2016 4:49 am     Reply with quote

Ttelmah wrote:
and, understand the custom characters are just another character, so you position then with lcd_goto, just as for any other character. Smile


HI,
problem SOLVED! now it works fine !

Thank you very much for your good advice and patience Razz

all the best !

-arto-
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 20, 2016 4:50 am     Reply with quote

PCM programmer wrote:
This thread has examples of how to do it:
http://www.ccsinfo.com/forum/viewtopic.php?t=40565


HI,
problem SOLVED! now it works fine !

Thank you very much for your good advice and patience Razz

all the best !

-arto-
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 20, 2016 4:52 am     Reply with quote

temtronic wrote:
yes...
just start with a simple program,
maybe copy/paste my code 'chunks' into a small program( you'll need the
LCD driver of course though you must have that working..

small steps.... and then the 'light' will come on !!

Jay


HI,
problem SOLVED! now it works fine !

Thank you very much for your good advice and patience Razz

all the best !

-arto-
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group