From f8abab2fa92d05f1f709c1b5c297e4ab804c483e Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 9 Oct 2021 09:57:48 -0600 Subject: don't hardcode 2.9V for aux LED shutoff (use the same value as LVP; easier to configure if it's in only one place) --- spaghetti-monster/anduril/aux-leds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/aux-leds.c b/spaghetti-monster/anduril/aux-leds.c index 3195fdc..a0a6d7a 100644 --- a/spaghetti-monster/anduril/aux-leds.c +++ b/spaghetti-monster/anduril/aux-leds.c @@ -64,7 +64,7 @@ uint8_t voltage_to_rgb() { 255, 6, // 7, R+G+B }; uint8_t volts = voltage; - if (volts < 29) return 0; + if (volts < VOLTAGE_LOW) return 0; uint8_t i; for (i = 0; volts >= levels[i]; i += 2) {} -- cgit v1.2.3 From e3aeb180f0a7337740b949f97db736c80fedd04b Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Thu, 14 Oct 2021 08:20:39 -0600 Subject: don't blink when toggling tint --- spaghetti-monster/anduril/tint-ramping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/tint-ramping.c b/spaghetti-monster/anduril/tint-ramping.c index 0b077ef..aa9b1f6 100644 --- a/spaghetti-monster/anduril/tint-ramping.c +++ b/spaghetti-monster/anduril/tint-ramping.c @@ -31,7 +31,7 @@ uint8_t tint_ramping_state(Event event, uint16_t arg) { if (! arg) { tint = !tint; set_level(actual_level); - blink_once(); + //blink_once(); // unnecessary, and kind of annoying on moon } return EVENT_HANDLED; } -- cgit v1.2.3 From cb735ab69b7c9f43ef30dec30110107068f3e267 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Mon, 25 Oct 2021 12:15:14 -0600 Subject: fixed too-slow thermal regulation bug introduced in d4sv2-tintramp branch (2021-09-10 r619.1.11) The gradual_target var was getting clobbered and causing thermal regulation to stop until the next thermal warning event, every time it reached a new ramp step. So... save/restore it to prevent it from getting clobbered. --- spaghetti-monster/fsm-ramping.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index e8fcde7..05c2e0e 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -267,7 +267,9 @@ void gradual_tick() { ) { //actual_level = gt + 1; + uint8_t orig = gradual_target; set_level(gt + 1); + gradual_target = orig; } // is handled in set_level() //#ifdef USE_TINT_RAMPING -- cgit v1.2.3 From 11d3a36cdf726226b083a57f0bcfbb4a9f9b5243 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Thu, 28 Oct 2021 17:57:08 -0600 Subject: Clarified Ramp->2C behavior a bit more. (old wording was confusing people) --- spaghetti-monster/anduril/anduril-manual.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/anduril-manual.txt b/spaghetti-monster/anduril/anduril-manual.txt index a8f3730..009e95e 100644 --- a/spaghetti-monster/anduril/anduril-manual.txt +++ b/spaghetti-monster/anduril/anduril-manual.txt @@ -173,8 +173,9 @@ There are four ways to access ramping mode when the light is off: While the light is on, a few actions are available: - 1C: Turn off. - - 2C: Go to or from the ceiling level. - (or if already at ceiling, and not in Simple UI, go to/from turbo) + - 2C: Go to or from the turbo level. + (or if it has regulated down, "bump" back up to turbo) + (turbo level / behavior is configurable) - 1H: Change brightness (up). If the button was released less than a second ago, or if it's already at the ceiling, it goes down instead. - 2H: Change brightness (down). @@ -760,8 +761,7 @@ Off Any 15+C Version check Ramp Any 1C Off Ramp Any 1H Ramp (up, with reversing) Ramp Any 2H Ramp (down) -Ramp Simple 2C Go to/from ceiling -Ramp Full 2C Go to/from ceiling (or turbo if at ceil already) +Ramp Any 2C Go to/from ceiling or turbo (configurable) Ramp Full 3C Change ramp style (smooth / stepped) Ramp Any 3H Tint ramping (on some lights) Ramp Full 3H Momentary turbo (on lights without tint ramping) -- cgit v1.2.3 From 4b4353ade4c026c196e2b6edacbb0dc437e3ddda Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 31 Oct 2021 02:35:49 -0600 Subject: added "200%" turbo on tint-ramping lights: D4S and LT1 Normal ramp from 0% to 100% power on levels 1 to 130, then 101% to 200% power at levels 131 to 150 using both channels at maximum for turbo. When either channel would go over 100%, the extra spills over to the other channel. --- spaghetti-monster/anduril/cfg-blf-lantern.h | 24 +++++++++------ .../anduril/cfg-emisar-d4sv2-tintramp.h | 13 +++++---- spaghetti-monster/fsm-ramping.c | 33 ++++++++++++++++++--- spaghetti-monster/fsm-ramping.h | 34 +++++++++++----------- 4 files changed, 69 insertions(+), 35 deletions(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/cfg-blf-lantern.h b/spaghetti-monster/anduril/cfg-blf-lantern.h index 48ed1f7..edbdca4 100644 --- a/spaghetti-monster/anduril/cfg-blf-lantern.h +++ b/spaghetti-monster/anduril/cfg-blf-lantern.h @@ -19,15 +19,20 @@ // (0 = 100% brightness, 64 = 200% brightness) //#define TINT_RAMPING_CORRECTION 26 // prototype, 140% #define TINT_RAMPING_CORRECTION 10 // production model, 115% +//#define TINT_RAMPING_CORRECTION 0 // none #ifdef RAMP_LENGTH #undef RAMP_LENGTH #endif -// level_calc.py 1 150 7135 1 30 800 +// 1-130: 0 to 100% power +// level_calc.py 3.0 1 130 7135 1 30 800 --pwm 255 +// 131-150: 101% to 200% power +// level_calc.py 8.69 1 150 7135 1 1 1600 --pwm 510 #define RAMP_LENGTH 150 -#define PWM1_LEVELS 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,11,11,12,13,13,14,15,15,16,17,18,18,19,20,21,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,46,48,49,50,51,53,54,56,57,58,60,61,63,64,66,67,69,70,72,74,75,77,79,80,82,84,85,87,89,91,93,95,97,98,100,102,104,106,108,111,113,115,117,119,121,124,126,128,130,133,135,137,140,142,145,147,150,152,155,157,160,163,165,168,171,173,176,179,182,185,188,190,193,196,199,202,205,209,212,215,218,221,224,228,231,234,238,241,245,248,251,255 -#define MAX_1x7135 65 +#define PWM1_LEVELS 1,1,2,2,3,3,4,5,5,6,6,7,8,8,9,10,10,11,12,12,13,14,15,16,17,17,18,19,20,21,22,23,24,25,26,27,28,29,31,32,33,34,35,37,38,39,40,42,43,45,46,47,49,50,52,54,55,57,58,60,62,63,65,67,69,70,72,74,76,78,80,82,84,86,88,90,92,95,97,99,101,104,106,108,111,113,115,118,121,123,126,128,131,134,136,139,142,145,148,150,153,156,159,162,166,169,172,175,178,181,185,188,191,195,198,202,205,209,213,216,220,224,227,231,235,239,243,247,251,255,264,274,284,294,305,316,327,339,351,363,376,389,403,417,431,446,461,477,493,510 +#define MAX_1x7135 130 +#define DEFAULT_LEVEL 70 #define HALFSPEED_LEVEL 14 #define QUARTERSPEED_LEVEL 5 @@ -40,7 +45,7 @@ // set floor and ceiling as far apart as possible // because this lantern isn't overpowered #define RAMP_SMOOTH_FLOOR 1 -#define RAMP_SMOOTH_CEIL 150 +#define RAMP_SMOOTH_CEIL 130 #define RAMP_DISCRETE_FLOOR 10 #define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL #define RAMP_DISCRETE_STEPS 5 @@ -59,14 +64,15 @@ #undef USE_THERMAL_REGULATION #endif -// don't blink while ramping -#ifdef BLINK_AT_RAMP_MIDDLE -#undef BLINK_AT_RAMP_MIDDLE -#endif +// don't blink at floor #ifdef BLINK_AT_RAMP_FLOOR #undef BLINK_AT_RAMP_FLOOR #endif -// except the top... blink at the top +// blink at 100% power +#ifndef BLINK_AT_RAMP_MIDDLE +#define BLINK_AT_RAMP_MIDDLE +#endif +// blink again at the 200% power / ceil / turbo #ifndef BLINK_AT_RAMP_CEIL #define BLINK_AT_RAMP_CEIL #endif diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h index c170645..bc710c2 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h @@ -28,10 +28,13 @@ // 2nd LEDs // output: unknown, 2000 lm? #define RAMP_LENGTH 150 -// level_calc.py 5.01 1 150 7135 1 0.2 2000 --pwm dyn:74:16383:511 // abstract ramp (power is split between both sets of LEDs) -#define PWM1_LEVELS 1,1,1,2,2,2,3,4,4,5,6,6,7,8,9,10,12,13,14,16,17,19,20,22,24,26,28,30,32,35,37,40,42,45,47,50,53,56,59,62,65,68,71,74,77,80,83,86,89,91,94,96,98,100,102,104,105,106,107,107,107,106,105,103,101,98,94,90,84,78,71,63,54,44,33,35,37,38,40,42,44,46,48,50,53,55,57,60,63,65,68,71,74,77,80,83,87,90,94,98,102,106,110,114,118,123,128,132,137,142,148,153,159,164,170,176,183,189,196,202,209,216,224,231,239,247,255,263,272,281,290,299,309,318,328,339,349,360,371,382,394,406,418,430,443,456,469,483,497,511 -#define PWM_TOPS 16383,13673,10738,15435,11908,8123,12779,14756,12240,13447,14013,11907,12263,12351,12261,12048,12926,12464,11972,12278,11704,11789,11180,11134,11013,10837,10620,10371,10100,10113,9793,9718,9376,9248,8898,8738,8560,8369,8168,7961,7749,7535,7321,7107,6895,6686,6480,6278,6080,5823,5639,5403,5178,4965,4763,4570,4346,4134,3936,3714,3507,3283,3074,2853,2648,2433,2211,2006,1776,1564,1351,1137,924,714,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 +// 1-130: 0 to 100% power +// level_calc.py 5.01 1 130 7135 2 0.2 2000 --pwm dyn:64:16383:511 +// 131 to 150: 101% to 200% power +// level_calc.py 6.44 1 150 7135 1 0.2 2000 --pwm dyn:74:16383:1022 +#define PWM1_LEVELS 2,2,2,3,3,4,4,5,6,7,8,9,10,11,13,14,16,17,19,21,23,25,28,30,33,35,38,41,44,47,50,54,57,60,64,67,71,74,78,81,84,88,91,94,97,99,101,103,105,106,107,107,107,106,105,102,99,95,90,84,77,68,58,47,34,36,38,40,42,44,47,49,52,54,57,60,63,66,69,73,76,80,83,87,91,96,100,104,109,114,119,124,130,135,141,147,153,160,166,173,180,187,195,203,211,219,228,236,245,255,264,274,285,295,306,317,329,340,353,365,378,391,405,419,433,448,463,479,495,511,530,550,570,591,612,634,657,680,705,730,755,782,809,837,865,895,925,957,989,1022 +#define PWM_TOPS 16383,13234,9781,13826,9593,13434,9973,12021,12900,13193,13150,12899,12508,12023,12666,11982,12181,11422,11393,11247,11018,10731,10826,10434,10365,9927,9767,9565,9332,9076,8806,8693,8395,8096,7928,7626,7439,7143,6948,6665,6393,6203,5946,5700,5465,5187,4926,4681,4451,4195,3957,3700,3463,3213,2983,2718,2476,2231,1986,1742,1501,1245,997,756,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 #define DEFAULT_LEVEL 70 #define MAX_1x7135 150 #define HALFSPEED_LEVEL 10 @@ -54,8 +57,8 @@ #define SIMPLE_UI_STEPS 5 // stop panicking at ~1500 lm -#define THERM_FASTER_LEVEL 140 -#define MIN_THERM_STEPDOWN 75 // should be above highest dyn_pwm level +#define THERM_FASTER_LEVEL 130 +#define MIN_THERM_STEPDOWN 65 // should be above highest dyn_pwm level // use the brightest setting for strobe #define STROBE_BRIGHTNESS MAX_LEVEL diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 05c2e0e..ee72cd7 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -293,8 +293,14 @@ void update_tint() { // calculate actual PWM levels based on a single-channel ramp // and a global tint value //PWM_DATATYPE brightness = PWM_GET(pwm1_levels, level); - PWM_DATATYPE brightness = PWM1_LVL; - PWM_DATATYPE warm_PWM, cool_PWM; + uint16_t brightness = PWM1_LVL; + uint16_t warm_PWM, cool_PWM; + #ifdef USE_DYN_PWM + uint16_t top = PWM1_TOP; + //uint16_t top = PWM_GET(pwm_tops, actual_level-1); + #else + const uint16_t top = PWM_TOP; + #endif // auto-tint modes uint8_t mytint; @@ -311,18 +317,37 @@ void update_tint() { // stretch 1-254 to fit 0-255 range (hits every value except 98 and 198) else { mytint = (tint * 100 / 99) - 1; } - // middle tints sag, so correct for that effect PWM_DATATYPE2 base_PWM = brightness; - // correction is only necessary when PWM is fast #if defined(TINT_RAMPING_CORRECTION) && (TINT_RAMPING_CORRECTION > 0) + // middle tints sag, so correct for that effect + // by adding extra power which peaks at the middle tint + // (correction is only necessary when PWM is fast) if (level > HALFSPEED_LEVEL) { base_PWM = brightness + ((((PWM_DATATYPE2)brightness) * TINT_RAMPING_CORRECTION / 64) * triangle_wave(mytint) / 255); } + // fade the triangle wave out when above 100% power, + // so it won't go over 200% + if (brightness > top) { + base_PWM -= 2 * ( + ((brightness - top) * TINT_RAMPING_CORRECTION / 64) + * triangle_wave(mytint) / 255 + ); + } + // guarantee no more than 200% power + if (base_PWM > (top << 1)) { base_PWM = top << 1; } #endif cool_PWM = (((PWM_DATATYPE2)mytint * (PWM_DATATYPE2)base_PWM) + 127) / 255; warm_PWM = base_PWM - cool_PWM; + // when running at > 100% power, spill extra over to other channel + if (cool_PWM > top) { + warm_PWM += (cool_PWM - top); + cool_PWM = top; + } else if (warm_PWM > top) { + cool_PWM += (warm_PWM - top); + warm_PWM = top; + } TINT1_LVL = warm_PWM; TINT2_LVL = cool_PWM; diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h index c1f6064..de090c2 100644 --- a/spaghetti-monster/fsm-ramping.h +++ b/spaghetti-monster/fsm-ramping.h @@ -48,26 +48,26 @@ void update_tint(); // auto-detect the data type for PWM tables #ifndef PWM_BITS -#define PWM_BITS 8 -#define PWM_TOP 255 + #define PWM_BITS 8 + #define PWM_TOP 255 #endif #if PWM_BITS <= 8 -#define PWM_DATATYPE uint8_t -#define PWM_DATATYPE2 uint16_t -#define PWM_TOP 255 -#define PWM_GET(x,y) pgm_read_byte(x+y) + #define PWM_DATATYPE uint8_t + #define PWM_DATATYPE2 uint16_t + #define PWM_TOP 255 + #define PWM_GET(x,y) pgm_read_byte(x+y) #else -#define PWM_DATATYPE uint16_t -#ifndef PWM_DATATYPE2 -#define PWM_DATATYPE2 uint32_t -#endif -#ifndef PWM_TOP -#define PWM_TOP 1023 // 10 bits by default -#endif -// pointer plus 2*y bytes -//#define PWM_GET(x,y) pgm_read_word(x+(2*y)) -// nope, the compiler was already doing the math correctly -#define PWM_GET(x,y) pgm_read_word(x+y) + #define PWM_DATATYPE uint16_t + #ifndef PWM_DATATYPE2 + #define PWM_DATATYPE2 uint32_t + #endif + #ifndef PWM_TOP + #define PWM_TOP 1023 // 10 bits by default + #endif + // pointer plus 2*y bytes + //#define PWM_GET(x,y) pgm_read_word(x+(2*y)) + // nope, the compiler was already doing the math correctly + #define PWM_GET(x,y) pgm_read_word(x+y) #endif // use UI-defined ramp tables if they exist -- cgit v1.2.3 From c890237f5ed6fba2f200cba23cff5622818a9ad0 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 31 Oct 2021 02:51:38 -0600 Subject: fixed flicker on inactive tint ramp channel during ramping --- spaghetti-monster/fsm-ramping.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index ee72cd7..49e173f 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -102,6 +102,7 @@ void set_level(uint8_t level) { #endif } else { // enable the power channel, if relevant + #ifndef USE_TINT_RAMPING // update_tint handles this better #ifdef LED_ENABLE_PIN #ifndef LED_ENABLE_PIN_LEVEL_MIN LED_ENABLE_PORT |= (1 << LED_ENABLE_PIN); @@ -117,6 +118,7 @@ void set_level(uint8_t level) { #ifdef LED2_ENABLE_PIN LED2_ENABLE_PORT |= (1 << LED2_ENABLE_PIN); #endif + #endif // ifndef USE_TINT_RAMPING // PWM array index = level - 1 level --; @@ -354,11 +356,15 @@ void update_tint() { // disable the power channel, if relevant #ifdef LED_ENABLE_PIN - if (! warm_PWM) + if (warm_PWM) + LED_ENABLE_PORT |= (1 << LED_ENABLE_PIN); + else LED_ENABLE_PORT &= ~(1 << LED_ENABLE_PIN); #endif #ifdef LED2_ENABLE_PIN - if (! cool_PWM) + if (cool_PWM) + LED2_ENABLE_PORT |= (1 << LED2_ENABLE_PIN); + else LED2_ENABLE_PORT &= ~(1 << LED2_ENABLE_PIN); #endif } -- cgit v1.2.3 From f782cad5199d322815fdf4e1faa61aae5945bad8 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 31 Oct 2021 03:19:13 -0600 Subject: made d4sv2-tintramp-fet work the same as no-fet version, but with added FET from ramp step 141 to 150 (0 to 100% power from 1 to 130, 101% to 200% from 131 to 150, and +DD FET from 141 to 150) also calibrated candle mode a bit better --- .../anduril/cfg-emisar-d4sv2-tintramp-fet.h | 24 ++++++++++++++-------- .../anduril/cfg-emisar-d4sv2-tintramp.h | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h index 3c638a7..657e25d 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp-fet.h @@ -14,22 +14,30 @@ // 2nd LEDs // output: unknown, 2000 lm? #define RAMP_LENGTH 150 +///// copy non-FET ramp, but add FET to the top 10 levels from 141 to 150 +/* old // level_calc.py 5.01 1 140 7135 1 0.2 2000 --pwm dyn:69:16383:511 // plus a FET segment -// level_calc.py 2 1 10 7135 5 50.0 3000 --pwm 255 // abstract ramp (power is split between both sets of LEDs) +// level_calc.py 2 1 10 7135 5 50.0 3000 --pwm 255 // append: ,500,482,456,420,374,318,252,178,94,0 -#undef PWM1_LEVELS -#define PWM1_LEVELS 1,1,1,2,2,3,3,4,5,5,6,7,8,9,10,12,13,14,16,18,19,21,23,25,27,30,32,35,37,40,43,45,48,51,54,58,61,64,67,70,74,77,80,83,86,89,92,95,97,99,101,103,105,106,106,107,106,106,104,102,100,96,92,87,81,73,65,56,45,33,35,37,39,41,43,45,47,49,52,54,57,59,62,65,68,71,74,78,81,85,89,92,96,100,105,109,114,118,123,128,133,139,144,150,156,162,168,175,181,188,195,202,210,217,225,233,242,250,259,268,278,287,297,307,318,328,339,351,362,374,386,399,412,425,438,452,466,481,496,511,500,482,456,420,374,318,252,178,94,0 +*/ +/* also old +// level_calc.py 3 1 11 7135 511 2000 5000 --pwm 1022 +// append: 549,589,633,679,728,780,836,894,957,1022 +//#undef PWM1_LEVELS +//#define PWM1_LEVELS 1,1,1,2,2,3,3,4,5,5,6,7,8,9,10,12,13,14,16,18,19,21,23,25,27,30,32,35,37,40,43,45,48,51,54,58,61,64,67,70,74,77,80,83,86,89,92,95,97,99,101,103,105,106,106,107,106,106,104,102,100,96,92,87,81,73,65,56,45,33,35,37,39,41,43,45,47,49,52,54,57,59,62,65,68,71,74,78,81,85,89,92,96,100,105,109,114,118,123,128,133,139,144,150,156,162,168,175,181,188,195,202,210,217,225,233,242,250,259,268,278,287,297,307,318,328,339,351,362,374,386,399,412,425,438,452,466,481,496,511,549,589,633,679,728,780,836,894,957,1022 // append: ,511,511,511,511,511,511,511,511,511,511 -#undef PWM_TOPS -#define PWM_TOPS 16383,13469,10296,14694,10845,14620,11496,13507,14400,11954,12507,12676,12605,12376,12036,12805,12240,11650,11882,11933,11243,11155,10988,10763,10497,10569,10223,10164,9781,9646,9475,9071,8870,8652,8422,8330,8077,7823,7569,7318,7169,6919,6676,6439,6209,5986,5770,5561,5305,5063,4834,4618,4413,4180,3925,3723,3468,3264,3016,2787,2576,2333,2111,1885,1658,1412,1189,968,734,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 +//#undef PWM_TOPS +//#define PWM_TOPS 16383,13469,10296,14694,10845,14620,11496,13507,14400,11954,12507,12676,12605,12376,12036,12805,12240,11650,11882,11933,11243,11155,10988,10763,10497,10569,10223,10164,9781,9646,9475,9071,8870,8652,8422,8330,8077,7823,7569,7318,7169,6919,6676,6439,6209,5986,5770,5561,5305,5063,4834,4618,4413,4180,3925,3723,3468,3264,3016,2787,2576,2333,2111,1885,1658,1412,1189,968,734,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511 +*/ + // prepend: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, #define PWM2_LEVELS 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,14,27,45,68,96,129,166,208,255 #undef DEFAULT_LEVEL #define DEFAULT_LEVEL 70 #undef MAX_1x7135 -#define MAX_1x7135 140 +#define MAX_1x7135 130 #undef RAMP_SMOOTH_FLOOR #define RAMP_SMOOTH_FLOOR 10 // level 1 is unreliable (?) @@ -53,9 +61,9 @@ // stop panicking at ~2000 lm #undef THERM_FASTER_LEVEL -#define THERM_FASTER_LEVEL 140 +#define THERM_FASTER_LEVEL 130 #undef MIN_THERM_STEPDOWN -#define MIN_THERM_STEPDOWN 70 // should be above highest dyn_pwm level +#define MIN_THERM_STEPDOWN 65 // should be above highest dyn_pwm level // speed up party strobe; the FET is really fast #undef PARTY_STROBE_ONTIME diff --git a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h index bc710c2..3e54dca 100644 --- a/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h +++ b/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h @@ -66,7 +66,7 @@ #define PARTY_STROBE_ONTIME 2 // the default of 26 looks a bit flat, so increase it -#define CANDLE_AMPLITUDE 40 +#define CANDLE_AMPLITUDE 33 // the power regulator is a bit slow, so push it harder for a quick response from off #define DEFAULT_JUMP_START_LEVEL 21 -- cgit v1.2.3 From 03ccd35ea79cba1e8647d02dd79e44eac2a6568d Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 31 Oct 2021 03:41:10 -0600 Subject: documented number entry 1H action (add 10) in UI table --- spaghetti-monster/anduril/anduril-manual.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/anduril-manual.txt b/spaghetti-monster/anduril/anduril-manual.txt index 009e95e..34ae1bb 100644 --- a/spaghetti-monster/anduril/anduril-manual.txt +++ b/spaghetti-monster/anduril/anduril-manual.txt @@ -819,3 +819,4 @@ Config menus Full Hold Skip current item with no changes Config menus Full Release Configure current item Number entry Full Click Add 1 to value for current item +Number entry Full Hold Add 10 to value for current item -- cgit v1.2.3 From ccacc3931e1dd3e27483c930b40326c968f1e91e Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 3 Nov 2021 02:42:12 -0600 Subject: added KR4-tintramp build (is basically identical to D4Sv2-tintramp, but with the switch on a different pin, and no button LED) --- spaghetti-monster/anduril/cfg-noctigon-kr4-tintramp.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 spaghetti-monster/anduril/cfg-noctigon-kr4-tintramp.h (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/cfg-noctigon-kr4-tintramp.h b/spaghetti-monster/anduril/cfg-noctigon-kr4-tintramp.h new file mode 100644 index 0000000..f19744d --- /dev/null +++ b/spaghetti-monster/anduril/cfg-noctigon-kr4-tintramp.h @@ -0,0 +1,12 @@ +// Noctigon KR4 tint-ramping config options for Anduril +// (basically the same as Emisar D4S V2 tint-ramping, +// but switch on a different pin, and no lighted button) +// ATTINY: 1634 +#include "hwdef-Noctigon_KR4-tintramp.h" +#include "cfg-emisar-d4sv2-tintramp.h" +#undef MODEL_NUMBER +#define MODEL_NUMBER "0215" + +// the button doesn't light up +#undef USE_BUTTON_LED + -- cgit v1.2.3 From efd3f3ebdb0898d79e44d984cedd4c0409902e25 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 3 Nov 2021 04:16:05 -0600 Subject: added runtime config to choose tint-ramping or tint-toggle (Off->9H option 1, 0=smooth, 1=toggle) --- spaghetti-monster/anduril/anduril-manual.txt | 10 ++++++ spaghetti-monster/anduril/load-save-config-fsm.h | 1 + spaghetti-monster/anduril/load-save-config.c | 2 ++ spaghetti-monster/anduril/ramp-mode-fsm.h | 2 +- spaghetti-monster/anduril/ramp-mode.c | 7 ++-- spaghetti-monster/anduril/ramp-mode.h | 10 ++++++ spaghetti-monster/anduril/tint-ramping.c | 46 +++++++++--------------- spaghetti-monster/anduril/tint-ramping.h | 8 +++++ 8 files changed, 54 insertions(+), 32 deletions(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/anduril-manual.txt b/spaghetti-monster/anduril/anduril-manual.txt index 34ae1bb..8d6ad75 100644 --- a/spaghetti-monster/anduril/anduril-manual.txt +++ b/spaghetti-monster/anduril/anduril-manual.txt @@ -692,6 +692,11 @@ Misc Config Menu Some models may have an extra config menu for settings which don't fit anywhere else. These settings are, in order: + - Tint ramp style: + + 0 = smooth (blend channels in any proportion) + 1 = toggle (only one channel active at a time) + - Jump Start level: Some lights are prone to starting up slowly at low levels, so they @@ -728,6 +733,11 @@ be warm white while dim, or cool white while bright. Or vice-versa. To access this, ramp to the end of the tint range, then keep holding until the light blinks a second time. +The misc config menu also has a setting to choose a tint ramp style. +This can be smooth, allowing the user to smoothly blend both channels in +whatever ratio they desire... or it can be "tint toggle" style, where +only one channel is active at a time. + UI Reference Table ------------------ diff --git a/spaghetti-monster/anduril/load-save-config-fsm.h b/spaghetti-monster/anduril/load-save-config-fsm.h index 894c344..ba3c69b 100644 --- a/spaghetti-monster/anduril/load-save-config-fsm.h +++ b/spaghetti-monster/anduril/load-save-config-fsm.h @@ -60,6 +60,7 @@ typedef enum { #endif #ifdef USE_TINT_RAMPING tint_e, + tint_style_e, #endif #ifdef USE_JUMP_START jump_start_level_e, diff --git a/spaghetti-monster/anduril/load-save-config.c b/spaghetti-monster/anduril/load-save-config.c index ee451ac..4987def 100644 --- a/spaghetti-monster/anduril/load-save-config.c +++ b/spaghetti-monster/anduril/load-save-config.c @@ -62,6 +62,7 @@ void load_config() { #endif #ifdef USE_TINT_RAMPING tint = eeprom[tint_e]; + tint_style = eeprom[tint_style_e]; #endif #ifdef USE_JUMP_START jump_start_level = eeprom[jump_start_level_e], @@ -140,6 +141,7 @@ void save_config() { #endif #ifdef USE_TINT_RAMPING eeprom[tint_e] = tint; + eeprom[tint_style_e] = tint_style; #endif #ifdef USE_JUMP_START eeprom[jump_start_level_e] = jump_start_level, diff --git a/spaghetti-monster/anduril/ramp-mode-fsm.h b/spaghetti-monster/anduril/ramp-mode-fsm.h index 7f67d1e..1a062e9 100644 --- a/spaghetti-monster/anduril/ramp-mode-fsm.h +++ b/spaghetti-monster/anduril/ramp-mode-fsm.h @@ -47,7 +47,7 @@ #endif // include an extra config mode for random stuff which doesn't fit elsewhere -#if defined(USE_JUMP_START) +#if defined(USE_TINT_RAMPING) || defined(USE_JUMP_START) #define USE_GLOBALS_CONFIG #endif diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index 6d85480..851f5a4 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -551,14 +551,17 @@ uint8_t ramp_extras_config_state(Event event, uint16_t arg) { #ifdef USE_GLOBALS_CONFIG void globals_config_save(uint8_t step, uint8_t value) { if (0) {} + #ifdef USE_TINT_RAMPING + else if (step == 1+tint_style_config_step) { tint_style = value; } + #endif #ifdef USE_JUMP_START - else { jump_start_level = value; } + else if (step == 1+jump_start_config_step) { jump_start_level = value; } #endif } uint8_t globals_config_state(Event event, uint16_t arg) { // TODO: set number of steps based on how many configurable options - return config_state_base(event, arg, 1, globals_config_save); + return config_state_base(event, arg, globals_config_num_steps, globals_config_save); } #endif diff --git a/spaghetti-monster/anduril/ramp-mode.h b/spaghetti-monster/anduril/ramp-mode.h index bba6d96..93756ab 100644 --- a/spaghetti-monster/anduril/ramp-mode.h +++ b/spaghetti-monster/anduril/ramp-mode.h @@ -224,6 +224,16 @@ uint8_t ramp_stepss[] = { uint8_t ramp_discrete_step_size; // don't set this #ifdef USE_GLOBALS_CONFIG +typedef enum { + #ifdef USE_TINT_RAMPING + tint_style_config_step, + #endif + #ifdef USE_JUMP_START + jump_start_config_step, + #endif + globals_config_num_steps +} globals_config_steps_e; + void globals_config_save(uint8_t step, uint8_t value); uint8_t globals_config_state(Event event, uint16_t arg); #endif diff --git a/spaghetti-monster/anduril/tint-ramping.c b/spaghetti-monster/anduril/tint-ramping.c index aa9b1f6..6cc0616 100644 --- a/spaghetti-monster/anduril/tint-ramping.c +++ b/spaghetti-monster/anduril/tint-ramping.c @@ -22,31 +22,6 @@ #include "tint-ramping.h" -#ifdef TINT_RAMP_TOGGLE_ONLY - -uint8_t tint_ramping_state(Event event, uint16_t arg) { - // click, click, hold: change the tint - if (event == EV_click3_hold) { - // toggle once on first frame; ignore other frames - if (! arg) { - tint = !tint; - set_level(actual_level); - //blink_once(); // unnecessary, and kind of annoying on moon - } - return EVENT_HANDLED; - } - - // click, click, hold, release: save config - else if (event == EV_click3_hold_release) { - // remember tint after battery change - save_config(); - return EVENT_HANDLED; - } - - return EVENT_NOT_HANDLED; -} - -#else // no TINT_RAMP_TOGGLE_ONLY uint8_t tint_ramping_state(Event event, uint16_t arg) { static int8_t tint_ramp_direction = 1; @@ -61,6 +36,21 @@ uint8_t tint_ramping_state(Event event, uint16_t arg) { // click, click, hold: change the tint if (event == EV_click3_hold) { + ///// tint-toggle mode + // toggle once on first frame; ignore other frames + if (tint_style) { + // only respond on first frame + if (arg) return EVENT_NOT_HANDLED; + + // force tint to be 1 or 254 + if (tint != 254) { tint = 1; } + // invert between 1 and 254 + tint = tint ^ 0xFF; + set_level(actual_level); + return EVENT_HANDLED; + } + + ///// smooth tint-ramp mode // reset at beginning of movement if (! arg) { active = 1; // first frame means this is for us @@ -98,8 +88,8 @@ uint8_t tint_ramping_state(Event event, uint16_t arg) { active = 0; // ignore next hold if it wasn't meant for us // reverse tint_ramp_direction = -tint_ramp_direction; - if (tint == 0) tint_ramp_direction = 1; - else if (tint == 255) tint_ramp_direction = -1; + if (tint <= 1) tint_ramp_direction = 1; + else if (tint >= 254) tint_ramp_direction = -1; // remember tint after battery change save_config(); return EVENT_HANDLED; @@ -108,8 +98,6 @@ uint8_t tint_ramping_state(Event event, uint16_t arg) { return EVENT_NOT_HANDLED; } -#endif // ifdef TINT_RAMP_TOGGLE_ONLY - #endif diff --git a/spaghetti-monster/anduril/tint-ramping.h b/spaghetti-monster/anduril/tint-ramping.h index e482999..1c5e22a 100644 --- a/spaghetti-monster/anduril/tint-ramping.h +++ b/spaghetti-monster/anduril/tint-ramping.h @@ -20,6 +20,14 @@ #ifndef TINT_RAMPING_H #define TINT_RAMPING_H +// 0: smooth tint ramp +// 1: toggle tint only between two extremes +#ifdef TINT_RAMP_TOGGLE_ONLY +uint8_t tint_style = 1; +#else +uint8_t tint_style = 0; +#endif + #ifdef USE_MANUAL_MEMORY uint8_t manual_memory_tint; #endif -- cgit v1.2.3 From c33100dcfbaee04e6992191defa3bf1e6be80b1e Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 3 Nov 2021 04:46:56 -0600 Subject: reset tint while changing tint ramp style --- spaghetti-monster/anduril/ramp-mode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/ramp-mode.c b/spaghetti-monster/anduril/ramp-mode.c index 851f5a4..93b936a 100644 --- a/spaghetti-monster/anduril/ramp-mode.c +++ b/spaghetti-monster/anduril/ramp-mode.c @@ -552,7 +552,11 @@ uint8_t ramp_extras_config_state(Event event, uint16_t arg) { void globals_config_save(uint8_t step, uint8_t value) { if (0) {} #ifdef USE_TINT_RAMPING - else if (step == 1+tint_style_config_step) { tint_style = value; } + else if (step == 1+tint_style_config_step) { + tint_style = !(!(value)); + // set tint to middle or edge depending on style being smooth or toggle + tint = tint_style ? 1 : 127; + } #endif #ifdef USE_JUMP_START else if (step == 1+jump_start_config_step) { jump_start_level = value; } -- cgit v1.2.3 From c3f547d5edfbca0ed78190d9d8b8f3609baebb5f Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 3 Nov 2021 20:33:01 -0600 Subject: fixed KR4-tintramp build (switch wasn't working) and added it to MODELS --- spaghetti-monster/anduril/MODELS | 1 + 1 file changed, 1 insertion(+) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/MODELS b/spaghetti-monster/anduril/MODELS index ca9da30..a125f53 100644 --- a/spaghetti-monster/anduril/MODELS +++ b/spaghetti-monster/anduril/MODELS @@ -20,6 +20,7 @@ Model Name MCU 0212 noctigon-kr4-nofet attiny1634 0213 noctigon-kr4-219 attiny1634 0214 noctigon-kr4-219b attiny1634 +0215 noctigon-kr4-tintramp attiny1634 0251 noctigon-k1 attiny1634 0252 noctigon-k1-sbt90 attiny1634 0253 noctigon-k1-12v attiny1634 -- cgit v1.2.3