Skip to content

Blink cursor over editing position #40

Closed

Description

@adrianbn

Hopefully this is not already available and I missed it. If so, I apologize.

Is your feature request related to a problem? Please describe.
While editing, the cursor is always at the end of the line being edited.

Describe the solution you'd like
I would like to be able to control the cursor while editing a field to, for instance, make it blink over the position you're editing. As it currently stands the cursor is always at the end of the current line, so turning on blinking does not solve the problem.

Describe alternatives you've considered
I've tried to manually set blinking and to manually move the cursor to the right position. Blinking alone just makes the cursor blink at the end of the line, and trying to manipulate the cursor position accurately without access to the line positioning (row) and the variable in the current line is not possible.

Additional context
Here's a simple editing demo I made that shows how I would like the blinking to work: https://www.youtube.com/watch?v=M6q4AmBr45s
It also shows the cursor on the left, which is a personal preference of mine as well, so if there is an option to change it that I missed please let me know.

Activity

  1. VasilKalchev commented on Nov 1, 2021

    @VasilKalchev
    Owner

    Hello adrianbn,

    This is a nice feature, but because of the way the library works, I don't see an obvious way to implement it.

    I did some testing and it seems that it'll be possible to implement this manually.
    Create a LiquidLine with just a constant string (e.g. "Duration"), don't add other variables to it and don't attach functions to it. When navigating the menu:

    • use LiquidMenu::get_currentScreen() to recognize the screen you're currently on
    • when you're at the right screen, set the cursor position after the string LiquidCrystal::setCursor(9, 0)
    • print the variable and reset the cursor's position to be over the first digit of the variable
    • enable the blinking cursor with LiquidCrystal::cursor(); LiquidCrystal::blink()
    • implement the code from the video that edits the variable digit by digit

    Rough example:

    // ...
    
    LiquidLine duration_line(0, 0, "Duration: ");
    LiquidScreen duration_screen(duration_line);
    
    LiquidMenu menu(lcd, duration_screen);
    
    // ...
    
    void loop() {
      if (btn_right.pressed()) {
        menu.next_screen();
    
        if (menu.get_currentScreen() == &duration_screen) {
          // no need to set the position, since there is just one line on this screen
          lcd.print(5);
          lcd.setCursor(10, 0);
          lcd.cursor();
          lcd.blink();
          // ...
        } else {
          lcd.noCursor();
          lcd.noBlink();
        }
      }
    }
  2. Repository owner locked and limited conversation to collaborators on Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionNeed help using the repository.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions