This commit is contained in:
2025-11-08 23:35:19 +01:00
parent 256a77b3fa
commit ca5a36449a

14
main.c
View File

@ -150,6 +150,9 @@ static inline void switchMode(void)
eModeCurrent = (eModeCurrent + 1) % MAX_COUNT; eModeCurrent = (eModeCurrent + 1) % MAX_COUNT;
} }
/**
* @brief Init PWM for PA2
*/
void initPWM(void) void initPWM(void)
{ {
// No PORTMUX needed - PA2 is WO2 by default // No PORTMUX needed - PA2 is WO2 by default
@ -164,6 +167,9 @@ void initPWM(void)
TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc | TCA_SINGLE_ENABLE_bm; TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc | TCA_SINGLE_ENABLE_bm;
} }
/**
* @brief Set PWM duty cycle for PA2
*/
void setPWM_PA2(uint8_t duty) void setPWM_PA2(uint8_t duty)
{ {
TCA0.SINGLE.CMP2 = duty; TCA0.SINGLE.CMP2 = duty;
@ -421,14 +427,14 @@ void ledAnimationGlow(void)
brightness += direction; brightness += direction;
// Reverse direction at limits // Reverse direction at limits
if (brightness >= 100) if (brightness >= 100U)
{ {
brightness = 100; brightness = 100U;
direction = -1; direction = -1;
} }
else if (brightness == 0) else if (brightness == 10U)
{ {
brightness = 0; brightness = 10U;
direction = 1; direction = 1;
} }