mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-07-05 02:01:42 +02:00
Power management progress
This commit is contained in:
@ -5,6 +5,7 @@ Motor::Motor(uint8_t pin, ledc_timer_t timer, ledc_channel_t channel){
|
||||
this->channel = channel;
|
||||
this->timer = timer;
|
||||
this->duty = 0;
|
||||
this->powerManager = *Power::getPowerManager();
|
||||
};
|
||||
|
||||
void Motor::begin(void){
|
||||
@ -23,7 +24,13 @@ void Motor::begin(void){
|
||||
};
|
||||
|
||||
void Motor::setSpeed(uint16_t duty){
|
||||
|
||||
if(duty>0) {
|
||||
powerManager.waitForPowerAllowance(CONSUMPTION_MOTOR, portMAX_DELAY);
|
||||
Serial.println("Motor got power");
|
||||
} else {
|
||||
powerManager.releasePower(CONSUMPTION_MOTOR);
|
||||
Serial.println("Motor released power");
|
||||
}
|
||||
int difference = duty-this->getSpeed();
|
||||
if (difference > 0){
|
||||
for(int i = 0;i<difference;i+=difference/20){
|
||||
|
Reference in New Issue
Block a user