Use 1ms timer and table for scheduling
This commit is contained in:
@@ -3,7 +3,20 @@
|
|||||||
|
|
||||||
int loopCount = 0;
|
int loopCount = 0;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
|
int table[40] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
void perms() {
|
||||||
|
if (table[index] == 1){
|
||||||
|
SwitchControlLibrary().PressButtonA();
|
||||||
|
}
|
||||||
|
if (table[index] == 2){
|
||||||
|
SwitchControlLibrary().ReleaseButtonA();
|
||||||
|
}
|
||||||
|
|
||||||
|
index = (index + 1) % 40;
|
||||||
|
}
|
||||||
|
/*
|
||||||
void button() {
|
void button() {
|
||||||
if (state == 0) {
|
if (state == 0) {
|
||||||
SwitchControlLibrary().PressButtonA();
|
SwitchControlLibrary().PressButtonA();
|
||||||
@@ -14,11 +27,12 @@ void button() {
|
|||||||
state = 0;
|
state = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
SwitchControlLibrary();
|
SwitchControlLibrary();
|
||||||
MsTimer2::set(20, button);
|
MsTimer2::set(1, perms);
|
||||||
MsTimer2::start();
|
MsTimer2::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user