better blink
This commit is contained in:
@ -12,7 +12,7 @@ typedef enum {
|
||||
LED_BLUE
|
||||
} signalPin_t;
|
||||
|
||||
typedef enum { ON, OFF, TOGGLE, BLINK } signalAction_t;
|
||||
typedef enum { ON, OFF, TOGGLE, BLINK, BLINK_FAST } signalAction_t;
|
||||
|
||||
void showInit();
|
||||
void show(signalPin_t signalPin, signalAction_t action);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <iwdg.h>
|
||||
#include <logger.h>
|
||||
#include <sinkStruct.h>
|
||||
#include <show.h>
|
||||
#include <config.h>
|
||||
|
||||
#include <networkAbstractionLayer_impl.h>
|
||||
@ -28,6 +29,7 @@ static void networkSecondsHandler(void *handle) {
|
||||
seconds.seconds = tmpSeconds;
|
||||
seconds.missedUpdates = 0;
|
||||
seconds.valid = true;
|
||||
show(LED_GREEN, ON);
|
||||
} else {
|
||||
coloredMsg(LOG_YELLOW, "nsh, failed");
|
||||
seconds.missedUpdates += 1;
|
||||
@ -39,6 +41,7 @@ static void networkSecondsHandler(void *handle) {
|
||||
coloredMsg(LOG_YELLOW, "nsh, success, network time is %lu", tmpSeconds);
|
||||
seconds.missedUpdates = 0;
|
||||
tryAgain = false;
|
||||
show(LED_GREEN, ON);
|
||||
if (seconds.seconds != tmpSeconds) {
|
||||
coloredMsg(LOG_YELLOW, "nsh, local time updated");
|
||||
seconds.seconds = tmpSeconds;
|
||||
|
@ -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);
|
||||
}
|
@ -86,7 +86,7 @@ static void wizDHCPAssign() {
|
||||
coloredMsg(LOG_BLUE, "wizda, set netinfo again");
|
||||
|
||||
networkAvailable = true;
|
||||
show(LED_GREEN, ON);
|
||||
show(LED_GREEN, BLINK_FAST);
|
||||
coloredMsg(LOG_BLUE, "wizda, network is available");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user