diff --git a/cube/User/Inc/show.h b/cube/User/Inc/show.h index 63235e9..fdceda6 100644 --- a/cube/User/Inc/show.h +++ b/cube/User/Inc/show.h @@ -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); diff --git a/cube/User/Src/networkAbstractionLayer.c b/cube/User/Src/networkAbstractionLayer.c index 0d34d31..6e844e5 100644 --- a/cube/User/Src/networkAbstractionLayer.c +++ b/cube/User/Src/networkAbstractionLayer.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -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; diff --git a/cube/User/Src/show.c b/cube/User/Src/show.c index 8b0cddb..8a2359a 100644 --- a/cube/User/Src/show.c +++ b/cube/User/Src/show.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -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); } \ No newline at end of file diff --git a/cube/User/Src/wizHelper.c b/cube/User/Src/wizHelper.c index 281ed96..c7f0aa5 100644 --- a/cube/User/Src/wizHelper.c +++ b/cube/User/Src/wizHelper.c @@ -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"); }