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 CCS Technical Support

command to move the Cursor up down in LCD and to save data

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



Joined: 20 May 2014
Posts: 21

View user's profile Send private message

command to move the Cursor up down in LCD and to save data
PostPosted: Thu Jun 05, 2014 5:45 am     Reply with quote

Anyone pls suggest me the command for moving the cursor up & down in LCD for 16F877a and to select and save data in LCD memory.
_________________
e-learner
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Thu Jun 05, 2014 6:36 am     Reply with quote

Code:
void cursor_up( void)
{
   // add your own code here
   //etc ..

}

cursor_down()
{
   // add your own code here
   //etc ..

}
jeremiah



Joined: 20 Jul 2010
Posts: 1358

View user's profile Send private message

PostPosted: Thu Jun 05, 2014 7:24 am     Reply with quote

To add to this, most LCD's that I have worked with didn't have an up/down cursor command. What I had to do:

1. Generate methods that set the exact position of the cursor of the LCD using a coordinate system (X,Y). As an example, the point 0,0 would be the upper left corner (first position, first line) of the screen. Alternately, there are a lot of good LCD drivers in the code library (flex_lcd for example) that already provide such a function.

2. Generate a go up / down function that used the function from #1 to set the cursor one line higher/lower than what it currently was. Depending on your LCD and the driver you use for it, you either have to keep track of the current position yourself or the driver has a function that provides that info to make this easier. So for example, if the current position (X,Y) is (8,1) and I wanted to move "up", I would set the new position to (8,0), remembering that the top line is "line 0".
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Thu Jun 05, 2014 8:08 am     Reply with quote

It all depends....

Assuming you are talking about a 'standard' text LCD.

For flex_lcd:

If you are running the LCD using the six wire interface, then reading data is not possible.

If you have the cursor enabled, then LCD_GOTOXY, will move the cursor anywhere you want. However there is no direct 'knowledge' of where you are on a line, so you'd have to add your own count to keep track of this.

The LCD_READ_BYTE function returns the byte at the current selected address. You can goto xy, and then read the bytes at this location.

However all such operations are relatively slow. Given the small amount of data on an LCD, it is much simpler to just keep a copy locally in RAM of what you send to the LCD.
e-learner



Joined: 20 May 2014
Posts: 21

View user's profile Send private message

RE:
PostPosted: Thu Jun 05, 2014 11:40 pm     Reply with quote

Thanks for your reply guys,
But i came to know lcd_goto(x,y) will go to specific position in LCD,
lcd_get(x,y) will return the specific position of the cursor in LCD when i read several examples. What i exactly need is when i press a button increment it should goes up one position and again, if decrement should goes down one position and again, when i press save button it should go to the enter mode of LCD. So i am afraid whether lcd_goto(x,y) command alone can help me?

Hope you all understand my need.
_________________
e-learner
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Fri Jun 06, 2014 2:00 am     Reply with quote

You are missing the point.

It all depends on what your LCD does.

Now the standard 'text' LCD's, don't actually 'have' a cursor position, available for you to read. If you want one, you'd have to generate it yourself. So add code to the putc routine, so it increments a column counter whenever a character is sent, update a row counter when a line feed is seen etc. etc..
The reason there is not a function to do what you want, is these displays don't offer this ability, so you'd have to do it yourself.
There is a command to move the cursor one character right, or left (which is what is used to handle the 'backspace'), but nothing to move it to the second line.
There is no command to 'read back' the current RAM address being used. You can only set it.
You have to work within the limitations of the hardware.

However it is mundanely simple to add your own wrappers to the functions to keep track of 'where' you are, and to keep a copy of what is being sent locally. The only reason it is not done, is that for 99.9999% of users it would be wasted code.
After all _you_ know what you are sending to the display. Nothing appears there without commands from your processor, so bothering to try to read back etc., is just wasted effort....

There have been several examples posted here of generating menu systems on text LCD's without any need for anything beyond the existing functions. A search should find a lot of examples. Classic would be to have your cursor sitting on the top right menu selection, and then you know when a 'down arrow' is selected, to simply move to the bottom right selection. If you are on a right selection and left arrow is pushed, then you move to the left selection. _You_ know where you have put the cursor, so _you_ know where to move it to. No 'readback' needed.
In most cases, people don't even use the LCD cursor at all (I don't). Instead you have the text for the 'menu' entries, and on the 'selected' one alternately send the text, and spaces, so the whole item flashes, perhaps once per second. Much clearer, and this then is the 'cursor' for what is happening.
e-learner



Joined: 20 May 2014
Posts: 21

View user's profile Send private message

RE:
PostPosted: Fri Jun 06, 2014 2:36 am     Reply with quote

ok Ttelmah thank you, i got it that there is no straight function for cursor movement up, down in text lcd's and for entry mode also, and i have to generate my own routine for it...
_________________
e-learner
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