I have the problem that if I jump into a function - for example functionA() I want to check for another character and this only gets recognized if Im done with this functionA(). Of Course I can use another kbhit() inside the functionA() but inside a are much more other functions which for example drive a stepper motor and if i use kbhit() everywhere inside its very confusing.
Is there a better way to solf this?
Code:
while(true)
{
if (kbhit()) getc(var)
else
{
if (var=='A') {functionA()}
if (var=='B') {functionB()}
if (var=='C') {functionC()}
}
}
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
Posted: Wed Jun 13, 2007 6:19 am
This is what interrupts are for.
You fill a buffer with incoming data in an interrupt service routine, and check the buffer's contents in the main code.
There are plenty of examples (here and elsewhere) how to do it.
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