Skip to content

Commit

Permalink
Flashlight SOS function
Browse files Browse the repository at this point in the history
  • Loading branch information
egzumer committed Oct 15, 2023
1 parent d7c4588 commit ec4bec5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static void ACTION_FlashLight(void)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT);
break;
case 1:
case 2:
gFlashLightState++;
break;
default:
Expand Down
29 changes: 29 additions & 0 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,35 @@ void APP_TimeSlice10ms(void)

if (gFlashLightState == FLASHLIGHT_BLINK && (gFlashLightBlinkCounter & 15u) == 0)
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
if (gVoxResumeCountdown > 0)
Expand Down
3 changes: 2 additions & 1 deletion misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ enum {
enum {
FLASHLIGHT_OFF = 0,
FLASHLIGHT_ON,
FLASHLIGHT_BLINK
FLASHLIGHT_BLINK,
FLASHLIGHT_SOS
};

enum {
Expand Down

0 comments on commit ec4bec5

Please sign in to comment.