diff --git a/inc/MicroBitPin.h b/inc/MicroBitPin.h index e4ba2fd..a6381e1 100644 --- a/inc/MicroBitPin.h +++ b/inc/MicroBitPin.h @@ -154,6 +154,11 @@ class MicroBitPin : public MicroBitComponent * @param period The new period for the analog output in milliseconds. */ void setAnalogPeriod(int period); + + /** + * Same thing as setAnalogPeriodUs, but with microseconds. + */ + void setAnalogPeriodUs(int period); }; #endif diff --git a/source/MicroBitPin.cpp b/source/MicroBitPin.cpp index 9d03e8c..17302a5 100644 --- a/source/MicroBitPin.cpp +++ b/source/MicroBitPin.cpp @@ -205,11 +205,18 @@ int MicroBitPin::isTouched() * If this pin is not configured as an analog output, the operation * has no effect. * - * @param period The new period for the analog output in milliseconds. - */ -void MicroBitPin::setAnalogPeriod(int period) + * @param period The new period for the analog output in microseconds. + */ +void MicroBitPin::setAnalogPeriodUs(int period) { if (status & IO_STATUS_ANALOG_OUT) - ((DynamicPwm *)pin)->setPeriodUs(period*1000); - + ((DynamicPwm *)pin)->setPeriodUs(period); +} + +/** + * Same thing as setAnalogPeriodUs, but with milliseconds. + */ +void MicroBitPin::setAnalogPeriod(int period) +{ + setAnalogPeriodUs(period*1000); }