Merge pull request #7436 from to-scho/hotfix/shutterbuttons

Fixed exception with ShutterButton
This commit is contained in:
Theo Arends 2020-01-04 16:41:24 +01:00 committed by GitHub
commit 81d3b35d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -562,6 +562,11 @@ void ShutterButtonHandler(void)
press_index = (buttonState == SHT_PRESSED_HOLD) ? 3 : (press_index-1);
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SHT: shutter %d, button %d = %d (single=1, double=2, tripple=3, hold=4)"), shutter_index+1, button_index+1, press_index+1);
XdrvMailbox.index = shutter_index +1;
last_source = SRC_BUTTON;
XdrvMailbox.data_len = 0;
char databuf[1] = "";
XdrvMailbox.data = databuf;
XdrvMailbox.command = NULL;
if (buttonState == SHT_PRESSED_IMMEDIATE) {
XdrvMailbox.payload = XdrvMailbox.index;
CmndShutterStop();
@ -646,7 +651,8 @@ void CmndShutterStop(void)
last_source = SRC_WEBGUI;
CmndShutterPosition();
} else {
ResponseCmndDone();
if (XdrvMailbox.command)
ResponseCmndDone();
}
}
}
@ -724,7 +730,8 @@ void CmndShutterPosition(void)
target_pos_percent = ShutterRealToPercentPosition(Shutter.real_position[index], index);
}
XdrvMailbox.index = index +1; // Fix random index for ShutterClose
ResponseCmndIdxNumber(Settings.shutter_invert[index] ? 100 - target_pos_percent : target_pos_percent);
if (XdrvMailbox.command)
ResponseCmndIdxNumber(Settings.shutter_invert[index] ? 100 - target_pos_percent : target_pos_percent);
}
}