K2 press, execute a program 2, and press it again, termination procedure 2
The program 1 2 as modular custom function, is called the main function,
Seek expert advice,
CodePudding user response:
The simplest is to set up a state, judge state of start-stop,CodePudding user response:
Such as 1/f, define a bool variable allowed/prohibited subroutine, bool variable values according to the key change,CodePudding user response:
/===========================================================
//the following are just some theory, specific analysis
//if the module is infinite loop execution need to use the timer
//if there is any doubt welcome communication: 395233700
//on April 18, 2019 14:17:09
//===========================================================
Void openmodule_1 ();//open the module 1
Void closemodule_1 ();//close the module 1
Void openmodule_2 ();//open the module 2
Void closemodule_2 ();//close the module 2
Char checkkey ();//test button module
Int main ()
{
//the definition of local variable table
Char keyvalue;//save access to key information
Bool key1state;//save the state of the button 1
Bool key2state;//save the state of the button 2
//local variable initialization
Key1state=0;
Key2state=0;
Keyvalue=(https://bbs.csdn.net/topics/checkkey);//get key information
If (keyvalue key1=https://bbs.csdn.net/topics/=)//value judgment buttons
{
If (key1state==0)
{
Openmodule_1 ();//open the module
}
The else
{
Closemodule_1 ();//close the module
}
Key1state=! Key1state;//button press change state
}
Else if (keyvalue=key2 https://bbs.csdn.net/topics/=//value judgment buttons
{
If (key1state==0)
{
Openmodule_2 ();//open the module
}
The else
{
Closemodule_2 ();//close the module
}
Key2state=! Key2state;//button press change state
}
}