Beta processing for step commands algorithm

This commit is contained in:
Robert Strouse 2023-04-24 18:59:05 -07:00
parent 39c6e08ca5
commit ae87dc1d82
3 changed files with 13 additions and 19 deletions

View file

@ -3,7 +3,7 @@
#ifndef configsettings_h #ifndef configsettings_h
#define configsettings_h #define configsettings_h
#define FW_VERSION "v1.5.1" #define FW_VERSION "v1.5.2beta"
enum DeviceStatus { enum DeviceStatus {
DS_OK = 0, DS_OK = 0,
DS_ERROR = 1, DS_ERROR = 1,

View file

@ -1021,39 +1021,33 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
} }
} }
break; break;
case somfy_commands::MyUp:
case somfy_commands::StepUp: case somfy_commands::StepUp:
dir = 0; dir = 0;
this->lastFrame.processed = true; this->lastFrame.processed = true;
// With the step commands and integrated shades // With the step commands and integrated shades
// the motor must tilt in the direction first then move // the motor must tilt in the direction first then move
// so we have to calculate the target with this in mind. // so we have to calculate the target with this in mind.
if(this->tiltType == tilt_types::integrated) { if(this->tiltType == tilt_types::integrated && this->currentTiltPos > 0.0f) {
// First check to see if the tilt is 0. If it is not then we need to tilt. this->tiltTarget = max(0.0f, this->currentTiltPos - (100.0f/(static_cast<float>(this->tiltTime/100.0f))));
if(this->currentTiltPos > 0.0f) { }
this->tiltTarget = max(0.0f, this->currentTiltPos - 1.0f); else if(this->currentPos > 0.0f) {
} this->target = max(0.0f, this->currentPos - (100.0f/(static_cast<float>(this->upTime/100.0f))));
else if(this->currentPos > 0.0f) {
this->target = max(0.0f, this->currentPos - 1.0f);
}
} }
else if(this->currentPos > 0.0f) this->target = max(0.0f, this->currentPos - 1.0f);
break; break;
case somfy_commands::MyDown:
case somfy_commands::StepDown: case somfy_commands::StepDown:
dir = 1; dir = 1;
this->lastFrame.processed = true; this->lastFrame.processed = true;
// With the step commands and integrated shades // With the step commands and integrated shades
// the motor must tilt in the direction first then move // the motor must tilt in the direction first then move
// so we have to calculate the target with this in mind. // so we have to calculate the target with this in mind.
if(this->tiltType == tilt_types::integrated) { if(this->tiltType == tilt_types::integrated && this->currentTiltPos < 100.0f) {
// First check to see if the tilt is 0. If it is not then we need to tilt. this->tiltTarget = min(100.0f, this->currentTiltPos + (100.0f/(static_cast<float>(this->tiltTime/100.0f))));
if(this->currentTiltPos < 100.0f) { }
this->tiltTarget = min(100.0f, this->currentTiltPos + 1.0f); else if(this->currentPos < 100.0f) {
} this->target = min(100.0f, this->currentPos + (100.0f/(static_cast<float>(this->downTime/100.0f))));
else if(this->currentPos > 100.0f) {
this->target = min(100.0f, this->currentPos + 1.0f);
}
} }
else if(this->currentPos < 100.0f) this->target = min(100.0f, this->currentPos + 1.0f);
break; break;
default: default:
dir = 0; dir = 0;

Binary file not shown.