add config.ini
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user