FastLED 3.9.15
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 249 of file pin.cpp.hpp.

249 {
251
253 // Route to ISR duty cycle update (scale 16-bit to 8-bit)
254 u8 duty = static_cast<u8>(val >> 8);
256 ch->duty_cycle = duty;
257 ch->high_ticks = (static_cast<u32>(ch->period_ticks) * duty) / 256;
258 return;
259 }
260
261 if (ch && ch->backend == pwm_state::PwmBackend::Native) {
262 platforms::setPwm16(pin, val);
263 return;
264 }
265
266 // No setPwmFrequency called — forward to platform as before
267 platforms::setPwm16(pin, val);
268}
RAII helper for critical sections (interrupt disable/enable) Automatically disables interrupts on con...
PwmPinState * findByPin(int pin)
Definition pin.cpp.hpp:141
unsigned char u8
Definition stdint.h:131

References fl::pwm_state::PwmPinState::backend, fl::pwm_state::PwmPinState::duty_cycle, fl::pwm_state::findByPin(), 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: