~toykeeper/flashlight-firmware/fsm

« back to all changes in this revision

Viewing changes to ToyKeeper/spaghetti-monster/anduril/candle-mode.c

  • Committer: Selene ToyKeeper
  • Date: 2023-06-29 08:44:53 UTC
  • mto: (483.1.175 anduril2)
  • mto: This revision was merged to the branch mainline in revision 491.
  • Revision ID: bzr@toykeeper.net-20230629084453-82f9dddarrzcixos
Removed references to Harry Potter,
because J.K. Rowling is the figurehead of a hate group
and I don't want to condone that in any way.

I liked a 2-word phrase she wrote once, "mischief managed", but that was
decades ago...  and now she is the face of a transphobic movement known as
TERFs.  She turned out to be a pretty terrible person who uses her massive
wealth and influence to spread hate and oppress people.

To be clear:

    Trans rights are human rights.

... and anyone who has a problem with that has no place in this project.

Patch suggested by SiteRelEnby, and TBH it's embarrassing that I didn't remove
the phrase sooner.  It seemed fun and innocent in 2017 when this project
started, but ... things changed.

https://github.com/SiteRelEnby/anduril2/commit/a1cee423b4e0e16909a90d5c3e6a7b70df30d755

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    // if the timer just expired, shut off
36
36
    if (sunset_active  &&  (! sunset_timer)) {
37
37
        set_state(off_state, 0);
38
 
        return MISCHIEF_MANAGED;
 
38
        return EVENT_HANDLED;
39
39
    }
40
40
    #endif  // ifdef USE_SUNSET_TIMER
41
41
 
42
42
 
43
43
    if (event == EV_enter_state) {
44
44
        ramp_direction = 1;
45
 
        return MISCHIEF_MANAGED;
 
45
        return EVENT_HANDLED;
46
46
    }
47
47
    #ifdef USE_SUNSET_TIMER
48
48
    // 2 clicks: cancel timer
50
50
        // parent state just rotated through strobe/flasher modes,
51
51
        // so cancel timer...  in case any time was left over from earlier
52
52
        sunset_timer = 0;
53
 
        return MISCHIEF_MANAGED;
 
53
        return EVENT_HANDLED;
54
54
    }
55
55
    #endif  // ifdef USE_SUNSET_TIMER
56
56
    // hold: change brightness (brighter)
64
64
        candle_mode_brightness += ramp_direction;
65
65
        if (candle_mode_brightness < 1) candle_mode_brightness = 1;
66
66
        else if (candle_mode_brightness > MAX_CANDLE_LEVEL) candle_mode_brightness = MAX_CANDLE_LEVEL;
67
 
        return MISCHIEF_MANAGED;
 
67
        return EVENT_HANDLED;
68
68
    }
69
69
    // reverse ramp direction on hold release
70
70
    else if (event == EV_click1_hold_release) {
71
71
        ramp_direction = -ramp_direction;
72
 
        return MISCHIEF_MANAGED;
 
72
        return EVENT_HANDLED;
73
73
    }
74
74
    // click, hold: change brightness (dimmer)
75
75
    else if (event == EV_click2_hold) {
76
76
        ramp_direction = 1;
77
77
        if (candle_mode_brightness > 1)
78
78
            candle_mode_brightness --;
79
 
        return MISCHIEF_MANAGED;
 
79
        return EVENT_HANDLED;
80
80
    }
81
81
    // clock tick: animate candle brightness
82
82
    else if (event == EV_tick) {
129
129
            // random amplitude
130
130
            //candle_wave3_depth = 2 + (pseudo_rand() % ((CANDLE_WAVE3_MAXDEPTH * CANDLE_AMPLITUDE / 100) - 2));
131
131
            candle_wave3_depth = pseudo_rand() % (CANDLE_WAVE3_MAXDEPTH * CANDLE_AMPLITUDE / 100);
132
 
        return MISCHIEF_MANAGED;
 
132
        return EVENT_HANDLED;
133
133
    }
134
134
    return EVENT_NOT_HANDLED;
135
135
}