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-emisar-2ch.h | 115 ++++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 58 deletions(-) (limited to 'hwdef-emisar-2ch.h') diff --git a/hwdef-emisar-2ch.h b/hwdef-emisar-2ch.h index 8b0ffc0..9d1b185 100644 --- a/hwdef-emisar-2ch.h +++ b/hwdef-emisar-2ch.h @@ -28,11 +28,12 @@ * ADC12 thermal sensor */ -#define HWDEF_C_FILE hwdef-emisar-2ch.c - #define ATTINY 1634 #include +#define HWDEF_C_FILE hwdef-emisar-2ch.c + +#define USE_CHANNEL_MODES // channel modes: // * 0. channel 1 only // * 1. channel 2 only @@ -48,11 +49,10 @@ #define CHANNEL_MODES_ENABLED 0b00011111 #define CHANNEL_HAS_ARGS 0b00011000 +#define USE_CHANNEL_MODE_ARGS // _, _, _, 128=middle CCT, 0=warm-to-cool #define CHANNEL_MODE_ARGS 0,0,0,128,0 -#define USE_CHANNEL_MODES -#define USE_CHANNEL_MODE_ARGS #define SET_LEVEL_MODES set_level_ch1, \ set_level_ch2, \ set_level_both, \ @@ -70,7 +70,7 @@ #define PWM_CHANNELS 1 // old, remove this -#define PWM_BITS 16 // 0 to 16383 at variable Hz, not 0 to 255 at 16 kHz +#define PWM_BITS 16 // 0 to 16383 at variable Hz, not 0 to 255 at 16 kHz #define PWM_GET PWM_GET16 #define PWM_DATATYPE uint16_t #define PWM_DATATYPE2 uint32_t // only needs 32-bit if ramp values go over 255 @@ -80,7 +80,7 @@ // PWM parameters of both channels are tied together because they share a counter #define PWM_TOP ICR1 // holds the TOP value for for variable-resolution PWM -#define PWM_TOP_INIT 511 +#define PWM_TOP_INIT 511 // highest value used in top half of ramp #define PWM_CNT TCNT1 // for dynamic PWM, reset phase #define CH1_PIN PB3 // pin 16, Opamp reference @@ -96,7 +96,7 @@ //#define CH3_PIN PC0 // pin 15, DD FET PWM //#define CH3_LVL OCR0A // OCR0A is the output compare register for PC0 - +// e-switch #ifndef SWITCH_PIN #define SWITCH_PIN PA7 // pin 20 #define SWITCH_PCINT PCINT7 // pin 20 pin change interrupt @@ -164,59 +164,58 @@ bool gradual_tick_blend(uint8_t gt); bool gradual_tick_auto(uint8_t gt); -// with so many pins, doing this all with #ifdefs gets awkward... -// ... so just hardcode it in each hwdef file instead inline void hwdef_setup() { - // enable output ports - //DDRC = (1 << CH3_PIN); - DDRB = (1 << CH1_PIN); - DDRA = (1 << CH2_PIN) - | (1 << AUXLED_R_PIN) - | (1 << AUXLED_G_PIN) - | (1 << AUXLED_B_PIN) - | (1 << BUTTON_LED_PIN) - | (1 << CH1_ENABLE_PIN) - | (1 << CH2_ENABLE_PIN) - ; - - // configure PWM - // Setup PWM. F_pwm = F_clkio / 2 / N / TOP, where N = prescale factor, TOP = top of counter - // pre-scale for timer: N = 1 - // Linear opamp PWM for both main and 2nd LEDs (10-bit) - // WGM1[3:0]: 1,0,1,0: PWM, Phase Correct, adjustable (DS table 12-5) - // CS1[2:0]: 0,0,1: clk/1 (No prescaling) (DS table 12-6) - // COM1A[1:0]: 1,0: PWM OC1A in the normal direction (DS table 12-4) - // COM1B[1:0]: 1,0: PWM OC1B in the normal direction (DS table 12-4) - TCCR1A = (1<