#include "ArduinoTrace.h"
#include "ptScheduler.h"
#include "ezButton.h"
ptScheduler Task1Sch=ptScheduler(1000000);
bool T1Start;
ezButton button1(10);
ezButton button2(11);
ezButton button3(12);
byte led0 = 2;
byte led1 = 3;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(led0, OUTPUT);
pinMode(led1, OUTPUT);
button1.setDebounceTime(50);
button2.setDebounceTime(50);
button3.setDebounceTime(50);
}
void loop() {
// put your main code here, to run repeatedly:
if(Task1Sch.call())
{
button1.loop();
button2.loop();
button3.loop();
T1Start = true;
Task1();
}
}
void Task1()
{
enum {null,s1,s2,s3, s4};
static int step=s1;
int pstep=null;
static bool Q0=0; //stored action blue led
bool Q1=1; //continous action red led
while(step!=pstep)
{
pstep=step;
switch(step)
{
case s1:
if(T1Start)
{
T1Start =false;
step=s2;
}
case s2:
if(button1.isPressed())
{
step=s3;
Q0 = 1;
}
break;
case s3:
if(button2.isPressed())
{
Q1=0;
step=s4;
}
break;
case s4:
Q1=0;
if(button3.isPressed())
{
Q0=0;
step=s2;
}
break;
}
}
DUMP(Q0);
DUMP(Q1);
DUMP(millis());
digitalWrite(2,Q0);
digitalWrite(3,Q1);
}