add config.ini

This commit is contained in:
2024-01-19 16:37:35 +01:00
parent 15bd7c7741
commit fe671182cd
3 changed files with 19 additions and 10 deletions

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);