From 882567cd08e15d73aee0802fd1b1c31076801a02 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 29 Apr 2023 02:50:03 -0600 Subject: converted KR4-nofet build --- hwdef-noctigon-kr4-nofet.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 hwdef-noctigon-kr4-nofet.c (limited to 'hwdef-noctigon-kr4-nofet.c') diff --git a/hwdef-noctigon-kr4-nofet.c b/hwdef-noctigon-kr4-nofet.c new file mode 100644 index 0000000..ec984df --- /dev/null +++ b/hwdef-noctigon-kr4-nofet.c @@ -0,0 +1,47 @@ +// Noctigon KR4 (no DD FET) 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 linear power channel +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); + // pulse frequency modulation, a.k.a. dynamic PWM + uint16_t top = PWM_GET16(pwm_tops, level); + + CH1_PWM = ch1_pwm; + CH2_PWM = 0; + // 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); + + GRADUAL_ADJUST_SIMPLE(pwm1, CH1_PWM); + + if ( (pwm1 == CH1_PWM) + ) { + return true; // done + } + return false; // not done yet +} + -- 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-nofet.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'hwdef-noctigon-kr4-nofet.c') diff --git a/hwdef-noctigon-kr4-nofet.c b/hwdef-noctigon-kr4-nofet.c index ec984df..8ce9525 100644 --- a/hwdef-noctigon-kr4-nofet.c +++ b/hwdef-noctigon-kr4-nofet.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 linear power channel 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-nofet.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'hwdef-noctigon-kr4-nofet.c') diff --git a/hwdef-noctigon-kr4-nofet.c b/hwdef-noctigon-kr4-nofet.c index 8ce9525..0492def 100644 --- a/hwdef-noctigon-kr4-nofet.c +++ b/hwdef-noctigon-kr4-nofet.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 linear power channel 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); // pulse frequency modulation, a.k.a. dynamic PWM uint16_t top = PWM_GET16(pwm_tops, level); -- cgit v1.2.3