MCPcopy Create free account
hub / github.com/FastLED/FastLED / setPwm16

Function setPwm16

src/fl/system/pin.cpp.hpp:249–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249void setPwm16(int pin, u16 val) {
250 pwm_state::PwmPinState* ch = pwm_state::findByPin(pin);
251
252 if (ch && ch->backend == pwm_state::PwmBackend::IsrSoftware) {
253 // Route to ISR duty cycle update (scale 16-bit to 8-bit)
254 u8 duty = static_cast<u8>(val >> 8);
255 fl::isr::critical_section cs;
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}
269
270// ============================================================================
271// PWM Frequency API

Callers 2

analogWrite16Function · 0.70
FL_TEST_FILEFunction · 0.50

Calls 1

findByPinFunction · 0.85

Tested by

no test coverage detected