FastLED 3.9.15
Loading...
Searching...
No Matches

◆ analogWrite()

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

Write analog value to pin (PWM)

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

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

227 {
229
231 // Route to ISR duty cycle update (scale 8-bit val to duty)
232 u8 duty = (val > 255) ? 255 : static_cast<u8>(val);
234 ch->duty_cycle = duty;
235 ch->high_ticks = (static_cast<u32>(ch->period_ticks) * duty) / 256;
236 return;
237 }
238
239 if (ch && ch->backend == pwm_state::PwmBackend::Native) {
240 // Native backend — forward to platform (frequency already configured)
241 platforms::analogWrite(pin, val);
242 return;
243 }
244
245 // No setPwmFrequency called — forward to platform as before
246 platforms::analogWrite(pin, val);
247}
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 initPanels(), setPanelHigh(), and setPanelLow().

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