MQTT-Handling optimiert

This commit is contained in:
Bernhard
2026-01-20 21:15:35 +01:00
parent 281e70d91e
commit 4bde0cc888
2 changed files with 86 additions and 155 deletions

View File

@@ -140,7 +140,6 @@ void Can_SetMotorGear(int iMotorIndex, int iGear)
{
if (motctrl[iMotorIndex].iMotorGear != MOTOR_GEAR_FORWARD)
{
MqttClient_Publish_MotorGear(iMotorIndex, iGear);
motctrl[iMotorIndex].iMotorGear = MOTOR_GEAR_FORWARD;
// motor is switched to forward -> set min. power
Can_SetMotorPower(iMotorIndex, 1);
@@ -152,7 +151,6 @@ void Can_SetMotorGear(int iMotorIndex, int iGear)
{
if (motctrl[iMotorIndex].iMotorGear != MOTOR_GEAR_REVERSE)
{
MqttClient_Publish_MotorGear(iMotorIndex, iGear);
motctrl[iMotorIndex].iMotorGear = MOTOR_GEAR_REVERSE;
// motor is switched to reverse -> set min. power
Can_SetMotorPower(iMotorIndex, 1);
@@ -164,7 +162,6 @@ void Can_SetMotorGear(int iMotorIndex, int iGear)
{
if (motctrl[iMotorIndex].iMotorGear != MOTOR_GEAR_NEUTRAL)
{
MqttClient_Publish_MotorGear(iMotorIndex, iGear);
motctrl[iMotorIndex].iMotorGear = MOTOR_GEAR_NEUTRAL;
}
// motor is switch to neutral -> set power to 0
@@ -172,6 +169,7 @@ void Can_SetMotorGear(int iMotorIndex, int iGear)
WriteOutputPin(GPIO_LED_MOTRUN, LOW);
mylog(LOG_INFO, "CAN: Motor[%d]: Set gear neutral.", iMotorIndex);
}
MqttClient_Publish_MotorGear(iMotorIndex, iGear);
}