From 89ea4e6f8ac15d3cb12d5562df9681c9d650b5f8 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 22 Sep 2024 16:46:40 -0600 Subject: cherry-picked hank-lume-x1 code from https://github.com/loneoceans/anduril/commit/d83ebb75dab8c462b7efa841bccc00a136ff15a2 The [PR](https://github.com/ToyKeeper/anduril/pull/37) has a lot of other stuff in it, so I'm just picking out the parts needed for this particular light, and leaving the rest for later. Will need further edits before merging into trunk. --- ui/anduril/anduril.c | 11 +++++++++++ ui/anduril/momentary-mode.c | 6 ++++++ 2 files changed, 17 insertions(+) (limited to 'ui') diff --git a/ui/anduril/anduril.c b/ui/anduril/anduril.c index a7e4199..c4bd99f 100644 --- a/ui/anduril/anduril.c +++ b/ui/anduril/anduril.c @@ -341,7 +341,18 @@ void loop() { #ifdef USE_THERMAL_REGULATION // TODO: blink out therm_ceil during thermal_config_state? else if (state == tempcheck_state) { + // temperature is type int16_t + // but blink_num is uint8_t, so -10 will blink as 246 + #ifdef USE_LONG_BLINK_FOR_NEGATIVE_SIGN + if (temperature < 0){ + blink_negative(); + blink_num(-temperature); + } + else {blink_num(temperature);} + #endif + #ifndef USE_LONG_BLINK_FOR_NEGATIVE_SIGN blink_num(temperature); + #endif nice_delay_ms(1000); } #endif diff --git a/ui/anduril/momentary-mode.c b/ui/anduril/momentary-mode.c index 327302a..31a9411 100644 --- a/ui/anduril/momentary-mode.c +++ b/ui/anduril/momentary-mode.c @@ -7,6 +7,12 @@ #include "anduril/momentary-mode.h" uint8_t momentary_state(Event event, uint16_t arg) { + + // enable OTG mode, if defined + #ifdef USE_OTG_IN_MOMENTARY + POWER_BANK_EN_PORT |= POWER_BANK_EN_PIN; + #endif + // init strobe mode, if relevant #ifdef USE_STROBE_STATE if ((event == EV_enter_state) && (momentary_mode != 0)) { -- cgit v1.2.3 From 6be8fff532c4be83126517a6e3b7b725548761c2 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 22 Sep 2024 17:15:47 -0600 Subject: hank-lume-x1 cleanup and calibration, part 1: - changed model number from 0281 to 0171 - cleaned up blink_negative and AUXLED_RGB_DIFFERENT_PORTS a little (but the latter needs a complete refactor, as soon as the hardware abstraction code can handle aux LEDs better) - cleaned up USE_LONG_BLINK_FOR_NEGATIVE_SIGN a little - removed USE_OTG_IN_MOMENTARY since it's not actually used - moved hw/loneoceans/lume-x1-avr32dd20/* files into hw/hank/lume-x1/ - superficial cleanup on hank/lume-x1/hwdef.* - removed some of the extra stuff from hank/lume-x1/anduril.h - adjusted calibration (especially ramp table) on hank-lume-x1 (ramp shape is pretty close to a D4K-boost now, but with more firefly modes) (calibration is based on a sample size of 1, further testing needed) --- ui/anduril/anduril.c | 6 ++---- ui/anduril/momentary-mode.c | 6 ------ 2 files changed, 2 insertions(+), 10 deletions(-) (limited to 'ui') diff --git a/ui/anduril/anduril.c b/ui/anduril/anduril.c index c4bd99f..383acbc 100644 --- a/ui/anduril/anduril.c +++ b/ui/anduril/anduril.c @@ -344,15 +344,13 @@ void loop() { // temperature is type int16_t // but blink_num is uint8_t, so -10 will blink as 246 #ifdef USE_LONG_BLINK_FOR_NEGATIVE_SIGN - if (temperature < 0){ + if (temperature < 0) { blink_negative(); blink_num(-temperature); } - else {blink_num(temperature);} + else #endif - #ifndef USE_LONG_BLINK_FOR_NEGATIVE_SIGN blink_num(temperature); - #endif nice_delay_ms(1000); } #endif diff --git a/ui/anduril/momentary-mode.c b/ui/anduril/momentary-mode.c index 31a9411..327302a 100644 --- a/ui/anduril/momentary-mode.c +++ b/ui/anduril/momentary-mode.c @@ -7,12 +7,6 @@ #include "anduril/momentary-mode.h" uint8_t momentary_state(Event event, uint16_t arg) { - - // enable OTG mode, if defined - #ifdef USE_OTG_IN_MOMENTARY - POWER_BANK_EN_PORT |= POWER_BANK_EN_PIN; - #endif - // init strobe mode, if relevant #ifdef USE_STROBE_STATE if ((event == EV_enter_state) && (momentary_mode != 0)) { -- cgit v1.2.3 From 84129176fa2a316d26ed0bd1d252ef2703e79ca6 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 4 Jun 2025 00:24:47 -0600 Subject: lockout mode now only does momentary moon/low on 1st and 2nd presses, so it no longer flashes on each click while advancing to other functions --- ui/anduril/lockout-mode.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'ui') diff --git a/ui/anduril/lockout-mode.c b/ui/anduril/lockout-mode.c index c3f82ea..255ab22 100644 --- a/ui/anduril/lockout-mode.c +++ b/ui/anduril/lockout-mode.c @@ -12,24 +12,30 @@ uint8_t lockout_state(Event event, uint16_t arg) { // button is being held #ifdef USE_AUX_RGB_LEDS // don't turn on during RGB aux LED configuration - if (event == EV_click7_hold) { set_level(0); } else + //if (event == EV_click7_hold) { set_level(0); } else #endif - if ((event & (B_CLICK | B_PRESS)) == (B_CLICK | B_PRESS)) { - // hold: lowest floor - // click, hold: highest floor (or manual mem level) + uint8_t click_num = event & B_COUNT; + if ( // button pressed 1st or 2nd time + ((B_CLICK | B_PRESS) == (event & (B_CLICK | B_PRESS))) + && (click_num <= 2) + ) { uint8_t lvl = cfg.ramp_floors[0]; - if (1 == (event & 0x0f)) { // first click + // hold: lowest floor + if (1 == click_num) { // 1st click if (cfg.ramp_floors[1] < lvl) lvl = cfg.ramp_floors[1]; - } else { // 2nd click or later - if (cfg.ramp_floors[1] > lvl) lvl = cfg.ramp_floors[1]; + } + // click, hold: highest floor (or manual mem level) + else { // 2nd click #ifdef USE_MANUAL_MEMORY if (cfg.manual_memory) lvl = cfg.manual_memory; + else #endif + if (cfg.ramp_floors[1] > lvl) lvl = cfg.ramp_floors[1]; } off_state_set_level(lvl); } // button was released - else if ((event & (B_CLICK | B_PRESS)) == (B_CLICK)) { + else if ((B_CLICK) == (event & (B_CLICK | B_PRESS))) { off_state_set_level(0); } #endif // ifdef USE_MOON_DURING_LOCKOUT_MODE -- cgit v1.2.3