Hi Everyone,
I have a odd problem on a Terminal program I've written. The program waits for enter to be pressed then counts down from 10 to 0. The odd bit is that when teh user next hits a key, that key is displayed on screen.
The code is this...
#include "mbed.h"
#include "Terminal.h"
Terminal term(USBTX, USBRX); //Info transmitted to hypertermal via USB
int Flag=0, Count=10;
void Countdown(void){
if(Flag==1){
Count--;
if(Count<=0){
Flag=0; //Turn off Flag when Count reaches 0.
}
term.locate(18,6);
term.printf("%d ",Count);
}
}
int main() {
Ticker Timer_100ms;
Timer_100ms.attach(&Countdown, 0.1); //Call Profile every 0.1 seconds
term.cls(); //Clear the screen
term.locate(18,5);
term.printf("Count: %d ",Count);
while(1){
int Key=term.getc(); //Get the key pressed
if(Key==0x0D){ //See if it was ENTER
Flag=1;
}
}
}
Does anyone know why this occurs?
Thanks, Martin
Hi Everyone,
I have a odd problem on a Terminal program I've written. The program waits for enter to be pressed then counts down from 10 to 0. The odd bit is that when teh user next hits a key, that key is displayed on screen.
The code is this...
#include "mbed.h"
#include "Terminal.h"
Terminal term(USBTX, USBRX); //Info transmitted to hypertermal via USB
int Flag=0, Count=10;
void Countdown(void){
if(Flag==1){
Count--;
if(Count<=0){
Flag=0; //Turn off Flag when Count reaches 0.
}
term.locate(18,6);
term.printf("%d ",Count);
}
}
int main() {
Ticker Timer_100ms;
Timer_100ms.attach(&Countdown, 0.1); //Call Profile every 0.1 seconds
term.cls(); //Clear the screen
term.locate(18,5);
term.printf("Count: %d ",Count);
while(1){
int Key=term.getc(); //Get the key pressed
if(Key==0x0D){ //See if it was ENTER
Flag=1;
}
}
}
Does anyone know why this occurs?
Thanks, Martin