better blink

This commit is contained in:
2021-03-03 19:16:22 +01:00
parent fe1bc101a3
commit 6611220851
4 changed files with 18 additions and 3 deletions

View File

@ -1,6 +1,7 @@
#include <main.h>
#include <show.h>
#include <PontCoopScheduler.h>
#include <show.h>
#include <stdint.h>
#include <stdlib.h>
@ -24,9 +25,20 @@ showElement_t showElement[] = {
};
static void showHandler(void *handle) {
const uint8_t MAX_CNT = 3;
static uint8_t cnt = 0;
cnt += 1;
if (cnt > MAX_CNT) {
cnt = 0;
}
uint8_t idx = 0;
while (showElement[idx].port) {
if (showElement[idx].currentState == BLINK) {
if (cnt == MAX_CNT) {
HAL_GPIO_TogglePin(showElement[idx].port, showElement[idx].pin);
}
} else if (showElement[idx].currentState == BLINK_FAST) {
HAL_GPIO_TogglePin(showElement[idx].port, showElement[idx].pin);
}
idx++;
@ -43,5 +55,5 @@ void show(signalPin_t signalPin, signalAction_t action) {
}
void showInit() {
schAdd(showHandler, NULL, 0, 250);
schAdd(showHandler, NULL, 0, 100);
}