feat:V1.0 #8

Merged
Clement merged 58 commits from develop into master 2024-02-02 16:03:25 +00:00
3 changed files with 19 additions and 10 deletions
Showing only changes of commit fe671182cd - Show all commits

View File

@ -27,3 +27,8 @@ build_flags =
; nfc addr
-D NFC_ADDR=0x28
;;; Servo config ;;;
;;;;;;;;;;;;;;;;;;;;;;
-D RIGHT_POS=18
-D MIDDLE_POS=32
-D LEFT_POS=52

View File

@ -13,7 +13,7 @@ ServoMotorComponent::ServoMotorComponent(int PIN, unsigned long updatePeriod, f
this->PIN = PIN;
this->myservo.attach(PIN);
this->desiredposition = Position::MIDDLE;
this->currentPosition = 32;
this->currentPosition = MIDDLE_POS;
this->lastUpTime = millis();
this->updatePeriod = updatePeriod;
this->step = step;
@ -27,13 +27,13 @@ ServoMotorComponent::ServoMotorComponent(int PIN, unsigned long updatePeriod, f
void ServoMotorComponent::setDesiredPosition(Position desiredPosition) {
switch (desiredPosition) {
case Position::LEFT:
this->desiredposition = 52;
this->desiredposition = LEFT_POS;
break;
case Position::MIDDLE:
this->desiredposition = 32;
this->desiredposition = MIDDLE_POS;
break;
case Position::RIGHT:
this->desiredposition = 18;
this->desiredposition = RIGHT_POS;
break;
default:
break;
@ -49,10 +49,10 @@ void ServoMotorComponent::refresh() {
|| millis() - this->lastUpTime <= this->updatePeriod) return;
if (this->currentPosition > this->desiredposition) {
this->currentPosition--;
this->currentPosition -= this->step;
}
if (this->currentPosition < this->desiredposition) {
this->currentPosition++;
this->currentPosition += this->step;
}
this->lastUpTime = millis();
this->myservo.write(this->PIN, this->currentPosition);

View File

@ -1,6 +1,7 @@
#include "Program.h"
#include "Arduino.h"
#include "DolibarrClient.h"
#include "ServoMotorComponent.h"
int initialize_wifi(WifiConfig wifi) {
WiFiClass::mode(WIFI_STA); //Optional
@ -17,13 +18,16 @@ int initialize_wifi(WifiConfig wifi) {
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, 1, 0.1);
//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);
}
void Program::loop() {
this->servo->refresh();
this->servo->setDesiredPosition(Position::LEFT);
}