Go Down

Topic: Cursor position after lcd.print() and lcd.scrollDisplayLeft() (Read 2967 times) previous topic - next topic

rwiens

After re-reading Don's explanation of what's happening behind the scrollDisplayLeft() function, it is clear the HD44780 is not doing any actual memory manipulation, simply changing the memory pointer for where the display gets its data.  It looks to me like autoscroll() does the same thing.

If so, then no matter what I do I am going to end up having to do my own 'shift' code since my 'string of strings' will always be longer than 40 characters.  I was hoping to take advantage of the built-in functionality to just shift everything one position to the left and write the new character to the end, but from what I can tell (from the link Don previously provided: http://www.geocities.com/dinceraydin/lcd/commands.htm, plus looking at the library and data sheet) there are no HD44780 commands that manipulate the memory (i.e. move data from one location to another) at all.

Richard

ligeracastra

I'm new to arduino and LCDs as well.. I wanna ask if I have to always use setCursor if I want to print messages on the same line.. For instance, I want to print "WATER LEVEL:80%", but the 80 part is a variable(named level) that depends on an input.. I can't remember what language allows you to print it like this: ("WATER LEVEL: " & level & "%"), but is it possible on arduino with the LCD library? or do I have to print them one by one, for example lcd.print("WATER LEVEL: ") then lcd.print(level) then lcd.print("%")? If it's the latter, do I have to set the cursor in between prints? where does the cursor go after printing? thanks in advance..

floresta

Things will be easier to figure out if you understand how the display works.

The cursor starts out at (0,0) but you can change that by positioning the cursor wherever you want.

The after you write a character the cursor automatically increments to point to the next memory location.  This is also the next position on the display if you have a 40x2 display.  Follow the LCD Addressing link at http://web.alfredstate.edu/weimandn for information about the other display configurations.

Once a character is displayed it will remain there until overwritten (or cleared by overwriting with a [space]).

So - what I would do is:
(1) Initially display the string "WATER LEVEL:        %".  Do this in setup() since it only has to be displayed once.
(2) Each time you want to display a new value for 'level' you would position the cursor after the colon and print your value.  Do this in loop() because the information is changing.
(3) If your values are likely to shrink (from three digits to two for example) then you have to get a little more creative and you would:
  (a) position the cursor
  (b) write spaces to cover up the old value
  (c) reposition the cursor
  (d) write your new value.

It's easier to do than to explain.


Don



ligeracastra

Thank you very much Don! that's exactly what I need to know! :D Although I can't just put that on setup() since the user must have an option to change the minimum water level, which means I have to print out a new message. The "WATER LEVEL:  %" is printed to monitor the current level and it must be printed again after adjusting the minimum level, hence, it must be on loop(). I never thought of combining "WATER LEVEL:" and "%", so thanks a lot for that. That'll make my program shorter. awesome. :D

Go Up