In the following code for the ELEGOO Conqueror Robot Tank Kit 2024.06.05. In the file DeviceDriverSet_xxx0.cpp. The following code has a variable called direction_A which is a boolean variable.
In the switch statement for direction_A, there is case direction_void. For a boolean variable, I would expect case True and case False. But in the code below, there is none of true or false. How is this code working? What am I missing?
Thank you all for the help!
/*
Motor_control:AB / 方向、速度
*/
void DeviceDriverSet_Motor::DeviceDriverSet_Motor_control(boolean direction_A, uint8_t speed_A, //A组电机参数
boolean direction_B, uint8_t speed_B, //B组电机参数
boolean controlED //AB使能允许 true
) //电机控制
{
if (controlED == control_enable) //使能允许?
{
digitalWrite(PIN_Motor_STBY, HIGH);
{ //A...Right
switch (direction_A) //方向控制
{
case direction_just:
digitalWrite(PIN_Motor_AIN_1, HIGH);
analogWrite(PIN_Motor_PWMA, speed_A);
break;
case direction_back:
digitalWrite(PIN_Motor_AIN_1, LOW);
analogWrite(PIN_Motor_PWMA, speed_A);
break;
case direction_void:
analogWrite(PIN_Motor_PWMA, 0);
digitalWrite(PIN_Motor_STBY, LOW);
break;
default:
analogWrite(PIN_Motor_PWMA, 0);
digitalWrite(PIN_Motor_STBY, LOW);
break;
}
}
{ //B...Left
switch (direction_B)
{
case direction_just:
digitalWrite(PIN_Motor_BIN_1, HIGH);
analogWrite(PIN_Motor_PWMB, speed_B);
break;
case direction_back:
digitalWrite(PIN_Motor_BIN_1, LOW);
analogWrite(PIN_Motor_PWMB, speed_B);
break;
case direction_void:
analogWrite(PIN_Motor_PWMB, 0);
digitalWrite(PIN_Motor_STBY, LOW);
break;
default:
analogWrite(PIN_Motor_PWMB, 0);
digitalWrite(PIN_Motor_STBY, LOW);
break;
}
}
}
else
{
digitalWrite(PIN_Motor_STBY, LOW);
return;
}
}