Home > Back-end >  Button for help: C program delay the way how to respond?
Button for help: C program delay the way how to respond?

Time:04-02


Turbo C environment, program description:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
While (no button) {
According to string
Sleep (5 minutes)/delay (5 minutes)
Remove the string
Change the screen coordinates
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Requirements, in the absence of key refresh every 5 minutes string, and response button (button to exit),

Is now despite the key, but it must be 5 minutes after the expiration of the time to quit,

CodePudding user response:

A timer to calculate no buttons to press the time cough up, if there are any button press, recalculate the time, if there is no buttons to press the accumulative total 5 min to change according to cough up

CodePudding user response:

Flexible, do not delay for 5 minutes, do delay of 1 second, and then do a variable count, string is brushed again 300 times,

CodePudding user response:

Deprecated sleep (), the delay ()

Cycle time, more time, read the button state at the same time?

CodePudding user response:

refer to the second floor forever74 response:
flexible, do not delay for 5 minutes, do delay of 1 second, and then do a variable count, string is brushed again 300 times,

In 300, the state of the keyboard and read?

CodePudding user response:

Not interrupt handling?

CodePudding user response:

reference 4 floor proof1 response:
Quote: refer to the second floor forever74 response:
flexible, do not delay for 5 minutes, do delay of 1 second, and then do a variable count, string is brushed again 300 times,

In 300, the state of the keyboard and read?

Or the cycle, you how to deal with buttons, after natural or how to deal with,
Just shorten the delay time, add a count variable, more than one or two if

CodePudding user response:

refer to 6th floor forever74 response:
or the cycle, you how to deal with buttons, after natural or how to deal with,
Just shorten the delay time, add a count variable, more than one or two if


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
While (no button) {
Sleep (1 second)
Counter + 1
If (300) counter={
Remove the string
Change the screen coordinates
According to string
Counter=0
}
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Is this?

CodePudding user response:

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
While (the end) {
According to string
for (i=1; i<=300; I++)
If (no button)
Sleep (1 second)
The else
Rear end mark
Remove the string
Change the screen coordinates
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

?????
Some of the long,

CodePudding user response:

Reference:
 the while (1) {

Sleep (1 second) counter + 1
Read key response at any time (a button to exit)
If (300) counter={
Remove the string
Change the screen coordinates
According to string
Counter=0
}
}

CodePudding user response:

Why not use the system API, listening to the case?
  • Related