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

get data from LCD problem

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



Joined: 14 Mar 2010
Posts: 21

View user's profile Send private message

get data from LCD problem
PostPosted: Thu May 13, 2010 2:41 pm     Reply with quote

i can use the lcd_getc function,but
if i want a 2 digit data, how can i get it?
(using the Flexible LCD driver for 20x4 LCDs)

for example
123456789 < 1 in lcdxy (1,1)

i would like to get 12 , 34 ,56 , 78 into
int8 A1,
int8 A2,
int8 A3,
int8 A4,

A1 = lcd_getc(1,1); <how can i keep get data?
A2 = lcd_getc(3,1);

thank you,
Embarassed
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 13, 2010 3:05 pm     Reply with quote

Since your program wrote the data to the LCD, you should already
know what the data is. You should not have to read it from the LCD.

But, you need to read the data into a 3-byte array. The last byte of
the array must be set to 0x00. Then use atoi() to convert the numeric
string to an integer.
project2010



Joined: 14 Mar 2010
Posts: 21

View user's profile Send private message

PostPosted: Thu May 13, 2010 11:58 pm     Reply with quote

Actually, I'm using the keypad to input some number, and store it.
Use for set the time on DS1307.....so need 2 digits stored in one number....

Confused
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 14, 2010 10:45 am     Reply with quote

See this thread. It goes over the same problem you have: How to
convert two ASCII numbers from a keypad into one integer, and put
it in a variable.
http://www.ccsinfo.com/forum/viewtopic.php?t=42188
project2010



Joined: 14 Mar 2010
Posts: 21

View user's profile Send private message

PostPosted: Sat May 15, 2010 2:46 pm     Reply with quote

Code:

#include<18F4620.h>            //include 18F4620 ports
#device adc=10
#fuses HS,NOWDT,PUT,NOPROTECT,NOLVP,NODEBUG
#use delay(clock=20000000)         //use 20MHz crystal
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#include <LCD20x4.c>
#include <KBD.c>
#include <ds1307.c>
#include <stdlib.h>

char abc[2];
int x;

void main()
{
   lcd_init();

   while(true)
   {
         abc[0]=2;
         abc[1]=5;
         abc[2]=0x00;
   
         x=atoi(abc);
         printf(lcd_putc,"\%u",x);

   }
}


i have try some pattern....but it doesn't work
keep display 0.......... Sad
Ttelmah



Joined: 11 Mar 2010
Posts: 19541

View user's profile Send private message

PostPosted: Sat May 15, 2010 3:03 pm     Reply with quote

abc, is too small. You have allocated two storage locations, and are then addressing three locations....

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 15, 2010 4:48 pm     Reply with quote

Also, you are not loading the array with ASCII values. The atoi() function
expects an ASCII string. In C, to tell the compiler that a number should
be encoded in ASCII, you should put single quotes around the number.
Example:
Code:

abc[0] = '2';

However, don't put quotes around the final 0x00. It must actually be
a binary 0. Keep it the same as shown in your post.
project2010



Joined: 14 Mar 2010
Posts: 21

View user's profile Send private message

PostPosted: Sun May 16, 2010 11:33 am     Reply with quote

Code:

#include<18F4620.h>            //include 18F4620 ports
#device adc=10
#fuses HS,NOWDT,PUT,NOPROTECT,NOLVP,NODEBUG
#use delay(clock=20000000)         //use 20MHz crystal
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#include <LCD20x4.c>
#include <KBD.c>
#include <ds1307.c>
#include <stdlib.h>

int a;

char abc[10];
int x;

void main()
{
   lcd_init();

   while(true)
   {
         int a=8;

         abc[0]='2';
         abc[1]='5';
   
         x=atoi(abc);
         printf(lcd_putc,"\%u",x);

   }
}


it work it can display 25

but how can i put "int a" into "abc[0]"?
Code:
abc[0]="%d",a;
that's does not work ,result become 0

Also is atoi max support 0-255 right?


Last edited by project2010 on Sun May 16, 2010 12:16 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 16, 2010 11:46 am     Reply with quote

1. You ignored Ttelmah's post completely, in which he told you to
increase the size of the abc array.

2. You ignored my example of using single quotes, and changed it to
use double quotes.

Someone else can help on this thread.
project2010



Joined: 14 Mar 2010
Posts: 21

View user's profile Send private message

PostPosted: Sun May 16, 2010 12:18 pm     Reply with quote

PCM programmer wrote:
1. You ignored Ttelmah's post completely, in which he told you to
increase the size of the abc array.

2. You ignored my example of using single quotes, and changed it to
use double quotes.

Someone else can help on this thread.


sorry, i forgot to update the code....
i have read the reply for all guy...Wink
abc[10] increased, use single ' ' < but look like same.
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