aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-main.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2021-09-19 21:26:24 -0600
committerSelene ToyKeeper2021-09-19 21:26:24 -0600
commitf98736fe179a8ea26bfd44494a23db16ac4099bb (patch)
tree266bad0f063dce3b467e4393a08d594a314f5b0c /spaghetti-monster/fsm-main.c
parentclarified where brightness level comes from in beacon/sos/momentary modes (diff)
parentSP10 Pro: use dynamic PWM, add hidden firefly, adjust candle amplitude, and t... (diff)
downloadanduril-f98736fe179a8ea26bfd44494a23db16ac4099bb.tar.gz
anduril-f98736fe179a8ea26bfd44494a23db16ac4099bb.tar.bz2
anduril-f98736fe179a8ea26bfd44494a23db16ac4099bb.zip
merged gchart's SP10 Pro branch
(minus the change to version.h)
Diffstat (limited to 'spaghetti-monster/fsm-main.c')
-rw-r--r--spaghetti-monster/fsm-main.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-main.c b/spaghetti-monster/fsm-main.c
index 7031009..30b8a67 100644
--- a/spaghetti-monster/fsm-main.c
+++ b/spaghetti-monster/fsm-main.c
@@ -46,19 +46,30 @@ static inline void hw_setup() {
DDRB |= (1 << PWM1_PIN);
TCCR0B = 0x01; // pre-scaler for timer (1 => 1, 2 => 8, 3 => 64...)
TCCR0A = PHASE;
+ #if (PWM1_PIN == PB4) // Second PWM counter is ... weird
+ TCCR1 = _BV (CS10);
+ GTCCR = _BV (COM1B1) | _BV (PWM1B);
+ OCR1C = 255; // Set ceiling value to maximum
+ #endif
#endif
// tint ramping needs second channel enabled,
// despite PWM_CHANNELS being only 1
#if (PWM_CHANNELS >= 2) || defined(USE_TINT_RAMPING)
DDRB |= (1 << PWM2_PIN);
+ #if (PWM2_PIN == PB4) // Second PWM counter is ... weird
+ TCCR1 = _BV (CS10);
+ GTCCR = _BV (COM1B1) | _BV (PWM1B);
+ OCR1C = 255; // Set ceiling value to maximum
+ #endif
#endif
#if PWM_CHANNELS >= 3
- // Second PWM counter is ... weird
DDRB |= (1 << PWM3_PIN);
+ #if (PWM3_PIN == PB4) // Second PWM counter is ... weird
TCCR1 = _BV (CS10);
GTCCR = _BV (COM1B1) | _BV (PWM1B);
OCR1C = 255; // Set ceiling value to maximum
#endif
+ #endif
#if PWM_CHANNELS >= 4
// 4th PWM channel is ... not actually supported in hardware :(
DDRB |= (1 << PWM4_PIN);