~toykeeper/flashlight-firmware/fsm

« back to all changes in this revision

Viewing changes to ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.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-fsm.h: FSM config for eeprom configuration in Anduril.
 
2
// Copyright (C) 2017-2023 Selene ToyKeeper
 
3
// SPDX-License-Identifier: GPL-3.0-or-later
 
4
 
 
5
#pragma once
 
6
 
 
7
#define USE_EEPROM
 
8
// load into a custom RAM location instead of FSM's default byte array
 
9
#define EEPROM_OVERRIDE
 
10
 
 
11
#ifdef USE_SIMPLE_UI
 
12
#define NUM_RAMPS 3
 
13
#else
 
14
#define NUM_RAMPS 2
 
15
#endif
 
16
 
 
17
// let FSM know this config struct exists
 
18
#define USE_CFG
 
19
 
 
20
typedef struct Config {
 
21
 
 
22
    ///// ramp vars
 
23
    uint8_t ramp_style;
 
24
    #ifdef USE_2C_STYLE_CONFIG
 
25
        uint8_t ramp_2c_style;
 
26
    #endif
 
27
    #ifdef USE_RAMP_CONFIG
 
28
        uint8_t ramp_floors[NUM_RAMPS];
 
29
        uint8_t ramp_ceils [NUM_RAMPS];
 
30
        uint8_t ramp_stepss[NUM_RAMPS];
 
31
    #endif
 
32
    #ifdef USE_SIMPLE_UI
 
33
        uint8_t simple_ui_active;
 
34
        #ifdef USE_2C_STYLE_CONFIG
 
35
            uint8_t ramp_2c_style_simple;
 
36
        #endif
 
37
    #endif
 
38
    #ifdef USE_RAMP_AFTER_MOON_CONFIG
 
39
        uint8_t dont_ramp_after_moon;
 
40
    #endif
 
41
    #ifdef USE_MANUAL_MEMORY
 
42
        uint8_t manual_memory;
 
43
        #ifdef USE_MANUAL_MEMORY_TIMER
 
44
            uint8_t manual_memory_timer;
 
45
        #endif
 
46
    #endif
 
47
 
 
48
    ///// channel modes / color modes
 
49
    #if NUM_CHANNEL_MODES > 1
 
50
        uint8_t channel_mode;
 
51
        uint16_t channel_modes_enabled;
 
52
        #ifdef USE_MANUAL_MEMORY
 
53
            uint8_t manual_memory_channel_mode;
 
54
        #endif
 
55
        #ifdef DEFAULT_BLINK_CHANNEL
 
56
            uint8_t blink_channel;
 
57
        #endif
 
58
    #endif
 
59
    #ifdef USE_CHANNEL_MODE_ARGS
 
60
        // this is an array, needs a few bytes
 
61
        uint8_t channel_mode_args[NUM_CHANNEL_MODES];
 
62
        #ifdef USE_MANUAL_MEMORY
 
63
            uint8_t manual_memory_channel_args[NUM_CHANNEL_MODES];
 
64
        #endif
 
65
        #ifdef USE_STEPPED_TINT_RAMPING
 
66
            uint8_t tint_ramp_style;
 
67
        #endif
 
68
    #endif
 
69
 
 
70
    ///// Smooth animation between steps, and for on/off
 
71
    #ifdef USE_SMOOTH_STEPS
 
72
        uint8_t smooth_steps_style;
 
73
    #endif
 
74
 
 
75
    ///// strobe / blinky mode settings
 
76
    #ifdef USE_STROBE_STATE
 
77
        uint8_t strobe_type;
 
78
        #if (NUM_CHANNEL_MODES > 1) && defined(USE_CHANNEL_PER_STROBE)
 
79
            uint8_t strobe_channels[NUM_STROBES];
 
80
        #endif
 
81
    #endif
 
82
    #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
 
83
        uint8_t strobe_delays[2];
 
84
    #endif
 
85
    #ifdef USE_BIKE_FLASHER_MODE
 
86
        uint8_t bike_flasher_brightness;
 
87
    #endif
 
88
    #ifdef USE_BEACON_MODE
 
89
        uint8_t beacon_seconds;
 
90
    #endif
 
91
 
 
92
    ///// voltage and temperature
 
93
    #ifdef USE_VOLTAGE_CORRECTION
 
94
        uint8_t voltage_correction;
 
95
    #endif
 
96
    #ifdef USE_THERMAL_REGULATION
 
97
        uint8_t therm_ceil;
 
98
        int8_t therm_cal_offset;
 
99
    #endif
 
100
 
 
101
    ///// aux LEDs
 
102
    #ifdef USE_INDICATOR_LED
 
103
        uint8_t indicator_led_mode;
 
104
    #endif
 
105
    #ifdef USE_AUX_RGB_LEDS
 
106
        uint8_t rgb_led_off_mode;
 
107
        uint8_t rgb_led_lockout_mode;
 
108
        #ifdef USE_POST_OFF_VOLTAGE
 
109
            uint8_t post_off_voltage;
 
110
        #endif
 
111
    #endif
 
112
 
 
113
    ///// misc other mode settings
 
114
    #ifdef USE_AUTOLOCK
 
115
        uint8_t autolock_time;
 
116
    #endif
 
117
    #ifdef USE_TACTICAL_MODE
 
118
        uint8_t tactical_levels[3];
 
119
    #endif
 
120
 
 
121
    ///// hardware config / globals menu
 
122
    #ifdef USE_JUMP_START
 
123
        uint8_t jump_start_level;
 
124
    #endif
 
125
 
 
126
} Config;
 
127
 
 
128
// auto-detect how many eeprom bytes
 
129
#define EEPROM_BYTES sizeof(Config)
 
130
 
 
131
// declare this so FSM can see it,
 
132
// but define its values in a file which loads later
 
133
Config cfg;
 
134
 
 
135
#ifdef START_AT_MEMORIZED_LEVEL
 
136
#define USE_EEPROM_WL
 
137
#define EEPROM_WL_BYTES 1
 
138
#endif
 
139