|
@@ -52,14 +52,14 @@ uint8_t ServoCount; //=0
|
52
|
52
|
#define TAU_USEC (TAU_MSEC * 1000)
|
53
|
53
|
#define TAU_CYC (TAU_MSEC * CYC_MSEC)
|
54
|
54
|
#define SERVO_PRESCALER (TAU_CYC / MAX_OVERFLOW + 1)
|
55
|
|
-#define SERVO_OVERFLOW ((uint16)round((double)TAU_CYC / SERVO_PRESCALER))
|
|
55
|
+#define SERVO_OVERFLOW ((uint16_t)round((double)TAU_CYC / SERVO_PRESCALER))
|
56
|
56
|
|
57
|
57
|
// Unit conversions
|
58
|
|
-#define US_TO_COMPARE(us) ((uint16)map((us), 0, TAU_USEC, 0, SERVO_OVERFLOW))
|
59
|
|
-#define COMPARE_TO_US(c) ((uint32)map((c), 0, SERVO_OVERFLOW, 0, TAU_USEC))
|
60
|
|
-#define ANGLE_TO_US(a) ((uint16)(map((a), this->minAngle, this->maxAngle, \
|
|
58
|
+#define US_TO_COMPARE(us) ((uint16_t)map((us), 0, TAU_USEC, 0, SERVO_OVERFLOW))
|
|
59
|
+#define COMPARE_TO_US(c) ((uint32_t)map((c), 0, SERVO_OVERFLOW, 0, TAU_USEC))
|
|
60
|
+#define ANGLE_TO_US(a) ((uint16_t)(map((a), this->minAngle, this->maxAngle, \
|
61
|
61
|
SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW)))
|
62
|
|
-#define US_TO_ANGLE(us) ((int16)(map((us), SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW, \
|
|
62
|
+#define US_TO_ANGLE(us) ((int16_t)(map((us), SERVO_DEFAULT_MIN_PW, SERVO_DEFAULT_MAX_PW, \
|
63
|
63
|
this->minAngle, this->maxAngle)))
|
64
|
64
|
|
65
|
65
|
libServo::libServo() {
|
|
@@ -74,7 +74,7 @@ bool libServo::attach(const int32_t pin, const int32_t minAngle, const int32_t m
|
74
|
74
|
this->maxAngle = maxAngle;
|
75
|
75
|
|
76
|
76
|
timer_dev *tdev = PIN_MAP[this->pin].timer_device;
|
77
|
|
- uint8 tchan = PIN_MAP[this->pin].timer_channel;
|
|
77
|
+ uint8_t tchan = PIN_MAP[this->pin].timer_channel;
|
78
|
78
|
|
79
|
79
|
pinMode(this->pin, PWM);
|
80
|
80
|
pwmWrite(this->pin, 0);
|
|
@@ -97,7 +97,7 @@ bool libServo::detach() {
|
97
|
97
|
int32_t libServo::read() const {
|
98
|
98
|
if (this->attached()) {
|
99
|
99
|
timer_dev *tdev = PIN_MAP[this->pin].timer_device;
|
100
|
|
- uint8 tchan = PIN_MAP[this->pin].timer_channel;
|
|
100
|
+ uint8_t tchan = PIN_MAP[this->pin].timer_channel;
|
101
|
101
|
return US_TO_ANGLE(COMPARE_TO_US(timer_get_compare(tdev, tchan)));
|
102
|
102
|
}
|
103
|
103
|
return 0;
|