feature/servo_motor_component #17
@ -4,6 +4,7 @@
|
||||
#include "Arduino.h"
|
||||
#include "DolibarrClient.h"
|
||||
#include <M5Stack.h>
|
||||
#include "ServoMotorComponent.h"
|
||||
|
||||
class Program {
|
||||
public:
|
||||
@ -18,6 +19,7 @@ public:
|
||||
void loop();
|
||||
private:
|
||||
DolibarrClient *client;
|
||||
ServoMotorComponent *servo;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -2,23 +2,25 @@
|
||||
|
||||
ServoMotorComponent::ServoMotorComponent(int PIN) {
|
||||
this->PIN = PIN;
|
||||
this->position = 0;
|
||||
this->position = 30;
|
||||
this->speed = 100;
|
||||
this->easing = 0.5;
|
||||
this->myservo.attach(PIN);
|
||||
}
|
||||
|
||||
void ServoMotorComponent::goLeft() {
|
||||
this->myservo.write(this->PIN, 0);
|
||||
this->myservo.write(this->PIN, 52, this->speed, this->easing);
|
||||
this->position = 0;
|
||||
}
|
||||
|
||||
void ServoMotorComponent::goRight() {
|
||||
|
||||
this->myservo.write(this->PIN, 180);
|
||||
this->myservo.write(this->PIN, 18, this->speed, this->easing);
|
||||
|
||||
this->position = 180;
|
||||
}
|
||||
Clement
commented
Nom des variables pas claire Nom des variables pas claire
|
||||
|
||||
void ServoMotorComponent::goMiddle() {
|
||||
this->myservo.write(this->PIN, 90);
|
||||
this->myservo.write(this->PIN, 32, this->speed, this->easing);
|
||||
this->position = 90;
|
||||
}
|
||||
|
||||
@ -29,4 +31,20 @@ int ServoMotorComponent::getPosition() {
|
||||
void ServoMotorComponent::setPin(int PIN) {
|
||||
this->PIN = PIN;
|
||||
this->myservo.attach(PIN);
|
||||
return;
|
||||
}
|
||||
|
||||
void ServoMotorComponent::setSpeed(int speed) {
|
||||
this->speed = speed;
|
||||
return;
|
||||
}
|
||||
|
||||
void ServoMotorComponent::pause() {
|
||||
Clement
commented
Limite faire en sorte de pouvoir configurer le pas dans le constructeur (avec une valeur par défaut) Limite faire en sorte de pouvoir configurer le pas dans le constructeur (avec une valeur par défaut)
en double ou float
|
||||
this->myservo.pause();
|
||||
return;
|
||||
}
|
||||
|
||||
void ServoMotorComponent::setEasing(float easing) {
|
||||
Clement marked this conversation as resolved
Outdated
Clement
commented
typo ctrl C typo ctrl C
|
||||
this->easing = easing;
|
||||
return;
|
||||
}
|
||||
|
@ -13,10 +13,15 @@ public:
|
||||
void goMiddle();
|
||||
int getPosition();
|
||||
void setPin(int PIN);
|
||||
void pause();
|
||||
Clement
commented
tu peut viré le destructeur tu peut viré le destructeur
|
||||
void setSpeed(int speed);
|
||||
void setEasing(float easing);
|
||||
Clement
commented
met des commentaire doxygen sur tes fonction met des commentaire doxygen sur tes fonction
|
||||
|
||||
private:
|
||||
int PIN;
|
||||
int position;
|
||||
int speed;
|
||||
float easing;
|
||||
Servo myservo;
|
||||
};
|
||||
|
||||
|
@ -2,28 +2,17 @@
|
||||
#include "Arduino.h"
|
||||
Clement
commented
vire tes changement dans Program.CPP avant de push vire tes changement dans Program.CPP avant de push
|
||||
#include "DolibarrClient.h"
|
||||
|
||||
int initialize_wifi(WifiConfig wifi) {
|
||||
WiFiClass::mode(WIFI_STA); //Optional
|
||||
WiFi.setSleep(false);
|
||||
WiFi.begin(wifi.ssid, wifi.password);
|
||||
Serial.print("Connecting ");
|
||||
while(WiFiClass::status() != WL_CONNECTED){
|
||||
delay(WAITING_WIFI_DELAY);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("Connected to the WiFi network");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Program::Program() {
|
||||
Serial.begin(MONITOR_SPEED);
|
||||
struct WifiConfig wifi_c = {WIFI_SSID, WIFI_PASSWORD};
|
||||
struct DolibarrConfig dolibarr = {DOLIBARR_URL, DOLIBARR_API_TOKEN};
|
||||
initialize_wifi(wifi_c);
|
||||
this->client = new DolibarrClient(dolibarr);
|
||||
this->servo = new ServoMotorComponent(2);
|
||||
}
|
||||
|
||||
void Program::loop() {
|
||||
// this->servo->goLeft();
|
||||
// delay(3000);
|
||||
this->servo->goMiddle();
|
||||
// delay(3000);
|
||||
// this->servo->goRight();
|
||||
// delay(3000);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user
???