~toykeeper/flashlight-firmware/fsm

« back to all changes in this revision

Viewing changes to ToyKeeper/spaghetti-monster/anduril/load-save-config.h

  • Committer: Selene ToyKeeper
  • Date: 2023-11-04 15:09:10 UTC
  • mfrom: (483.1.175 anduril2)
  • Revision ID: bzr@toykeeper.net-20231104150910-ddd3afw4nhfvof2l
merged anduril2 branch -> fsm, with *years* of changes
(this also means this code is now Anduril 2 instead of Anduril 1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// load-save-config.h: Load/save/eeprom functions for Anduril.
 
2
// Copyright (C) 2017-2023 Selene ToyKeeper
 
3
// SPDX-License-Identifier: GPL-3.0-or-later
 
4
 
 
5
#pragma once
 
6
 
 
7
// remember stuff even after battery was changed
 
8
void load_config();
 
9
void save_config();
 
10
#ifdef START_AT_MEMORIZED_LEVEL
 
11
void save_config_wl();
 
12
#endif
 
13
 
 
14
// a struct to hold config values
 
15
Config cfg = {
 
16
 
 
17
    ///// ramp vars
 
18
 
 
19
    // smooth vs discrete ramping
 
20
    .ramp_style = RAMP_STYLE,  // 0 = smooth, 1 = discrete
 
21
    #ifdef USE_2C_STYLE_CONFIG
 
22
        // 1 = A1 style, 2 = A2 style
 
23
        .ramp_2c_style = DEFAULT_2C_STYLE,
 
24
    #endif
 
25
 
 
26
    // settings for each ramp (smooth, stepped, simple UI)
 
27
    #ifdef USE_RAMP_CONFIG
 
28
        .ramp_floors = {
 
29
            RAMP_SMOOTH_FLOOR,
 
30
            RAMP_DISCRETE_FLOOR,
 
31
            #ifdef USE_SIMPLE_UI
 
32
                SIMPLE_UI_FLOOR,
 
33
            #endif
 
34
            },
 
35
        .ramp_ceils = {
 
36
            RAMP_SMOOTH_CEIL,
 
37
            RAMP_DISCRETE_CEIL,
 
38
            #ifdef USE_SIMPLE_UI
 
39
                SIMPLE_UI_CEIL,
 
40
            #endif
 
41
            },
 
42
        .ramp_stepss = {
 
43
            DEFAULT_RAMP_SPEED,
 
44
            RAMP_DISCRETE_STEPS,
 
45
            #ifdef USE_SIMPLE_UI
 
46
                SIMPLE_UI_STEPS,
 
47
            #endif
 
48
            },
 
49
    #endif
 
50
 
 
51
    #ifdef USE_SIMPLE_UI
 
52
        // whether to enable the simplified interface or not
 
53
        .simple_ui_active = SIMPLE_UI_ACTIVE,
 
54
        #ifdef USE_2C_STYLE_CONFIG
 
55
            // 0 = no turbo, 1 = A1 style, 2 = A2 style
 
56
            .ramp_2c_style_simple = DEFAULT_2C_STYLE_SIMPLE,
 
57
        #endif
 
58
    #endif
 
59
 
 
60
    #ifdef USE_RAMP_AFTER_MOON_CONFIG
 
61
        .dont_ramp_after_moon = DEFAULT_DONT_RAMP_AFTER_MOON,
 
62
    #endif
 
63
 
 
64
    #ifdef USE_MANUAL_MEMORY
 
65
        .manual_memory = DEFAULT_MANUAL_MEMORY,
 
66
        #ifdef USE_MANUAL_MEMORY_TIMER
 
67
            .manual_memory_timer = DEFAULT_MANUAL_MEMORY_TIMER,
 
68
        #endif
 
69
    #endif
 
70
 
 
71
    ///// channel modes / color modes
 
72
 
 
73
    #if NUM_CHANNEL_MODES > 1
 
74
        // current multi-channel mode
 
75
        .channel_mode = DEFAULT_CHANNEL_MODE,
 
76
        // user can take unwanted modes out of the rotation (bitmask)
 
77
        .channel_modes_enabled = CHANNEL_MODES_ENABLED,
 
78
        #ifdef USE_MANUAL_MEMORY
 
79
            // reset w/ manual memory
 
80
            .manual_memory_channel_mode = DEFAULT_CHANNEL_MODE,
 
81
        #endif
 
82
        #ifdef DEFAULT_BLINK_CHANNEL
 
83
            // blink numbers in a specific channel (user configurable)
 
84
            .blink_channel = DEFAULT_BLINK_CHANNEL,
 
85
        #endif
 
86
    #endif
 
87
    #ifdef USE_CHANNEL_MODE_ARGS
 
88
        // one byte of extra data per channel mode, like for tint value
 
89
        .channel_mode_args = { CHANNEL_MODE_ARGS },
 
90
        #ifdef USE_MANUAL_MEMORY
 
91
            // remember and reset 1 extra parameter per channel mode (like tint)
 
92
            .manual_memory_channel_args = { CHANNEL_MODE_ARGS },
 
93
        #endif
 
94
        #ifdef USE_STEPPED_TINT_RAMPING
 
95
            .tint_ramp_style = DEFAULT_TINT_RAMP_STYLE,
 
96
        #endif
 
97
    #endif
 
98
 
 
99
    ///// Smooth animation between steps, and for on/off
 
100
    #ifdef USE_SMOOTH_STEPS
 
101
        .smooth_steps_style = DEFAULT_SMOOTH_STEPS_STYLE,
 
102
    #endif
 
103
 
 
104
    ///// strobe / blinky mode settings
 
105
 
 
106
    #ifdef USE_STROBE_STATE
 
107
        .strobe_type = DEFAULT_STROBE,
 
108
        #if (NUM_CHANNEL_MODES > 1) && defined(USE_CHANNEL_PER_STROBE)
 
109
            // channel mode saved per strobe-group mode
 
110
            #ifdef DEFAULT_STROBE_CHANNELS
 
111
                .strobe_channels = { DEFAULT_STROBE_CHANNELS },
 
112
            #endif
 
113
        #endif
 
114
    #endif
 
115
    #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
 
116
        // party / tactical strobe timing
 
117
        // party strobe 24 Hz, tactical strobe 10 Hz
 
118
        .strobe_delays = { 41, 67 },
 
119
    #endif
 
120
    #ifdef USE_BIKE_FLASHER_MODE
 
121
        .bike_flasher_brightness = MAX_1x7135,
 
122
    #endif
 
123
    #ifdef USE_BEACON_MODE
 
124
        // beacon timing
 
125
        .beacon_seconds = 2,
 
126
    #endif
 
127
 
 
128
    ///// voltage and temperature
 
129
 
 
130
    #ifdef USE_VOLTAGE_CORRECTION
 
131
        // same 0.05V units as fudge factor,
 
132
        // but 7 is neutral, and the expected range is from 1 to 13
 
133
        .voltage_correction = 7,
 
134
    #endif
 
135
    #ifdef USE_THERMAL_REGULATION
 
136
        .therm_ceil = DEFAULT_THERM_CEIL,
 
137
        .therm_cal_offset = 0,
 
138
    #endif
 
139
 
 
140
    ///// aux LEDs
 
141
 
 
142
    #ifdef USE_INDICATOR_LED
 
143
        // bits 2-3 control lockout mode
 
144
        // bits 0-1 control "off" mode
 
145
        // modes are: 0=off, 1=low, 2=high, 3=blinking (if TICK_DURING_STANDBY enabled)
 
146
        .indicator_led_mode = INDICATOR_LED_DEFAULT_MODE,
 
147
    #endif
 
148
    #ifdef USE_AUX_RGB_LEDS
 
149
        .rgb_led_off_mode = RGB_LED_OFF_DEFAULT,
 
150
        .rgb_led_lockout_mode = RGB_LED_LOCKOUT_DEFAULT,
 
151
        #ifdef USE_POST_OFF_VOLTAGE
 
152
            // display voltage readout for a while after turning off?
 
153
            .post_off_voltage = DEFAULT_POST_OFF_VOLTAGE_SECONDS,
 
154
        #endif
 
155
    #endif
 
156
 
 
157
    ///// misc other mode settings
 
158
 
 
159
    #ifdef USE_AUTOLOCK
 
160
        .autolock_time = DEFAULT_AUTOLOCK_TIME,
 
161
    #endif
 
162
    #ifdef USE_TACTICAL_MODE
 
163
        .tactical_levels = { TACTICAL_LEVELS },
 
164
    #endif
 
165
 
 
166
    ///// hardware config / globals menu
 
167
 
 
168
    #ifdef USE_JUMP_START
 
169
        .jump_start_level = DEFAULT_JUMP_START_LEVEL,
 
170
    #endif
 
171
 
 
172
};
 
173