How to underline (indicate) a character on HD44780 LCD without delay() use?

Hi!

I'm building user interface for my project. I didn't use any libraries because the interface is quite simple and decided to code everything on my own. There are plus and minus buttons which increment and decrement variables and a select button which cycles around options.

I want an indicator on the screen showing which variable is currently being changed. My only idea was the cursor() and noCursor() functions but it requires delay(). This is the result:

It looks good (the cursor could stretch on two digits though) but it's unacceptable because of the delay() function which messes recognising buttons press and who knows what else.

To sum up:
Do you have any idea how to mark a certain character on the LCD display? Underline, blink, invert colours? Anything?

Thank you!

I didn't use any libraries because the interface is quite simple and decided to code everything on my own.

Since you have already coded everything else without using a library why do you think you have to use the cursor() and noCursor() functions?

The underline and blink are both handled by the 'Display on/off control' instruction. All you have to do is issue your own version of this instruction and then deal with the required delay using whatever method you used in your other routines.

Don

I didn't use any libraries for interface handling. LCD is controlled with LiquidCrystal.h.

Can you be more specific with your advice?
If I understood correctly, I should create a function based on these function from LiquidCrystal.cpp:

// Turn the display on/off (quickly)
void LiquidCrystal::noDisplay() {
  _displaycontrol &= ~LCD_DISPLAYON;
  command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal::display() {
  _displaycontrol |= LCD_DISPLAYON;
  command(LCD_DISPLAYCONTROL | _displaycontrol);
}

// Turns the underline cursor on/off
void LiquidCrystal::noCursor() {
  _displaycontrol &= ~LCD_CURSORON;
  command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal::cursor() {
  _displaycontrol |= LCD_CURSORON;
  command(LCD_DISPLAYCONTROL | _displaycontrol);
}

// Turn on and off the blinking cursor
void LiquidCrystal::noBlink() {
  _displaycontrol &= ~LCD_BLINKON;
  command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal::blink() {
  _displaycontrol |= LCD_BLINKON;
  command(LCD_DISPLAYCONTROL | _displaycontrol);
}

Correct?

I didn't use any libraries for interface handling. LCD is controlled with LiquidCrystal.h.

That's not the way I interpreted your original post.

Can you be more specific with your advice?

Not really. I was under the impression that you were controlling your LCD using code that you had written that did not involve using the delay() routine and was confused about why you would then consider using cursor() and noCursor().

Don

See my signature.
Use the 'blink without delay' example sketch as a guide.
Remember that if you are not using any delays, your sketch has many, many iterations per second.
It will give you time to have your cursor blink or not.
If you are waiting for any input on those buttons of yours, you must have setup something like that already.
Use another instance like that to have the cursor do as you like.