add mode setters

This commit is contained in:
Robin Müller 2023-11-09 17:18:33 +01:00
parent 35be7da353
commit bf7fac071c
2 changed files with 12 additions and 3 deletions

View File

@ -34,13 +34,20 @@ ReturnValue_t FreshDeviceHandlerBase::performOperation(uint8_t opCode) {
void FreshDeviceHandlerBase::startTransition(Mode_t mode_, Submode_t submode_) { void FreshDeviceHandlerBase::startTransition(Mode_t mode_, Submode_t submode_) {
triggerEvent(CHANGING_MODE, mode_, submode_); triggerEvent(CHANGING_MODE, mode_, submode_);
mode = mode_; // Complete mode transition immediately by default.
submode = submode_; setMode(mode_, submode_);
}
void FreshDeviceHandlerBase::setMode(Mode_t newMode, Submode_t newSubmode) {
mode = newMode;
submode = newSubmode;
modeHelper.modeChanged(mode, submode); modeHelper.modeChanged(mode, submode);
modeChanged(mode, submode); modeChanged(mode, submode);
announceMode(false); announceMode(false);
} }
void FreshDeviceHandlerBase::setMode(Mode_t newMode) { setMode(newMode, submode); }
void FreshDeviceHandlerBase::getMode(Mode_t* mode_, Submode_t* submode_) { void FreshDeviceHandlerBase::getMode(Mode_t* mode_, Submode_t* submode_) {
*mode_ = this->mode; *mode_ = this->mode;
*submode_ = this->submode; *submode_ = this->submode;

View File

@ -89,6 +89,8 @@ class FreshDeviceHandlerBase : public SystemObject,
* new mode. * new mode.
*/ */
void startTransition(Mode_t mode, Submode_t submode) override; void startTransition(Mode_t mode, Submode_t submode) override;
virtual void setMode(Mode_t newMode, Submode_t newSubmode);
virtual void setMode(Mode_t newMode);
void getMode(Mode_t* mode, Submode_t* submode) override; void getMode(Mode_t* mode, Submode_t* submode) override;
void setToExternalControl() override; void setToExternalControl() override;
void announceMode(bool recursive) override; void announceMode(bool recursive) override;