Merge lp:~sammyshp/flashlight-firmware/moon-dont-ramp-up into lp:~toykeeper/flashlight-firmware/anduril2

Proposed by Sven Greiner
Status: Needs review
Proposed branch: lp:~sammyshp/flashlight-firmware/moon-dont-ramp-up
Merge into: lp:~toykeeper/flashlight-firmware/anduril2
Diff against target: 225 lines (+75/-11)
9 files modified
ToyKeeper/spaghetti-monster/anduril/anduril-manual.txt (+9/-1)
ToyKeeper/spaghetti-monster/anduril/config-default.h (+5/-0)
ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h (+6/-0)
ToyKeeper/spaghetti-monster/anduril/load-save-config.c (+12/-0)
ToyKeeper/spaghetti-monster/anduril/off-mode.c (+1/-1)
ToyKeeper/spaghetti-monster/anduril/off-mode.h (+6/-0)
ToyKeeper/spaghetti-monster/anduril/ramp-mode-fsm.h (+1/-1)
ToyKeeper/spaghetti-monster/anduril/ramp-mode.c (+29/-8)
ToyKeeper/spaghetti-monster/anduril/ramp-mode.h (+6/-0)
To merge this branch: bzr merge lp:~sammyshp/flashlight-firmware/moon-dont-ramp-up
Reviewer Review Type Date Requested Status
Selene ToyKeeper Pending
Review via email: mp+407834@code.launchpad.net

Description of the change

Add option to stop ramping up from moon

With `#undef MOON_START_RAMPING` entering moon from off by holding the switch will not automatically start ramping up. This ensures that moon is entered reliably when the switch is held long enough.

Timings still apply (you can release the switch when the light turns on or when it blips, depending on the configured timing).

With `#define USE_MOON_START_RAMPING_CONFIG` this can be configured during runtime with the global configuration menu.

This contains the changes of lp:~sammyshp/flashlight-firmware/2c-turbo-config because they were necessary for the configuration menu.

To post a comment you must log in.
Revision history for this message
Selene ToyKeeper (toykeeper) wrote :

We took very similar approaches here, mostly differing in whether the boolean means "ramp" or "don't ramp". Also, yours has the nice property that the user can select either behavior at compile time, or add a menu item... while mine only offers the old behavior or a menu item.

I'm hoping to merge other branches at the moment, but I left a note in the code pointing back to this as a possible improvement for later, because it's a good idea.

Unmerged revisions

621. By Sven Greiner

Make moon ramping behavior configurable during runtime

620. By Sven Greiner

Add option to stop ramping up from moon

With `#undef MOON_START_RAMPING` entering moon from off by holding the
switch will not automatically start ramping up. This ensures that moon
is entered reliably when the switch is held long enough.

Timings still apply (you can release the switch when the light turns on
or when it blips, depending on the configured timing).

619. By Sven Greiner

Add runtime configuration of 2C turbo style

This adds a new configuration option to the global configuration menu if
`USE_2C_STYLE_CONFIG` is defined. The user can select between 0 (no
change), 1 (Anduril 1 behavior) and 2 (Anduril 2) behavior. The default
is taken from `USE_2C_MAX_TURBO` if it is defined.

If `USE_2C_STYLE_CONFIG` is not defined, this creates the same output as
before (no increase in code size).

