toggle loop

This commit is contained in:
2020-10-24 19:34:30 +02:00
parent 69dd57fa55
commit 32f3ef93e9

View File

@ -1,5 +1,6 @@
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <PontCoopScheduler.h>
#include <stdlib.h>
@ -41,12 +42,24 @@ void disableLoop(void *handle) {
HAL_GPIO_WritePin(Loop_Disable_GPIO_Port, Loop_Disable_Pin, GPIO_PIN_RESET);
}
void toggleLoop(void *handle) {
static bool state = false;
if (state) {
disableLoop(NULL);
} else {
enableLoop(NULL);
}
state ^= true;
}
void my_setup_2() {
schAdd(blinkRed, NULL, 0, 500);
schAdd(blinkGreen, NULL, 0, 1000);
schAdd(helloWorld, NULL, 0, 5000);
schAdd(enableLoop, NULL, 10000, 0);
schAdd(disableLoop, NULL, 20000, 0);
// schAdd(enableLoop, NULL, 10000, 0);
// schAdd(disableLoop, NULL, 20000, 0);
schAdd(toggleLoop, NULL, 0, 10000);
}
void my_loop() {