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

LCD Module - Blinking Cursor or Underline Cursor

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



Joined: 20 Aug 2006
Posts: 12

View user's profile Send private message

LCD Module - Blinking Cursor or Underline Cursor
PostPosted: Fri Jun 29, 2007 7:46 am     Reply with quote

Does anyone know how to turn on a flashing cursor or underline cursor on a standard HD44780 type LCD module? Is there a command that I can send to the LCD module to turn it on and off? With the cursor flashing or underline on, you would still be able to display a character at that position.

What I am trying to do is have the user press buttons to scroll through a parameter setting that is three digit. I don't want them to wait forever to go from 1 to 250. I want them to press a button to move the cursor to the right, then press the up button (no more than 10 times) to cycle through the values of 0-9, then press a button to move the cursor to the right again and do the same for the next digit. And so on... Then, they will press another button to 'save' the value (which I store in the EEPROM of the PIC).

Thanks in advance.

Boyd
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Fri Jun 29, 2007 8:04 am     Reply with quote

Hello,

In the driver LCD.C you have that initializations,
Code:

BYTE const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};
                             // These bytes need to be sent to the LCD
                             // to start it up.
};


I added these lines just after:
Code:

#define LCD_BLINK   0
#define LCD_CURSOR  1
#define LCD_ONOFF   2
int8 LCD_FUNCTION  = LCD_INIT_STRING[1] ;


In my code i use this function for cursor on or Off
Code:

void cursorOnOff(int8 OnOff) {
  #bit LCD_CURSOR_BIT = LCD_FUNCTION.LCD_CURSOR // 1
  LCD_CURSOR_BIT = OnOff ;
  lcd_send_byte ( 0, LCD_FUNCTION );
  delay_us (50);           
}



cursorOnOff(1); for cursor on

It easy to make a similar function for blink cursor or lcd On/Off.

dro.
_________________
in médio virtus
BoydNielsen



Joined: 20 Aug 2006
Posts: 12

View user's profile Send private message

LCD Module - Blinking Cursor or Underline Cursor
PostPosted: Fri Jun 29, 2007 2:01 pm     Reply with quote

Thanks. It looks simple enough. Sometimes I miss the obvious. I'll try it over the weekend and post my results.

Boyd
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Sat Jun 30, 2007 1:46 am     Reply with quote

Hello,

Now i have more time to explain a few better.
The LCD controleur understand some 'instructions' for configuration or behavior.
DB4 is the "display, underline cursor , and blinking of cursor" control bit.

When DB4 is set :
DB0 is for "blinking of cursor on/off"
DB1 is for "underline cursor on/off"
DB2 is for "display on/off"

In my code, first , i save LCD_INIT_STRING[1] into LCD_FUNCTION for keep previous configuration.

After, it is simple to change the bit you need (DB0, DB1 or DB2).

A very simple way can be :

for start "blinking of cursor " : set bit 0 of LCD_FUNCTION then send the command to the LCD.

As:
Code:
bit_set(LCD_FUNCTION, 0);
lcd_send_byte ( 0, LCD_FUNCTION );


for start underline cursor,
Code:
bit_set(LCD_FUNCTION, 1);
lcd_send_byte ( 0, LCD_FUNCTION );


for stop underline cursor,
Code:
bit_clear(LCD_FUNCTION, 1);
lcd_send_byte ( 0, LCD_FUNCTION );


Now, i hope that my explanations are more clear.

dro.
_________________
in médio virtus
BoydNielsen



Joined: 20 Aug 2006
Posts: 12

View user's profile Send private message

LCD Module - Blinking Cursor or Underline Cursor
PostPosted: Tue Jul 03, 2007 9:33 am     Reply with quote

dro,

Okay, as I understand it (and after re-reviewing the datasheet again), to control the display ON/OFF, underline cursor, or blinking; I must set the DB0, DB1, or DB2 data bits high while holding the DB4 data bit line high. However, if I am running the LCD Module in the 4-bit interface data mode, I do not have DB3..DB0 lines connected. Does this mean that I cannot use these commands in 4-bit interface mode? Or, am I missing something here conceptually?

Boyd
Ttelmah
Guest







PostPosted: Tue Jul 03, 2007 9:47 am     Reply with quote

When you are in '4bit' mode, you still send 8bit commands. They are just sent DB4 to DB7 in the first transfer, and DB0 to DB3 in the second. The display on/off control, is still available to you (in fact it is _essential_, since it has to be sent to initialise the display...).
If you look at the lcd_init command, the second byte from the LCD_INIT_STRING, is the DISON/OFF command, which by default (0xC), says display on, cursor off, no blink.
If you just try changing this to 0xF you will find you have a blinking cursor. Obviously, you can use the lcd_send_byte command to change this latter, but this will show how it is done.

Best Wishes
BoydNielsen



Joined: 20 Aug 2006
Posts: 12

View user's profile Send private message

LCD Module - Blinking Cursor or Underline Cursor
PostPosted: Tue Jul 03, 2007 10:04 am     Reply with quote

Thanks. I knew I was missing something basic here -- of course you have to be able to initialize the display (what was I thinking!). This helps me immensely.

Boyd
BoydNielsen



Joined: 20 Aug 2006
Posts: 12

View user's profile Send private message

LCD Module - Blinking Cursor or Underline Cursor
PostPosted: Wed Jul 04, 2007 10:01 am     Reply with quote

Well, I finally got a chance to test the suggestions provided. It works great.

I use the "flex_lcd.c" driver (vice the "lcd.c" driver provided directly from CCS). I inserted the suggested code from inservi's 29 June 2007 9:04 am post. Then added the following three functions into the "flex_lcd.c" driver:
Code:
//---------------------------------------------------------------
void lcd_blink_OnOff(int8 OnOff)
{
   #BIT  LCD_CURSOR_BIT = LCD_FUNCTION.LCD_BLINK   // 0
   LCD_CURSOR_BIT = OnOff;
   lcd_send_byte (0,LCD_FUNCTION);
   delay_us (50);
}

//---------------------------------------------------------------
void lcd_cursor_OnOff(int8 OnOff)
{
   #BIT  LCD_CURSOR_BIT = LCD_FUNCTION.LCD_CURSOR  // 1
   LCD_CURSOR_BIT = OnOff;
   lcd_send_byte (0,LCD_FUNCTION);
   delay_us (50);
}

//---------------------------------------------------------------
void lcd_display_OnOff(int8 OnOff)
{
   #BIT  LCD_CURSOR_BIT = LCD_FUNCTION.LCD_ONOFF  // 2
   LCD_CURSOR_BIT = OnOff;
   lcd_send_byte (0,LCD_FUNCTION);
   delay_us (50);
}


Now, whenever I want to toggle the cursor, blinking, or LCD display, it is easily available.

Thank you to both inservi and Ttelmah for your help.

Ciao...
bubblebeez
Guest







PostPosted: Tue Jul 24, 2007 3:42 am     Reply with quote

Hi I have read the post and what's on it is all for assembly coding. I want to do the same thing but using c language. Is it possible? Please help im really at lost... Sad
Ttelmah
Guest







PostPosted: Tue Jul 24, 2007 4:16 am     Reply with quote

bubblebeez wrote:
Hi I have read the post and what's on it is all for assembly coding. I want to do the same thing but using c language. Is it possible? Please help im really at lost... Sad

Er. What is posted, _is_ 'C', not assembler....
There has not been a single line of assembler posted in this thread.

Best Wishes
bubblebeez
Guest







PostPosted: Thu Jul 26, 2007 12:36 am     Reply with quote

Embarassed ops sry ...
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