mirror of
https://github.com/modelec/pami.git
synced 2026-03-18 21:40:35 +01:00
add multi core, servo class
Use core 0 for ultrasonic detection Use a custom class to pilot servo
This commit is contained in:
@@ -1,18 +1,40 @@
|
||||
#ifndef SERVO_H
|
||||
#define SERVO_H
|
||||
#ifndef PAMI_SERVO_H
|
||||
#define PAMI_SERVO_H
|
||||
|
||||
#define MAX_US 544
|
||||
#define MIN_US 2400
|
||||
#define DEFAULT_MIN_US 544
|
||||
#define DEFAULT_MAX_US 2400
|
||||
|
||||
#define DEFAULT_MIN_ANGLE 0
|
||||
#define DEFAULT_MAX_ANGLE 180
|
||||
|
||||
class Servo {
|
||||
private:
|
||||
const int channel;
|
||||
const int pin;
|
||||
const int min;
|
||||
const int max;
|
||||
int channel{};
|
||||
int pin{};
|
||||
int min_us{};
|
||||
int max_us{};
|
||||
int min_angle{};
|
||||
int max_angle{};
|
||||
|
||||
void initServo() const;
|
||||
|
||||
public:
|
||||
Servo();
|
||||
|
||||
Servo(int pin, int channel, int min_angle = DEFAULT_MIN_ANGLE, int max_angle = DEFAULT_MAX_ANGLE,
|
||||
int min_us = DEFAULT_MIN_US,
|
||||
int max_us = DEFAULT_MAX_US);
|
||||
|
||||
void writeAngle(int angle) const;
|
||||
|
||||
void writeUs(int us) const;
|
||||
|
||||
/**
|
||||
* Write to the servo the value as degree if it's in the degree range of the servo otherwise as us value
|
||||
* @param value The value to write in angle or us
|
||||
*/
|
||||
void write(int value) const;
|
||||
};
|
||||
|
||||
|
||||
#endif //SERVO_H
|
||||
#endif //PAMI_SERVO_H
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
#ifndef PAMI_MAIN_H
|
||||
#define PAMI_MAIN_H
|
||||
|
||||
enum Direction {
|
||||
FORWARD,
|
||||
@@ -46,7 +46,6 @@ struct Step {
|
||||
#define ECHO_PIN 12
|
||||
// Servo Moteur
|
||||
#define SERVO_PIN 15
|
||||
// FIXME : Je sais pas, loop sous le bouton d'arret d'urgence
|
||||
#define EMG_PIN 5
|
||||
|
||||
#endif
|
||||
@@ -90,4 +89,4 @@ struct Step {
|
||||
#define STEPS_PER_REV 200.0
|
||||
#define MICROSTEPPING 8.0
|
||||
|
||||
#endif // MAIN_H
|
||||
#endif // PAMI_MAIN_H
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
#ifndef PAMI_UTILS_H
|
||||
#define PAMI_UTILS_H
|
||||
|
||||
void enableMotorDrivers();
|
||||
|
||||
@@ -9,6 +9,4 @@ int getStepsForDistance(float cm);
|
||||
|
||||
int getRotationSteps(float angleDeg);
|
||||
|
||||
void setServoAngle(int angle, int channel = 0);
|
||||
|
||||
#endif // UTILS_H
|
||||
#endif // PAMI_UTILS_H
|
||||
|
||||
Reference in New Issue
Block a user