FastLED 3.10.9
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 247 of file pin.cpp.hpp.

247 {
249
251 // Route to ISR duty cycle update (scale 8-bit val to duty)
252 u8 duty = (val > 255) ? 255 : static_cast<u8>(val);
254 ch->duty_cycle = duty;
255 ch->high_ticks = (static_cast<u32>(ch->period_ticks) * duty) / 256;
256 return;
257 }
258
259 if (ch && ch->backend == pwm_state::PwmBackend::Native) {
260 // Native backend — forward to platform (frequency already configured)
261 (platforms::analogWrite)(pin, val);
262 return;
263 }
264
265 // No setPwmFrequency called — forward to platform as before
266 (platforms::analogWrite)(pin, val);
267}
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 analogWrite(), 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 analogWrite(), initPanels(), setPanelHigh(), setPanelLow(), and fl::AnalogRGBController< RED_PIN, GREEN_PIN, BLUE_PIN >::writeRgb().

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