From 9765caab66ab628d763a5148efde80b3c3930b31 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 29 Apr 2023 01:19:42 -0600 Subject: Noctigon KR4: updated to use new channel system (also tweaked D4v2 build to match KR4 as much as possible) (also added Extended Simple UI to Hank's config) --- hwdef-noctigon-kr4.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 hwdef-noctigon-kr4.c (limited to 'hwdef-noctigon-kr4.c') diff --git a/hwdef-noctigon-kr4.c b/hwdef-noctigon-kr4.c new file mode 100644 index 0000000..bcb98fc --- /dev/null +++ b/hwdef-noctigon-kr4.c @@ -0,0 +1,51 @@ +// Noctigon KR4 PWM helper functions +// Copyright (C) 2020-2023 Selene ToyKeeper +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include "chan-rgbaux.c" + +// single set of LEDs with 2 stacked power channels, linear + DD FET +void set_level_main(uint8_t level) { + if (level == 0) { + CH1_PWM = 0; + CH2_PWM = 0; + PWM_CNT = 0; // reset phase + CH1_ENABLE_PORT &= ~(1 << CH1_ENABLE_PIN); // disable opamp + return; + } + + CH1_ENABLE_PORT |= (1 << CH1_ENABLE_PIN); // enable opamp + + level --; // PWM array index = level - 1 + PWM_DATATYPE ch1_pwm = PWM_GET(pwm1_levels, level); + PWM_DATATYPE ch2_pwm = PWM_GET(pwm2_levels, level); + // pulse frequency modulation, a.k.a. dynamic PWM + uint16_t top = PWM_GET(pwm_tops, level); + + CH1_PWM = ch1_pwm; + CH2_PWM = ch2_pwm; + // wait to sync the counter and avoid flashes + while(actual_level && (PWM_CNT > (top - 32))) {} + PWM_TOP = top; + // force reset phase when turning on from zero + // (because otherwise the initial response is inconsistent) + if (! actual_level) PWM_CNT = 0; +} + +bool gradual_tick_main(uint8_t gt) { + PWM_DATATYPE pwm1 = PWM_GET(pwm1_levels, gt); + PWM_DATATYPE pwm2 = PWM_GET(pwm2_levels, gt); + + GRADUAL_ADJUST_STACKED(pwm1, CH1_PWM, PWM_TOP_INIT); + GRADUAL_ADJUST_SIMPLE (pwm2, CH2_PWM); + + if ( (pwm1 == CH1_PWM) + && (pwm2 == CH2_PWM) + ) { + return true; // done + } + return false; // not done yet +} + -- cgit v1.2.3 From 0c88040fa1c2f3ffd5f6b6f6f5b12f5bd2193b06 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 29 Apr 2023 01:45:00 -0600 Subject: KR4: ramp can use 8 bits, since values never go over 255 also, don't blink at top of linear range --- hwdef-noctigon-kr4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hwdef-noctigon-kr4.c') diff --git a/hwdef-noctigon-kr4.c b/hwdef-noctigon-kr4.c index bcb98fc..5813a9b 100644 --- a/hwdef-noctigon-kr4.c +++ b/hwdef-noctigon-kr4.c @@ -22,7 +22,7 @@ void set_level_main(uint8_t level) { PWM_DATATYPE ch1_pwm = PWM_GET(pwm1_levels, level); PWM_DATATYPE ch2_pwm = PWM_GET(pwm2_levels, level); // pulse frequency modulation, a.k.a. dynamic PWM - uint16_t top = PWM_GET(pwm_tops, level); + uint16_t top = PWM_GET16(pwm_tops, level); CH1_PWM = ch1_pwm; CH2_PWM = ch2_pwm; -- cgit v1.2.3 From 723b5b1ffa8f12b29110a2133a8f09beaf528aad Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 16 Jul 2023 16:27:44 -0600 Subject: fixed d4v2, kr4, m44, emisar-2ch (using new refactor), added RGB aux channel modes to models which didn't have it --- hwdef-noctigon-kr4.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'hwdef-noctigon-kr4.c') diff --git a/hwdef-noctigon-kr4.c b/hwdef-noctigon-kr4.c index 5813a9b..e49ff69 100644 --- a/hwdef-noctigon-kr4.c +++ b/hwdef-noctigon-kr4.c @@ -6,6 +6,19 @@ #include "chan-rgbaux.c" +void set_level_main(uint8_t level); +bool gradual_tick_main(uint8_t gt); + + +Channel channels[] = { + { // channel 1 only + .set_level = set_level_main, + .gradual_tick = gradual_tick_main + }, + RGB_AUX_CHANNELS +}; + + // single set of LEDs with 2 stacked power channels, linear + DD FET void set_level_main(uint8_t level) { if (level == 0) { -- cgit v1.2.3 From d34d0e7acb1f1e49d21af7cf1c9e08161ce95dd4 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sun, 17 Sep 2023 04:37:25 -0600 Subject: fixed builds which weren't using set_level_zero() yet... - emisar-d4 - emisar-d4v2 - emisar-d4v2-nofet - emisar-d4sv2 - emisar-2ch - emisar-2ch-fet - noctigon-dm11-boost - noctigon-k1 - noctigon-kr4 - noctigon-kr4-nofet - sofirn-lt1s-pro ... and removed old build targets for d4sv2-tintramp, because it was replaced by emisar-2ch a while ago. --- hwdef-noctigon-kr4.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'hwdef-noctigon-kr4.c') diff --git a/hwdef-noctigon-kr4.c b/hwdef-noctigon-kr4.c index e49ff69..b721bdc 100644 --- a/hwdef-noctigon-kr4.c +++ b/hwdef-noctigon-kr4.c @@ -6,6 +6,8 @@ #include "chan-rgbaux.c" +void set_level_zero(); + void set_level_main(uint8_t level); bool gradual_tick_main(uint8_t gt); @@ -19,19 +21,17 @@ Channel channels[] = { }; +void set_level_zero() { + CH1_PWM = 0; + CH2_PWM = 0; + PWM_CNT = 0; // reset phase + CH1_ENABLE_PORT &= ~(1 << CH1_ENABLE_PIN); // disable opamp +} + // single set of LEDs with 2 stacked power channels, linear + DD FET void set_level_main(uint8_t level) { - if (level == 0) { - CH1_PWM = 0; - CH2_PWM = 0; - PWM_CNT = 0; // reset phase - CH1_ENABLE_PORT &= ~(1 << CH1_ENABLE_PIN); // disable opamp - return; - } - CH1_ENABLE_PORT |= (1 << CH1_ENABLE_PIN); // enable opamp - level --; // PWM array index = level - 1 PWM_DATATYPE ch1_pwm = PWM_GET(pwm1_levels, level); PWM_DATATYPE ch2_pwm = PWM_GET(pwm2_levels, level); // pulse frequency modulation, a.k.a. dynamic PWM -- cgit v1.2.3 From 75e2290da9505a4e631e0debf65bdf2da2029e16 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 31 Oct 2023 11:42:00 -0600 Subject: converted fw3x-lume1 to new API, I think (needs testing on actual hardware, and ideally tweaking to improve performance) --- hwdef-noctigon-kr4.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hwdef-noctigon-kr4.c') diff --git a/hwdef-noctigon-kr4.c b/hwdef-noctigon-kr4.c index b721bdc..884151d 100644 --- a/hwdef-noctigon-kr4.c +++ b/hwdef-noctigon-kr4.c @@ -1,7 +1,6 @@ // Noctigon KR4 PWM helper functions // Copyright (C) 2020-2023 Selene ToyKeeper // SPDX-License-Identifier: GPL-3.0-or-later - #pragma once #include "chan-rgbaux.c" -- cgit v1.2.3