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

Flex lcd driver and decimal numbers

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



Joined: 08 Mar 2012
Posts: 38
Location: Canada

View user's profile Send private message

PostPosted: Sun Apr 22, 2012 3:12 pm     Reply with quote

Can this driver be used to properly send decimal numbers to the LCD or will we get errors?
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Mon Apr 23, 2012 1:39 am     Reply with quote

Yes, of course it can.
If used properly....

You need to send the correct ASCII code for the number you want. Fortunately, C allows you to do this by using lcd_putc('1');, (note the single inverted commas)which generates the ASCII code 00110001 (in binary), to display 1. Or if you have a variable, use 'printf', which converts binary numbers to their decimal, octal, or hex digit patterns, according to the format you select.
It wouldn't be much use if you couldn't use it to display numbers...

Best Wishes
wordizlife



Joined: 08 Mar 2012
Posts: 38
Location: Canada

View user's profile Send private message

PostPosted: Tue May 01, 2012 7:14 pm     Reply with quote

Works fine for the numbers now, my problem was with my coding.

Now I am wondering how to get the screen to scroll up or down when needed. Can the lcd_gotoxy function be used for this?
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed May 02, 2012 2:29 am     Reply with quote

Most LCD effectively use a circular buffer.

When you send data to the LCD, the data is stored in RAM. What you see on the display is a window into the RAM. You can then change which data element appears in the top left hand corner of the display. By altering which data element appears in the top left you can achieve scrolling.

An alternative is to simply re-write the entire display.

Mike
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Wed May 02, 2012 2:31 am     Reply with quote

There isn't fundamentally a scroll up/down function in these LCD's.

Gotoxy, sets 'where' your next character will be drawn. Doesn't move the display.

There is a single character shift right/left available, but since the lines of the display are not adjacent in memory, this can't really be used to smoothly scroll up/down. You can send this with the send byte function, and scroll the screen text left/right. It uses codes 0x18, and 0x1C (for the two directions):
lcd_send_byte(0, 0x18); //To scroll left
lcd_send_byte(0, 0x1C); //To scroll right

Normally people do line scrolling by having their messages in a 'table', and just redrawing the required messages one line higher/lower in the window.

Best Wishes
flint



Joined: 05 Jun 2010
Posts: 24
Location: Nigeria

View user's profile Send private message

using flex lcd
PostPosted: Sat May 12, 2012 2:08 am     Reply with quote

Hi everyone!
Please how do i request an input that will be displayed on a 16x2 lcd from a user(assuming i already designed they key pad), and then store the input. I am able to send messages to the screen, but don't know how to do this. Any help, suggestion is welcomed. Thanks
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sat May 12, 2012 3:16 am     Reply with quote

What can't you do?

(1) Read the keypad.
(2) Handle the keypad data.
(3) Deal with user interaction.

Please be more specific.

Mike
flint



Joined: 05 Jun 2010
Posts: 24
Location: Nigeria

View user's profile Send private message

PostPosted: Sat May 12, 2012 3:56 am     Reply with quote

Mike Walne wrote:
What can't you do?

(1) Read the keypad.
(2) Handle the keypad data.
(3) Deal with user interaction.

Please be more specific.

Mike

what i want is for a user to enter a password, then the password is read-in, and used for verification
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sat May 12, 2012 4:54 am     Reply with quote

OK. As always, loads of ways, assuming you have your keypad working. Here's a starter for ten:-

Create const character string "PASSWORD".
Create character string array input_buffer[x] longer than password.

Write prompt to LCD
Code:

 ----------------
|Enter Password  |
|_               |
 ----------------

As user enters characters add each to input_buffer[] but print '*' to LCD
Code:

 ----------------
|Enter Password  |
|****_           |
 ----------------

When user presses <ENTER> add terminating zero to input_buffer[] and test password.

Again, many ways to test password.

(1) 'C' provides string compare functions which could be quick way.
(2) Do char by char compare........
(3) Do compare as characters are entered (may not need input_buffer[]).
(4) Some sort of state machine.
(5) Depends on how many valid passwords you have.
...........................

Mike
flint



Joined: 05 Jun 2010
Posts: 24
Location: Nigeria

View user's profile Send private message

PostPosted: Sat May 12, 2012 5:54 am     Reply with quote

Mike Walne wrote:
OK. As always, loads of ways, assuming you have your keypad working. Here's a starter for ten:-

Create const character string "PASSWORD".
Create character string array input_buffer[x] longer than password.

Write prompt to LCD
Code:

 ----------------
|Enter Password  |
|_               |
 ----------------

As user enters characters add each to input_buffer[] but print '*' to LCD
Code:

 ----------------
|Enter Password  |
|****_           |
 ----------------

When user presses <ENTER> add terminating zero to input_buffer[] and test password.

Again, many ways to test password.

(1) 'C' provides string compare functions which could be quick way.
(2) Do char by char compare........
(3) Do compare as characters are entered (may not need input_buffer[]).
(4) Some sort of state machine.
(5) Depends on how many valid passwords you have.
...........................

Mike

please, can u post a code snippet on how this can be achieved
Thanks so much Mike!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 12, 2012 4:44 pm     Reply with quote

Use the forum's search page to search for: keypad password
Set it to "Search for all terms".

If you did that, you would find threads like this, which have complete
code to enter a password from a keypad:
http://www.ccsinfo.com/forum/viewtopic.php?t=45935

But remember, we don't want to do your complete project for you.
That code only gives you the answer to part of your project.
You need to do the remainder of it.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sat May 12, 2012 4:47 pm     Reply with quote

Quote:

please, can u post a code snippet on how this can be achieved
Thanks so much Mike!

Short answer. No.

This is not a forum for getting others to write code for you.

Many of the guys here charge $$$$ ££££ to cut code.

What we will do, for free, is offer help and advice if you make an effort.

You will learn more by doing it yourself. CCS provides loads of short sample code. Have a play with some.

I've outlined where to start with your specific project. Have a go, when you get stuck, come back to the forum, show us what you've done and somebody will probably offer assistance.

Mike
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 12, 2012 5:01 pm     Reply with quote

Well, it was already in the archives, so I thought I'd give him half of the
answer. But you notice I made it clear that we won't do the whole thing
for him. I am not sure he can even understand the code that I linked for
him.
flint



Joined: 05 Jun 2010
Posts: 24
Location: Nigeria

View user's profile Send private message

PostPosted: Sat May 12, 2012 7:00 pm     Reply with quote

Thanks guys am already on it, if i get stuck i will holla back.
Best regards.
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