Skip to content

Commit e1853b3

Browse files
committed
feat(core): third step of ArduinoCore-API migration – Servo
Signed-off-by: Aymane Bahssain <aymane.bahssain@st.com>
1 parent b7eb6c2 commit e1853b3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

libraries/Servo/src/Servo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#ifndef Servo_h
4949
#define Servo_h
5050

51+
#include <Arduino.h>
5152
#include <inttypes.h>
5253

5354
/*
@@ -102,8 +103,8 @@ typedef struct {
102103
class Servo {
103104
public:
104105
Servo();
105-
uint8_t attach(int pin, int value = DEFAULT_PULSE_WIDTH); // attach the given pin to the next free channel, sets pinMode, set angle value, returns channel number or 0 if failure
106-
uint8_t attach(int pin, int min, int max, int value = DEFAULT_PULSE_WIDTH); // as above but also sets min and max values for writes.
106+
uint8_t attach(pin_size_t pin, int value = DEFAULT_PULSE_WIDTH); // attach the given pin to the next free channel, sets pinMode, set angle value, returns channel number or 0 if failure
107+
uint8_t attach(pin_size_t pin, int min, int max, int value = DEFAULT_PULSE_WIDTH); // as above but also sets min and max values for writes.
107108
void detach();
108109
void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
109110
void writeMicroseconds(int value); // Write pulse width in microseconds

libraries/Servo/src/stm32/Servo.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#if defined(ARDUINO_ARCH_STM32)
2020

21-
#include <Arduino.h>
2221
#include <Servo.h>
2322
#include <HardwareTimer.h>
2423

@@ -111,12 +110,12 @@ Servo::Servo()
111110
}
112111
}
113112

114-
uint8_t Servo::attach(int pin, int value)
113+
uint8_t Servo::attach(pin_size_t pin, int value)
115114
{
116115
return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH, value);
117116
}
118117

119-
uint8_t Servo::attach(int pin, int min, int max, int value)
118+
uint8_t Servo::attach(pin_size_t pin, int min, int max, int value)
120119
{
121120
if (this->servoIndex < MAX_SERVOS) {
122121
pinMode(pin, OUTPUT); // set servo pin to output
@@ -201,12 +200,12 @@ bool Servo::attached()
201200

202201
#warning "TIMER_TONE or HAL_TIM_MODULE_ENABLED not defined"
203202
Servo::Servo() {}
204-
uint8_t Servo::attach(int pin)
203+
uint8_t Servo::attach(pin_size_t pin)
205204
{
206205
UNUSED(pin);
207206
return 0;
208207
}
209-
uint8_t Servo::attach(int pin, int min, int max)
208+
uint8_t Servo::attach(pin_size_t pin, int min, int max)
210209
{
211210
UNUSED(pin);
212211
UNUSED(min);

0 commit comments

Comments
 (0)