/* 孤独的二进制
   面向对象点灯
   参考:
   https://www.freertos.org/FreeRTOS_Support_Forum_Archive/July_2010/freertos_Is_it_possible_create_freertos_task_in_c_3778071.html
   https://stackoverflow.com/questions/45831114/c-freertos-task-invalid-use-of-non-static-member-function
   https://electronics.stackexchange.com/questions/373793/using-c-objects-within-freertos-tasks
*/
#include "Arduino.h" // automatically added optional
#include "Led.h"

//对象一定要在全局变量中创建
Led ledYellow(26, 2000, "YELLOW");
Led ledRed(27, 300, "RED");
Led ledGreen(33, 1000, "GREEN");

void setup() {
  Serial.begin(115200);
  pinMode(23, INPUT_PULLUP);

  Serial.println("开启任务");
  ledGreen.startFlash();
  ledYellow.startFlash();
  ledRed.startFlash();

}

void loop() {
  if (digitalRead(23) == LOW) {
    Serial.println("删除任务");
    ledGreen.endFlash();
    ledYellow.endFlash();
    ledRed.endFlash();
    delay(1000);
  }
}