FastLED 3.10.8
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 265 of file pin.cpp.hpp.

265 {
267
269 // Route to ISR duty cycle update (scale 16-bit to 8-bit)
270 u8 duty = static_cast<u8>(val >> 8);
272 ch->duty_cycle = duty;
273 ch->high_ticks = (static_cast<u32>(ch->period_ticks) * duty) / 256;
274 return;
275 }
276
277 if (ch && ch->backend == pwm_state::PwmBackend::Native) {
278 platforms::setPwm16(pin, val);
279 return;
280 }
281
282 // No setPwmFrequency called — forward to platform as before
283 platforms::setPwm16(pin, val);
284}
RAII helper for critical sections (interrupt disable/enable) Automatically disables interrupts on con...
PwmPinState * findByPin(int pin) FL_NO_EXCEPT
Definition pin.cpp.hpp:154
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: