View previous topic :: View next topic |
Author |
Message |
wordizlife
Joined: 08 Mar 2012 Posts: 38 Location: Canada
|
|
Posted: Sun Apr 22, 2012 3:12 pm |
|
|
Can this driver be used to properly send decimal numbers to the LCD or will we get errors? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Mon Apr 23, 2012 1:39 am |
|
|
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
|
|
Posted: Tue May 01, 2012 7:14 pm |
|
|
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
|
|
Posted: Wed May 02, 2012 2:29 am |
|
|
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: 19552
|
|
Posted: Wed May 02, 2012 2:31 am |
|
|
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
|
using flex lcd |
Posted: Sat May 12, 2012 2:08 am |
|
|
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
|
|
Posted: Sat May 12, 2012 3:16 am |
|
|
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
|
|
Posted: Sat May 12, 2012 3:56 am |
|
|
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
|
|
Posted: Sat May 12, 2012 4:54 am |
|
|
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
|
|
Posted: Sat May 12, 2012 5:54 am |
|
|
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
|
|
Posted: Sat May 12, 2012 4:44 pm |
|
|
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
|
|
Posted: Sat May 12, 2012 4:47 pm |
|
|
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
|
|
Posted: Sat May 12, 2012 5:01 pm |
|
|
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
|
|
Posted: Sat May 12, 2012 7:00 pm |
|
|
Thanks guys am already on it, if i get stuck i will holla back.
Best regards. |
|
|
|