Flashlight SOS function

This commit is contained in:
Krzysiek Egzmont
2023-10-15 23:54:14 +02:00
parent d7c458839c
commit ec4bec5b1f
3 changed files with 32 additions and 1 deletions

View File

@@ -45,6 +45,7 @@ static void ACTION_FlashLight(void)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
break; break;
case 1: case 1:
case 2:
gFlashLightState++; gFlashLightState++;
break; break;
default: default:

View File

@@ -1447,6 +1447,35 @@ void APP_TimeSlice10ms(void)
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);
else 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;
}
else if(gFlashLightBlinkCounter == next) {
if(c==0) {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
}
else
GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
if(c == 18) {
next += 7*u;
c = 0;
}
else if(c==7 || c==9 || c==11)
next += 3*u;
else
next += u;
c++;
}
}
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
if (gVoxResumeCountdown > 0) if (gVoxResumeCountdown > 0)

3
misc.h
View File

@@ -52,7 +52,8 @@ enum {
enum { enum {
FLASHLIGHT_OFF = 0, FLASHLIGHT_OFF = 0,
FLASHLIGHT_ON, FLASHLIGHT_ON,
FLASHLIGHT_BLINK FLASHLIGHT_BLINK,
FLASHLIGHT_SOS
}; };
enum { enum {