mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-07-05 02:01:42 +02:00
Handle denials of power appropriately
This commit is contained in:
@ -29,10 +29,24 @@ void Motor::begin(void){
|
||||
void Motor::setSpeed(uint16_t duty){
|
||||
const float dutyFactor = duty / static_cast<float>(1 << DUTY_RES);
|
||||
const float current = PowerParameters::CurrentConsumptions::CURRENT_MOTOR_T_ON * dutyFactor;
|
||||
if (this->pin == MOTOR_LEFT_PIN){
|
||||
Power::waitForCurrentAllowance(PowerParameters::PowerConsumers::MOTOR_LEFT, current, MOTOR_MAX_EXECUTION_DELAY_MS, NULL);
|
||||
if (this->pin == MOTOR_LEFT_PIN) {
|
||||
if (!Power::waitForCurrentAllowance(
|
||||
PowerParameters::PowerConsumers::MOTOR_LEFT, current,
|
||||
MOTOR_MAX_EXECUTION_DELAY_MS, NULL)) {
|
||||
ESP_LOGW(TAG,
|
||||
"Power to set LEFT MOTOR to speed %d not granted in time. "
|
||||
"Skipping.",
|
||||
duty);
|
||||
}
|
||||
} else {
|
||||
Power::waitForCurrentAllowance(PowerParameters::PowerConsumers::MOTOR_RIGHT, current, MOTOR_MAX_EXECUTION_DELAY_MS, NULL);
|
||||
if (!Power::waitForCurrentAllowance(
|
||||
PowerParameters::PowerConsumers::MOTOR_RIGHT, current,
|
||||
MOTOR_MAX_EXECUTION_DELAY_MS, NULL)) {
|
||||
ESP_LOGW(TAG,
|
||||
"Power to set RIGHT MOTOR to speed %d not granted in time. "
|
||||
"Skipping.",
|
||||
duty);
|
||||
}
|
||||
}
|
||||
int difference = duty-this->getSpeed();
|
||||
if (difference > 0){
|
||||
|
Reference in New Issue
Block a user