1
// ff-strobe-modes.c: Fireflies Flashlights strobe modes for Anduril.
2
// Copyright (C) 2017-2023 Selene ToyKeeper
3
// SPDX-License-Identifier: GPL-3.0-or-later
7
#include "ff-strobe-modes.h"
9
uint8_t boring_strobe_state(Event event, uint16_t arg) {
10
// police strobe and SOS, meh
11
// 'st' reduces ROM size slightly
12
uint8_t st = boring_strobe_type;
14
if (event == EV_enter_state) {
18
else if (event == EV_1click) {
19
// reset to police strobe for next time
20
boring_strobe_type = 0;
21
set_state(off_state, 0);
24
// 2 clicks: rotate through strobe/flasher modes
25
else if (event == EV_2clicks) {
26
boring_strobe_type = (st + 1) % NUM_BORING_STROBES;
29
return EVENT_NOT_HANDLED;
32
inline void boring_strobe_state_iter() {
33
switch(boring_strobe_type) {
34
#ifdef USE_POLICE_STROBE_MODE
35
case 0: // police strobe
40
#ifdef USE_SOS_MODE_IN_FF_GROUP
48
#ifdef USE_POLICE_STROBE_MODE
49
inline void police_strobe_iter() {
50
// one iteration of main loop()
51
// flash at 16 Hz then 8 Hz, 8 times each
52
for (uint8_t del=41; del<100; del+=41) {
53
for (uint8_t f=0; f<8; f++) {
54
set_level(STROBE_BRIGHTNESS);
55
nice_delay_ms(del >> 1);