mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Update xdrv_27_shutter.ino
This commit is contained in:
parent
681f66f157
commit
5e799716a7
@ -125,6 +125,7 @@ void ShutterLogPos(uint32_t i)
|
|||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Real %d, Start %d, Stop %d, Dir %d, Delay %d, Rtc %s [s], Freq %d, PWM %d, Tilt %d"),
|
AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Real %d, Start %d, Stop %d, Dir %d, Delay %d, Rtc %s [s], Freq %d, PWM %d, Tilt %d"),
|
||||||
i+1, Shutter[i].real_position, Shutter[i].start_position, Shutter[i].target_position, Shutter[i].direction, Shutter[i].motordelay, stemp2,
|
i+1, Shutter[i].real_position, Shutter[i].start_position, Shutter[i].target_position, Shutter[i].direction, Shutter[i].motordelay, stemp2,
|
||||||
Shutter[i].pwm_velocity, Shutter[i].pwm_value,Shutter[i].tilt_real_pos);
|
Shutter[i].pwm_velocity, Shutter[i].pwm_value,Shutter[i].tilt_real_pos);
|
||||||
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecuteCommandPowerShutter(uint32_t device, uint32_t state, uint32_t source)
|
void ExecuteCommandPowerShutter(uint32_t device, uint32_t state, uint32_t source)
|
||||||
@ -365,7 +366,7 @@ void ShutterInit(void)
|
|||||||
void ShutterReportPosition(bool always, uint32_t index)
|
void ShutterReportPosition(bool always, uint32_t index)
|
||||||
{
|
{
|
||||||
Response_P(PSTR("{"));
|
Response_P(PSTR("{"));
|
||||||
TasmotaGlobal.rules_flag.shutter_moving = 0;
|
//TasmotaGlobal.rules_flag.shutter_moving = 0;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
uint32_t n = TasmotaGlobal.shutters_present;
|
uint32_t n = TasmotaGlobal.shutters_present;
|
||||||
if( index != MAX_SHUTTERS) {
|
if( index != MAX_SHUTTERS) {
|
||||||
@ -376,7 +377,7 @@ void ShutterReportPosition(bool always, uint32_t index)
|
|||||||
//AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Real Pos %d"), i+1,Shutter[i].real_position);
|
//AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Real Pos %d"), i+1,Shutter[i].real_position);
|
||||||
uint32_t position = ShutterRealToPercentPosition(Shutter[i].real_position, i);
|
uint32_t position = ShutterRealToPercentPosition(Shutter[i].real_position, i);
|
||||||
if (Shutter[i].direction != 0) {
|
if (Shutter[i].direction != 0) {
|
||||||
TasmotaGlobal.rules_flag.shutter_moving = 1;
|
//TasmotaGlobal.rules_flag.shutter_moving = 1;
|
||||||
ShutterLogPos(i);
|
ShutterLogPos(i);
|
||||||
}
|
}
|
||||||
if (i && index == MAX_SHUTTERS) { ResponseAppend_P(PSTR(",")); }
|
if (i && index == MAX_SHUTTERS) { ResponseAppend_P(PSTR(",")); }
|
||||||
@ -479,6 +480,7 @@ void ShutterPowerOff(uint8_t i)
|
|||||||
if (Shutter[i].direction !=0) {
|
if (Shutter[i].direction !=0) {
|
||||||
Shutter[i].direction = 0;
|
Shutter[i].direction = 0;
|
||||||
}
|
}
|
||||||
|
TasmotaGlobal.rules_flag.shutter_moving = 0;
|
||||||
switch (Shutter[i].switch_mode) {
|
switch (Shutter[i].switch_mode) {
|
||||||
case SHT_SWITCH:
|
case SHT_SWITCH:
|
||||||
if ((1 << (Settings->shutter_startrelay[i]-1)) & TasmotaGlobal.power) {
|
if ((1 << (Settings->shutter_startrelay[i]-1)) & TasmotaGlobal.power) {
|
||||||
@ -535,6 +537,7 @@ void ShutterUpdatePosition(void)
|
|||||||
ShutterGlobal.start_reported = 1;
|
ShutterGlobal.start_reported = 1;
|
||||||
}
|
}
|
||||||
int32_t deltatime = Shutter[i].time-Shutter[i].last_reported_time;
|
int32_t deltatime = Shutter[i].time-Shutter[i].last_reported_time;
|
||||||
|
if (deltatime >= 0) {
|
||||||
Shutter[i].last_reported_time = Shutter[i].time+1;
|
Shutter[i].last_reported_time = Shutter[i].time+1;
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Time %d(%d), cStop %d, cVelo %d, mVelo %d, aVelo %d, mRun %d, aPos %d, aPos2 %d, nStop %d, Trgt %d, mVelo %d, Dir %d, Tilt %d, TrgtTilt: %d, Tiltmove: %d"),
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Time %d(%d), cStop %d, cVelo %d, mVelo %d, aVelo %d, mRun %d, aPos %d, aPos2 %d, nStop %d, Trgt %d, mVelo %d, Dir %d, Tilt %d, TrgtTilt: %d, Tiltmove: %d"),
|
||||||
Shutter[i].time, deltatime, current_stop_way, current_pwm_velocity, velocity_max, Shutter[i].accelerator, min_runtime_ms, current_real_position,Shutter[i].real_position,
|
Shutter[i].time, deltatime, current_stop_way, current_pwm_velocity, velocity_max, Shutter[i].accelerator, min_runtime_ms, current_real_position,Shutter[i].real_position,
|
||||||
@ -575,6 +578,7 @@ void ShutterUpdatePosition(void)
|
|||||||
ShutterReportPosition(true, i);
|
ShutterReportPosition(true, i);
|
||||||
TasmotaGlobal.rules_flag.shutter_moved = 1;
|
TasmotaGlobal.rules_flag.shutter_moved = 1;
|
||||||
XdrvRulesProcess(0);
|
XdrvRulesProcess(0);
|
||||||
|
} // timeloop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -594,7 +598,7 @@ void ShutterAllowPreStartProcedure(uint8_t i)
|
|||||||
#ifdef USE_RULES
|
#ifdef USE_RULES
|
||||||
uint32_t uptime_Local=0;
|
uint32_t uptime_Local=0;
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start? var%d <99>=<%s>, max10s?"),i+1, rules_vars[i]);
|
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start? var%d <99>=<%s>, max10s?"),i+1, rules_vars[i]);
|
||||||
TasmotaGlobal.rules_flag.shutter_moving = 1;
|
//TasmotaGlobal.rules_flag.shutter_moving = 1;
|
||||||
XdrvRulesProcess(0);
|
XdrvRulesProcess(0);
|
||||||
uptime_Local = TasmotaGlobal.uptime;
|
uptime_Local = TasmotaGlobal.uptime;
|
||||||
while (uptime_Local+10 > TasmotaGlobal.uptime && (String)rules_vars[i] == "99") {
|
while (uptime_Local+10 > TasmotaGlobal.uptime && (String)rules_vars[i] == "99") {
|
||||||
@ -1660,9 +1664,12 @@ bool Xdrv27(uint8_t function)
|
|||||||
case FUNC_PRE_INIT:
|
case FUNC_PRE_INIT:
|
||||||
ShutterInit();
|
ShutterInit();
|
||||||
break;
|
break;
|
||||||
case FUNC_EVERY_50_MSECOND:
|
case FUNC_LOOP:
|
||||||
ShutterUpdatePosition();
|
ShutterUpdatePosition();
|
||||||
break;
|
break;
|
||||||
|
// case FUNC_EVERY_50_MSECOND:
|
||||||
|
// ShutterUpdatePosition();
|
||||||
|
// break;
|
||||||
case FUNC_EVERY_SECOND:
|
case FUNC_EVERY_SECOND:
|
||||||
//case FUNC_EVERY_250_MSECOND:
|
//case FUNC_EVERY_250_MSECOND:
|
||||||
ShutterReportPosition(false, MAX_SHUTTERS);
|
ShutterReportPosition(false, MAX_SHUTTERS);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user