FastLED 3.10.9
Loading...
Searching...
No Matches

◆ setPwm16()

void fl::setPwm16 ( int pin,
u16 val )

Set PWM duty cycle with 16-bit resolution.

Parameters
pinPin number (platform-specific numbering)
valPWM duty cycle (0-65535, platform-specific maximum)

Definition at line 269 of file pin.cpp.hpp.

269 {
271
273 // Route to ISR duty cycle update (scale 16-bit to 8-bit)
274 u8 duty = static_cast<u8>(val >> 8);
276 ch->duty_cycle = duty;
277 ch->high_ticks = (static_cast<u32>(ch->period_ticks) * duty) / 256;
278 return;
279 }
280
281 if (ch && ch->backend == pwm_state::PwmBackend::Native) {
282 platforms::setPwm16(pin, val);
283 return;
284 }
285
286 // No setPwmFrequency called — forward to platform as before
287 platforms::setPwm16(pin, val);
288}
RAII helper for critical sections (interrupt disable/enable) Automatically disables interrupts on con...
PwmPinState * findByPin(int pin) FL_NO_EXCEPT
Definition pin.cpp.hpp:155
unsigned char u8
Definition stdint.h:131

References fl::pwm_state::PwmPinState::backend, fl::pwm_state::PwmPinState::duty_cycle, fl::pwm_state::findByPin(), FL_NO_EXCEPT, fl::pwm_state::PwmPinState::high_ticks, fl::pwm_state::IsrSoftware, fl::pwm_state::Native, and fl::pwm_state::PwmPinState::period_ticks.

Referenced by analogWrite16().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: