-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Duplicated rpipico for pico2 (acutators)
One servo is at least working, should be able to handle more, needs testing
- Loading branch information
Showing
11 changed files
with
97 additions
and
208,598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
#define ENABLE_PIN 2 | ||
#include <array> | ||
|
||
#define CFG1_PIN 16 | ||
#define CFG2_PIN 17 | ||
|
||
#define DIR_PIN1 14 | ||
#define STEP_PIN1 15 | ||
|
||
|
||
#define DIR_PIN2 12 | ||
#define STEP_PIN2 13 | ||
|
||
#define DIR_PIN3 10 | ||
#define STEP_PIN3 11 | ||
|
||
#define DIR_PIN4 8 | ||
#define STEP_PIN4 9 | ||
constexpr std::array<int, 13> servoGpioNumbers = { | ||
/*placeholder*/ 0, | ||
/* servo 1 */ 2, | ||
/* servo 2 */ 3, | ||
/* servo 3 */ 6, | ||
/* servo 4 */ 7, | ||
/* servo 5 */ 8, | ||
/* servo 6 */ 9, | ||
/* servo 7 */ 10, | ||
/* servo 8 */ 11, | ||
/* servo 9 */ 12, | ||
/* servo 10 */ 13, | ||
/* servo 11 */ 14, | ||
/* servo 12 */ 14 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef SERVOACTUATOR_HPP | ||
#define SERVOACTUATOR_HPP | ||
|
||
|
||
#include <Arduino.h> | ||
#include <Servo.h> | ||
|
||
#include <array> | ||
|
||
|
||
class ServoActuator { | ||
public: | ||
ServoActuator(int gpioNumber); | ||
ServoActuator(int gpoNumber, int min, int max, int safe); | ||
void write(int angle); | ||
private: | ||
int gpioNumber; | ||
int min; | ||
int max; | ||
int safe; | ||
Servo servo; | ||
int limit(int angle); | ||
|
||
|
||
|
||
}; | ||
|
||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "servo/servo_actuator.hpp" | ||
|
||
|
||
ServoActuator::ServoActuator(int gpioNumber) { | ||
this->gpioNumber = gpioNumber; | ||
this->servo.attach(gpioNumber); | ||
} | ||
|
||
|
||
ServoActuator::ServoActuator(int gpioNumber, int min, int max, int safe) { | ||
this->gpioNumber = gpioNumber; | ||
this->min = min; | ||
this->max = max; | ||
this->safe = safe; | ||
this->servo.attach(gpioNumber); | ||
this->servo.write(safe); | ||
|
||
} | ||
|
||
int ServoActuator::limit(int angle) { | ||
if (angle > max) { | ||
return max; | ||
} else if (angle < min) { | ||
return min; | ||
} else { | ||
return angle; | ||
} | ||
} | ||
|
||
|
||
void ServoActuator::write(int angle) { | ||
this->servo.write(limit(angle)); | ||
} | ||
|
Oops, something went wrong.