Skip to content

Commit

Permalink
smaller fixes (#19621)
Browse files Browse the repository at this point in the history
* position report during moverment

during moving the teleperiod will now report the actual position

* fix error on inverted shutter
  • Loading branch information
stefanbode authored Sep 29, 2023
1 parent 335e18e commit 540acdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
12 changes: 3 additions & 9 deletions tasmota/tasmota_xdrv_driver/xdrv_27_esp32_shutter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
#define SHUTTER_RELAY_OPERATION_TIME 100 // wait for direction relay 0.1sec before power up main relay
#endif

#ifndef MOTOR_STOP_TIME
#define MOTOR_STOP_TIME 500 // wait 0.5 second after stop to do any other action. e.g. move in the opposite direction
#endif

//#define SHUTTER_UNITTEST

#define D_SHUTTER "SHUTTER"
Expand Down Expand Up @@ -825,7 +821,6 @@ void ShutterPowerOff(uint8_t i)
if (Settings->save_data) {
TasmotaGlobal.save_data_counter = Settings->save_data;
}
//delay(MOTOR_STOP_TIME);
Shutter[i].last_stop_time = millis();
}

Expand Down Expand Up @@ -962,7 +957,6 @@ void ShutterReportPosition(bool always, uint32_t index)
uint32_t position = ShutterRealToPercentPosition(Shutter[i].real_position, i);
uint32_t target = ShutterRealToPercentPosition(Shutter[i].target_position, i);
ResponseAppend_P(JSON_SHUTTER_POS, i + 1, (ShutterSettings.shutter_options[i] & 1) ? 100 - position : position, Shutter[i].direction,(ShutterSettings.shutter_options[i] & 1) ? 100 - target : target, Shutter[i].tilt_real_pos );
//ResponseAppend_P(JSON_SHUTTER_POS, i+1, position, Shutter[i].direction, target, Shutter[i].tilt_real_pos );
}
ResponseJsonEnd();
if (always || shutter_running) {
Expand Down Expand Up @@ -1941,10 +1935,8 @@ void CmndShutterPosition(void)
AddLog(LOG_LEVEL_INFO, PSTR("SHT: Garage not move in this direction: %d"), Shutter[index].switch_mode == SHT_PULSE);
for (uint8_t k = 0 ; k <= (uint8_t)(Shutter[index].switch_mode == SHT_PULSE) ; k++) {
ExecuteCommandPowerShutter(ShutterSettings.shutter_startrelay[index], 1, SRC_SHUTTER);
//delay(MOTOR_STOP_TIME);
ShutterWaitForMotorStop(index);
ExecuteCommandPowerShutter(ShutterSettings.shutter_startrelay[index], 0, SRC_SHUTTER);
//delay(MOTOR_STOP_TIME);
ShutterWaitForMotorStop(index);
}
// reset shutter time to avoid 2 seconds above count as runtime
Expand Down Expand Up @@ -2332,7 +2324,9 @@ bool Xdrv27(uint32_t function)
case FUNC_JSON_APPEND:
for (uint8_t i = 0; i < TasmotaGlobal.shutters_present; i++) {
ResponseAppend_P(",");
ResponseAppend_P(JSON_SHUTTER_POS, i + 1, ShutterRealToPercentPosition(Shutter[i].real_position, i), Shutter[i].direction, ShutterRealToPercentPosition(Shutter[i].target_position, i), Shutter[i].tilt_real_pos);
uint8_t position = ShutterRealToPercentPosition(Shutter[i].real_position, i);
uint8_t target = ShutterRealToPercentPosition(Shutter[i].target_position, i);
ResponseAppend_P(JSON_SHUTTER_POS, i + 1, (ShutterSettings.shutter_options[i] & 1) ? 100 - position : position, Shutter[i].direction,(ShutterSettings.shutter_options[i] & 1) ? 100 - target : target, Shutter[i].tilt_real_pos );
#ifdef USE_DOMOTICZ
if ((0 == TasmotaGlobal.tele_period) && (0 == i)) {
DomoticzSensor(DZ_SHUTTER, ShutterRealToPercentPosition(Shutter[i].real_position, i));
Expand Down
20 changes: 6 additions & 14 deletions tasmota/tasmota_xdrv_driver/xdrv_27_shutter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
#define SHUTTER_RELAY_OPERATION_TIME 100 // wait for direction relay 0.1sec before power up main relay
#endif

#ifndef MOTOR_STOP_TIME
#define MOTOR_STOP_TIME 500 // wait 0.5 second after stop to do any other action. e.g. move in the opposite direction
#endif

//#define SHUTTER_UNITTEST

#define D_SHUTTER "SHUTTER"
Expand Down Expand Up @@ -491,9 +487,9 @@ void ShutterReportPosition(bool always, uint32_t index)
shutter_running++;
}
if (i && index == MAX_SHUTTERS) { ResponseAppend_P(PSTR(",")); }
uint32_t position = ShutterRealToPercentPosition(Shutter[i].real_position, i);
uint32_t target = ShutterRealToPercentPosition(Shutter[i].target_position, i);
ResponseAppend_P(JSON_SHUTTER_POS, i+1, (Settings->shutter_options[i] & 1) ? 100-position : position, Shutter[i].direction,(Settings->shutter_options[i] & 1) ? 100-target : target, Shutter[i].tilt_real_pos );
uint8_t position = ShutterRealToPercentPosition(Shutter[i].real_position, i);
uint8_t target = ShutterRealToPercentPosition(Shutter[i].target_position, i);
ResponseAppend_P(JSON_SHUTTER_POS, i+1, (Settings->shutter_options[i] & 1) ? 100 - position : position, Shutter[i].direction,(Settings->shutter_options[i] & 1) ? 100 - target : target, Shutter[i].tilt_real_pos );
}
ResponseJsonEnd();
if (always || shutter_running) {
Expand Down Expand Up @@ -645,7 +641,6 @@ void ShutterPowerOff(uint8_t i)
if (Settings->save_data) {
TasmotaGlobal.save_data_counter = Settings->save_data;
}
//delay(MOTOR_STOP_TIME);
Shutter[i].last_stop_time = millis();
}

Expand Down Expand Up @@ -1404,10 +1399,8 @@ void CmndShutterPosition(void)
AddLog(LOG_LEVEL_INFO, PSTR("SHT: Garage not move in this direction: %d"), Shutter[index].switch_mode == SHT_PULSE);
for (uint8_t k=0 ; k <= (uint8_t)(Shutter[index].switch_mode == SHT_PULSE) ; k++) {
ExecuteCommandPowerShutter(Settings->shutter_startrelay[index], 1, SRC_SHUTTER);
//delay(MOTOR_STOP_TIME);
ShutterWaitForMotorStop(index);
ExecuteCommandPowerShutter(Settings->shutter_startrelay[index], 0, SRC_SHUTTER);
//delay(MOTOR_STOP_TIME);
ShutterWaitForMotorStop(index);
}
// reset shutter time to avoid 2 seconds above count as runtime
Expand Down Expand Up @@ -1928,11 +1921,10 @@ bool Xdrv27(uint32_t function)
break;
case FUNC_JSON_APPEND:
for (uint8_t i = 0; i < TasmotaGlobal.shutters_present; i++) {
uint8_t position = (Settings->shutter_options[i] & 1) ? 100 - Settings->shutter_position[i] : Settings->shutter_position[i];
uint8_t target = (Settings->shutter_options[i] & 1) ? 100 - ShutterRealToPercentPosition(Shutter[i].target_position, i) : ShutterRealToPercentPosition(Shutter[i].target_position, i);

uint8_t position = ShutterRealToPercentPosition(Shutter[i].real_position, i);
uint8_t target = ShutterRealToPercentPosition(Shutter[i].target_position, i);
ResponseAppend_P(",");
ResponseAppend_P(JSON_SHUTTER_POS, i+1, position, Shutter[i].direction,target, Shutter[i].tilt_real_pos);
ResponseAppend_P(JSON_SHUTTER_POS, i+1, (Settings->shutter_options[i] & 1) ? 100 - position : position, Shutter[i].direction,(Settings->shutter_options[i] & 1) ? 100 - target : target, Shutter[i].tilt_real_pos );
#ifdef USE_DOMOTICZ
if ((0 == TasmotaGlobal.tele_period) && (0 == i)) {
DomoticzSensor(DZ_SHUTTER, position);
Expand Down

0 comments on commit 540acdc

Please sign in to comment.