Fix shutterfrequency esp32 (#19717)

This commit is contained in:
stefanbode 2023-10-11 17:12:07 +02:00 committed by GitHub
parent b5d1109163
commit dade00bf59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 11 deletions

View File

@ -568,10 +568,7 @@ void ShutterInit(void)
//Initialize to get relay that changed //Initialize to get relay that changed
ShutterGlobal.RelayOldMask = TasmotaGlobal.power; ShutterGlobal.RelayOldMask = TasmotaGlobal.power;
// if shutter 4 is unused ShutterGlobal.open_velocity_max = ShutterSettings.open_velocity_max;
if (ShutterSettings.shutter_startrelay[MAX_SHUTTERS_ESP32 -1] == 0) {
ShutterGlobal.open_velocity_max = ShutterSettings.shuttercoeff[4][3] > 0 ? ShutterSettings.shuttercoeff[4][3] : ShutterGlobal.open_velocity_max;
}
for (uint32_t i = 0; i < MAX_SHUTTERS_ESP32; i++) { for (uint32_t i = 0; i < MAX_SHUTTERS_ESP32; i++) {
// set startrelay to 1 on first init, but only to shutter 1. 90% usecase // set startrelay to 1 on first init, but only to shutter 1. 90% usecase
if (ShutterSettings.shutter_startrelay[i] && (ShutterSettings.shutter_startrelay[i] <= 32 )) { if (ShutterSettings.shutter_startrelay[i] && (ShutterSettings.shutter_startrelay[i] <= 32 )) {
@ -996,7 +993,8 @@ void ShutterRtc50mS(void)
startWaveformClockCycles(Pin(GPIO_PWM1, i), cc/2, cc/2, 0, -1, 0, false); startWaveformClockCycles(Pin(GPIO_PWM1, i), cc/2, cc/2, 0, -1, 0, false);
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
analogWriteFreq(Shutter[i].pwm_velocity,Pin(GPIO_PWM1, i)); ledcWriteTone(i, Shutter[i].pwm_velocity); //
ledcWrite(i, 512); // Setzt den PWM-Wert auf 0
TasmotaGlobal.pwm_value[i] = 512; TasmotaGlobal.pwm_value[i] = 512;
pwm_apply = true; pwm_apply = true;
#endif // ESP32 #endif // ESP32
@ -1179,9 +1177,10 @@ void ShutterStartInit(uint32_t i, int32_t direction, int32_t target_pos)
analogWrite(Pin(GPIO_PWM1, i), 0); analogWrite(Pin(GPIO_PWM1, i), 0);
#endif #endif
#ifdef ESP32 #ifdef ESP32
analogWriteFreq(PWM_MIN,Pin(GPIO_PWM1, i)); ledcSetup(i, Shutter[i].pwm_velocity, 8);
TasmotaGlobal.pwm_value[i] = 0; ledcAttachPin(Pin(GPIO_PWM1, i), i); // Nehmen Sie an, dass GPIO_PWM1 der gewünschte GPIO-Pin ist.
PwmApplyGPIO(false); ledcWriteTone(i, Shutter[i].pwm_velocity); //
ledcWrite(i, 0); // Setzt den PWM-Wert auf 0
#endif #endif
RtcSettings.pulse_counter[i] = 0; RtcSettings.pulse_counter[i] = 0;
break; break;
@ -1708,9 +1707,7 @@ void CmndShutterFrequency(void)
{ {
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= 20000)) { if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= 20000)) {
ShutterGlobal.open_velocity_max = XdrvMailbox.payload; ShutterGlobal.open_velocity_max = XdrvMailbox.payload;
if (TasmotaGlobal.shutters_present < 4) { ShutterSettings.open_velocity_max = ShutterGlobal.open_velocity_max;
ShutterSettings.shuttercoeff[4][3] = ShutterGlobal.open_velocity_max;
}
ShutterInit(); ShutterInit();
} }
ResponseCmndNumber(ShutterGlobal.open_velocity_max); ResponseCmndNumber(ShutterGlobal.open_velocity_max);