diff --git a/src/ContinuousStepper/Tickers/AnalogWriteFrequency.hpp b/src/ContinuousStepper/Tickers/AnalogWriteFrequency.hpp index 8163316..de42967 100644 --- a/src/ContinuousStepper/Tickers/AnalogWriteFrequency.hpp +++ b/src/ContinuousStepper/Tickers/AnalogWriteFrequency.hpp @@ -11,7 +11,7 @@ class AwfOscillator { pin_ = pin; } - void start(unsigned int frequency) { + void start(frequency_t frequency) { analogWriteFrequency(pin_, frequency); if (!active_) { analogWrite(pin_, 128); @@ -24,7 +24,7 @@ class AwfOscillator { active_ = false; } - unsigned int minFrequency() const { + frequency_t minFrequency() const { // The analogWriteFrequency function has a lower limit of a few Hz. // https://www.pjrc.com/teensy/td_pulse.html#frequency return 5; diff --git a/src/ContinuousStepper/Tickers/KhoiH_PWM.hpp b/src/ContinuousStepper/Tickers/KhoiH_PWM.hpp index fbf23d4..4552d73 100644 --- a/src/ContinuousStepper/Tickers/KhoiH_PWM.hpp +++ b/src/ContinuousStepper/Tickers/KhoiH_PWM.hpp @@ -16,7 +16,7 @@ class KhoihOscillator { pwm_ = new KhoiH_PWM(pin, 500, 0); } - void start(unsigned int frequency) { + void start(frequency_t frequency) { pwm_->setPWM(pin_, frequency, 50); } @@ -24,7 +24,7 @@ class KhoihOscillator { pwm_->setPWM(pin_, 500, 0); } - unsigned int minFrequency() const { + frequency_t minFrequency() const { return 1; } diff --git a/src/ContinuousStepper/Tickers/OscillatorTicker.hpp b/src/ContinuousStepper/Tickers/OscillatorTicker.hpp index 847bd39..f04ccfc 100644 --- a/src/ContinuousStepper/Tickers/OscillatorTicker.hpp +++ b/src/ContinuousStepper/Tickers/OscillatorTicker.hpp @@ -4,6 +4,8 @@ namespace ArduinoContinuousStepper { +using frequency_t = unsigned int; + template class OscillatorTicker : StepperTicker { using time_t = unsigned long; diff --git a/src/ContinuousStepper/Tickers/Tone.hpp b/src/ContinuousStepper/Tickers/Tone.hpp index 72aeddb..5430dfe 100644 --- a/src/ContinuousStepper/Tickers/Tone.hpp +++ b/src/ContinuousStepper/Tickers/Tone.hpp @@ -11,7 +11,7 @@ class ToneOscillator { pin_ = pin; } - void start(unsigned int frequency) { + void start(frequency_t frequency) { tone(pin_, frequency); } @@ -19,7 +19,7 @@ class ToneOscillator { noTone(pin_); } - unsigned int minFrequency() const { + frequency_t minFrequency() const { #if defined(ARDUINO_ARCH_AVR) // It is not possible to generate tones lower than 31Hz // https://www.arduino.cc/reference/en/language/functions/advanced-io/tone/