wgalaugher
Joined: 10 Jan 2011 Posts: 18
|
|
Posted: Wed Sep 14, 2011 3:28 pm |
|
|
I finally got it. I understand most of the code except for this part
Code: |
signed int16 wait_for_number(int16 loopfor)
{
int16 temp=0;
int8 chr;
do {
if (!bkbhit)
{
chr=bgetc();
if (chr>='0' && chr<='9') {
//Have received a number
temp=temp*10;
temp=temp+(chr-'0'); //Add in the digit
}
if (chr=='\r') {
//Have carriage return
return temp;
}
}
delay_us(90);
} while (loopfor--);
return -1L; //flag for 'timeout'
|
I would like to use this code as basis of an input screen and I need to clear the buffer for the next set of numbers. How do I do that so I can input a series of values each followed by a carrage return. |
|