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

243 {
245
247 // Route to ISR duty cycle update (scale 8-bit val to duty)
248 u8 duty = (val > 255) ? 255 : static_cast<u8>(val);
250 ch->duty_cycle = duty;
251 ch->high_ticks = (static_cast<u32>(ch->period_ticks) * duty) / 256;
252 return;
253 }
254
255 if (ch && ch->backend == pwm_state::PwmBackend::Native) {
256 // Native backend — forward to platform (frequency already configured)
257 platforms::analogWrite(pin, val);
258 return;
259 }
260
261 // No setPwmFrequency called — forward to platform as before
262 platforms::analogWrite(pin, val);
263}
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 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: