Remove blink and SOS

This commit is contained in:
Armel FAUVEAU
2024-03-21 03:16:34 +01:00
parent b9ecbc48e4
commit 7ed9889ef4
4 changed files with 79 additions and 58 deletions

View File

@@ -210,7 +210,7 @@ ifeq ($(ENABLE_FEAT_F4HWN),1)
VERSION_STRING_1 ?= v0.22 VERSION_STRING_1 ?= v0.22
AUTHOR_STRING_2 ?= F4HWN AUTHOR_STRING_2 ?= F4HWN
VERSION_STRING_2 ?= v2.3 VERSION_STRING_2 ?= v2.4
AUTHOR_STRING ?= $(AUTHOR_STRING_1)+$(AUTHOR_STRING_2) AUTHOR_STRING ?= $(AUTHOR_STRING_1)+$(AUTHOR_STRING_2)
VERSION_STRING ?= $(VERSION_STRING_2) VERSION_STRING ?= $(VERSION_STRING_2)

View File

@@ -1303,8 +1303,10 @@ void APP_TimeSlice10ms(void)
return; return;
#endif #endif
#ifdef ENABLE_FLASHLIGHT #ifndef ENABLE_FEAT_F4HWN
FlashlightTimeSlice(); #ifdef ENABLE_FLASHLIGHT
FlashlightTimeSlice();
#endif
#endif #endif
#ifdef ENABLE_VOX #ifdef ENABLE_VOX

View File

@@ -5,62 +5,79 @@
#include "flashlight.h" #include "flashlight.h"
enum FlashlightMode_t gFlashLightState; #ifndef ENABLE_FEAT_F4HWN
enum FlashlightMode_t gFlashLightState;
void FlashlightTimeSlice() void FlashlightTimeSlice()
{ {
if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) { if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0) {
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
return;
}
if (gFlashLightState == FLASHLIGHT_SOS) {
const uint16_t u = 15;
static uint8_t c;
static uint16_t next;
if (gFlashLightBlinkCounter - next > 7 * u) {
c = 0;
next = gFlashLightBlinkCounter + 1;
return; return;
} }
if (gFlashLightBlinkCounter == next) { if (gFlashLightState == FLASHLIGHT_SOS) {
if (c==0) { const uint16_t u = 15;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); static uint8_t c;
} else { static uint16_t next;
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
if (gFlashLightBlinkCounter - next > 7 * u) {
c = 0;
next = gFlashLightBlinkCounter + 1;
return;
} }
if (c >= 18) { if (gFlashLightBlinkCounter == next) {
next = gFlashLightBlinkCounter + 7 * u; if (c==0) {
c = 0; GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
} else if(c==7 || c==9 || c==11) { } else {
next = gFlashLightBlinkCounter + 3 * u; GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
} else { }
next = gFlashLightBlinkCounter + u;
if (c >= 18) {
next = gFlashLightBlinkCounter + 7 * u;
c = 0;
} else if(c==7 || c==9 || c==11) {
next = gFlashLightBlinkCounter + 3 * u;
} else {
next = gFlashLightBlinkCounter + u;
}
c++;
} }
c++;
} }
} }
}
void ACTION_FlashLight(void) void ACTION_FlashLight(void)
{ {
switch (gFlashLightState) { switch (gFlashLightState) {
case FLASHLIGHT_OFF: case FLASHLIGHT_OFF:
gFlashLightState++; gFlashLightState++;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
break; break;
case FLASHLIGHT_ON: case FLASHLIGHT_ON:
case FLASHLIGHT_BLINK: case FLASHLIGHT_BLINK:
gFlashLightState++; gFlashLightState++;
break; break;
case FLASHLIGHT_SOS: case FLASHLIGHT_SOS:
default: default:
gFlashLightState = 0; gFlashLightState = 0;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
}
} }
} #else
void ACTION_FlashLight(void)
{
static bool gFlashLightState = false;
if(gFlashLightState)
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
}
else
{
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
}
gFlashLightState = (gFlashLightState) ? false : true;
}
#endif
#endif #endif

View File

@@ -5,17 +5,19 @@
#include <stdint.h> #include <stdint.h>
enum FlashlightMode_t { #ifndef ENABLE_FEAT_F4HWN
FLASHLIGHT_OFF = 0, enum FlashlightMode_t {
FLASHLIGHT_ON, FLASHLIGHT_OFF = 0,
FLASHLIGHT_BLINK, FLASHLIGHT_ON,
FLASHLIGHT_SOS FLASHLIGHT_BLINK,
}; FLASHLIGHT_SOS
};
extern enum FlashlightMode_t gFlashLightState; extern enum FlashlightMode_t gFlashLightState;
extern volatile uint16_t gFlashLightBlinkCounter; extern volatile uint16_t gFlashLightBlinkCounter;
void FlashlightTimeSlice(void); void FlashlightTimeSlice(void);
#endif
void ACTION_FlashLight(void); void ACTION_FlashLight(void);
#endif #endif