|
@@ -25,7 +25,9 @@
|
25
|
25
|
#include <pwm.h>
|
26
|
26
|
|
27
|
27
|
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
28
|
|
- LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size);
|
|
28
|
+ if (!LPC176x::pin_is_valid(pin)) return;
|
|
29
|
+ if (LPC176x::pwm_attach_pin(pin))
|
|
30
|
+ LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range
|
29
|
31
|
}
|
30
|
32
|
|
31
|
33
|
#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM
|