Also add dynamic setup of the global configuration menu.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ToyKeeper/spaghetti-monster/anduril/anduril-manual.txt'
--- ToyKeeper/spaghetti-monster/anduril/anduril-manual.txt 2021-08-23 10:37:15 +0000
+++ ToyKeeper/spaghetti-monster/anduril/anduril-manual.txt 2021-08-30 13:29:06 +0000
@@ -645,7 +645,7 @@
645Some models may have an extra config menu for settings which don't fit 645Some models may have an extra config menu for settings which don't fit
646anywhere else. These settings are, in order:646anywhere else. These settings are, in order:
647647
648 - 2C style: (not yet implemented)648 - 2C style:
649649
650 1: 2C goes to turbo (Anduril V1 style)650 1: 2C goes to turbo (Anduril V1 style)
651 2: 2C goes to ramp ceiling (Anduril V2 style)651 2: 2C goes to ramp ceiling (Anduril V2 style)
@@ -659,6 +659,14 @@
659659
660 The value can be from 1 to 150, but is usually between 10 and 30.660 The value can be from 1 to 150, but is usually between 10 and 30.
661661
662 - Start ramping up from moon:
663
664 When entering moon from off by holding the button and then keep
665 holding it ...
666
667 0: stay at moon
668 1: start to ramp up
669
662Some settings are hardware-specific and may not be present on all 670Some settings are hardware-specific and may not be present on all
663lights. The number of settings in the global menu depends on the 671lights. The number of settings in the global menu depends on the
664hardware model and the firmware version.672hardware model and the firmware version.
665673
=== modified file 'ToyKeeper/spaghetti-monster/anduril/config-default.h'
--- ToyKeeper/spaghetti-monster/anduril/config-default.h 2021-07-13 23:44:08 +0000
+++ ToyKeeper/spaghetti-monster/anduril/config-default.h 2021-08-30 13:29:06 +0000
@@ -106,6 +106,11 @@
106// timer is available in regular ramp mode and candle mode106// timer is available in regular ramp mode and candle mode
107#define USE_SUNSET_TIMER107#define USE_SUNSET_TIMER
108108
109// automatically start ramping up when entering moon from off
110#define MOON_START_RAMPING
111// make this configurable at runtime
112//#define USE_MOON_START_RAMPING_CONFIG
113
109114
110///// What to do when power is connected /////115///// What to do when power is connected /////
111// factory reset function erases user's runtime configuration in eeprom116// factory reset function erases user's runtime configuration in eeprom
112117
=== modified file 'ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h'
--- ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h 2021-08-23 10:24:08 +0000
+++ ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h 2021-08-30 13:29:06 +0000
@@ -82,6 +82,12 @@
82 #ifdef USE_AUTOLOCK82 #ifdef USE_AUTOLOCK
83 autolock_time_e,83 autolock_time_e,
84 #endif84 #endif
85 #ifdef USE_2C_STYLE_CONFIG
86 use_2c_max_turbo_e,
87 #endif
88 #ifdef USE_MOON_START_RAMPING_CONFIG
89 moon_start_ramping_e,
90 #endif
85 eeprom_indexes_e_END91 eeprom_indexes_e_END
86} eeprom_indexes_e;92} eeprom_indexes_e;
87#define EEPROM_BYTES eeprom_indexes_e_END93#define EEPROM_BYTES eeprom_indexes_e_END
8894
=== modified file 'ToyKeeper/spaghetti-monster/anduril/load-save-config.c'
--- ToyKeeper/spaghetti-monster/anduril/load-save-config.c 2021-08-23 10:24:08 +0000
+++ ToyKeeper/spaghetti-monster/anduril/load-save-config.c 2021-08-30 13:29:06 +0000
@@ -82,6 +82,12 @@
82 #ifdef USE_AUTOLOCK82 #ifdef USE_AUTOLOCK
83 autolock_time = eeprom[autolock_time_e];83 autolock_time = eeprom[autolock_time_e];
84 #endif84 #endif
85 #ifdef USE_2C_STYLE_CONFIG
86 use_2c_max_turbo = eeprom[use_2c_max_turbo_e];
87 #endif
88 #ifdef USE_MOON_START_RAMPING_CONFIG
89 moon_start_ramping = eeprom[moon_start_ramping_e];
90 #endif
85 }91 }
86 #ifdef START_AT_MEMORIZED_LEVEL92 #ifdef START_AT_MEMORIZED_LEVEL
87 if (load_eeprom_wl()) {93 if (load_eeprom_wl()) {
@@ -148,6 +154,12 @@
148 #ifdef USE_AUTOLOCK154 #ifdef USE_AUTOLOCK
149 eeprom[autolock_time_e] = autolock_time;155 eeprom[autolock_time_e] = autolock_time;
150 #endif156 #endif
157 #ifdef USE_2C_STYLE_CONFIG
158 eeprom[use_2c_max_turbo_e] = use_2c_max_turbo,
159 #endif
160 #ifdef USE_MOON_START_RAMPING_CONFIG
161 eeprom[moon_start_ramping_e] = moon_start_ramping;
162 #endif
151163
152 save_eeprom();164 save_eeprom();
153}165}
154166
=== modified file 'ToyKeeper/spaghetti-monster/anduril/off-mode.c'
--- ToyKeeper/spaghetti-monster/anduril/off-mode.c 2021-08-27 13:33:01 +0000
+++ ToyKeeper/spaghetti-monster/anduril/off-mode.c 2021-08-30 13:29:06 +0000
@@ -109,7 +109,7 @@
109 // don't start ramping immediately;109 // don't start ramping immediately;
110 // give the user time to release at moon level110 // give the user time to release at moon level
111 //if (arg >= HOLD_TIMEOUT) { // smaller111 //if (arg >= HOLD_TIMEOUT) { // smaller
112 if (arg >= (!ramp_style) * HOLD_TIMEOUT) { // more consistent112 if (moon_start_ramping && arg >= (!ramp_style) * HOLD_TIMEOUT) { // more consistent
113 set_state(steady_state, 1);113 set_state(steady_state, 1);
114 }114 }
115 return MISCHIEF_MANAGED;115 return MISCHIEF_MANAGED;
116116
=== modified file 'ToyKeeper/spaghetti-monster/anduril/off-mode.h'
--- ToyKeeper/spaghetti-monster/anduril/off-mode.h 2020-07-22 22:50:22 +0000
+++ ToyKeeper/spaghetti-monster/anduril/off-mode.h 2021-08-30 13:29:06 +0000
@@ -23,5 +23,11 @@
23// when the light is "off" or in standby23// when the light is "off" or in standby
24uint8_t off_state(Event event, uint16_t arg);24uint8_t off_state(Event event, uint16_t arg);
2525
26#ifdef MOON_START_RAMPING
27uint8_t moon_start_ramping = 1;
28#else
29uint8_t moon_start_ramping = 0;
30#endif
31
2632
27#endif33#endif
2834
=== modified file 'ToyKeeper/spaghetti-monster/anduril/ramp-mode-fsm.h'
--- ToyKeeper/spaghetti-monster/anduril/ramp-mode-fsm.h 2021-08-23 10:24:08 +0000
+++ ToyKeeper/spaghetti-monster/anduril/ramp-mode-fsm.h 2021-08-30 13:29:06 +0000
@@ -47,7 +47,7 @@
47#endif47#endif
4848
49// include an extra config mode for random stuff which doesn't fit elsewhere49// include an extra config mode for random stuff which doesn't fit elsewhere
50#if defined(USE_JUMP_START) || defined(USE_2C_STYLE_CONFIG)50#if defined(USE_JUMP_START) || defined(USE_2C_STYLE_CONFIG) || defined(USE_MOON_START_RAMPING_CONFIG)
51#define USE_GLOBALS_CONFIG51#define USE_GLOBALS_CONFIG
52#endif52#endif
5353
5454
=== modified file 'ToyKeeper/spaghetti-monster/anduril/ramp-mode.c'
--- ToyKeeper/spaghetti-monster/anduril/ramp-mode.c 2021-08-23 10:24:08 +0000
+++ ToyKeeper/spaghetti-monster/anduril/ramp-mode.c 2021-08-30 13:29:06 +0000
@@ -101,7 +101,7 @@
101 // 2 clicks: go to/from highest level101 // 2 clicks: go to/from highest level
102 else if (event == EV_2clicks) {102 else if (event == EV_2clicks) {
103 uint8_t turbo_level;103 uint8_t turbo_level;
104 #ifdef USE_2C_MAX_TURBO104 if (use_2c_max_turbo) {
105 // simple UI: to/from ceiling105 // simple UI: to/from ceiling
106 // full UI: to/from turbo (Anduril1 behavior)106 // full UI: to/from turbo (Anduril1 behavior)
107 #ifdef USE_SIMPLE_UI107 #ifdef USE_SIMPLE_UI
@@ -109,7 +109,7 @@
109 else109 else
110 #endif110 #endif
111 turbo_level = MAX_LEVEL;111 turbo_level = MAX_LEVEL;
112 #else112 } else {
113 // simple UI: to/from ceiling113 // simple UI: to/from ceiling
114 // full UI: to/from ceiling if mem < ceiling,114 // full UI: to/from ceiling if mem < ceiling,
115 // or to/from turbo if mem >= ceiling115 // or to/from turbo if mem >= ceiling
@@ -119,7 +119,7 @@
119 #endif119 #endif
120 ) { turbo_level = mode_max; }120 ) { turbo_level = mode_max; }
121 else { turbo_level = MAX_LEVEL; }121 else { turbo_level = MAX_LEVEL; }
122 #endif122 }
123123
124 if (actual_level < turbo_level) {124 if (actual_level < turbo_level) {
125 set_level_and_therm_target(turbo_level);125 set_level_and_therm_target(turbo_level);
@@ -475,19 +475,40 @@
475475
476#ifdef USE_GLOBALS_CONFIG476#ifdef USE_GLOBALS_CONFIG
477void globals_config_save(uint8_t step, uint8_t value) {477void globals_config_save(uint8_t step, uint8_t value) {
478 uint8_t step_index = 0;
478 if (0) {}479 if (0) {}
479 #ifdef USE_2C_STYLE_CONFIG480 #ifdef USE_2C_STYLE_CONFIG
480 // TODO: make double-click style configurable (turbo or ceil)481 else if (++step_index == step) {
481 else if (1 == step) {}482 if (value > 0) {
483 use_2c_max_turbo = (value == 1);
484 }
485 }
482 #endif486 #endif
483 #ifdef USE_JUMP_START487 #ifdef USE_JUMP_START
484 else { jump_start_level = value; }488 else if (++step_index == step) {
489 jump_start_level = value;
490 }
491 #endif
492 #ifdef USE_MOON_START_RAMPING_CONFIG
493 else if (++step_index == step) {
494 moon_start_ramping = value;
495 }
485 #endif496 #endif
486}497}
487498
488uint8_t globals_config_state(Event event, uint16_t arg) {499uint8_t globals_config_state(Event event, uint16_t arg) {
489 // TODO: set number of steps based on how many configurable options500 const uint8_t step_count = 0
490 return config_state_base(event, arg, 1, globals_config_save);501 #ifdef USE_2C_STYLE_CONFIG
502 +1
503 #endif
504 #ifdef USE_JUMP_START
505 +1
506 #endif
507 #ifdef USE_MOON_START_RAMPING_CONFIG
508 +1
509 #endif
510 ;
511 return config_state_base(event, arg, step_count, globals_config_save);
491}512}
492#endif513#endif
493514
494515
=== modified file 'ToyKeeper/spaghetti-monster/anduril/ramp-mode.h'
--- ToyKeeper/spaghetti-monster/anduril/ramp-mode.h 2021-08-23 10:24:08 +0000
+++ ToyKeeper/spaghetti-monster/anduril/ramp-mode.h 2021-08-30 13:29:06 +0000
@@ -197,5 +197,11 @@
197uint8_t globals_config_state(Event event, uint16_t arg);197uint8_t globals_config_state(Event event, uint16_t arg);
198#endif198#endif
199199
200#ifdef USE_2C_MAX_TURBO
201uint8_t use_2c_max_turbo = 1;
202#else
203uint8_t use_2c_max_turbo = 0;
204#endif
205
200206
201#endif207#endif

Subscribers

People subscribed via source and target branches

to status/vote changes: