Added group/remote processing to SimMy #360

This commit is contained in:
Robert Strouse 2024-05-04 13:25:58 -07:00
parent d64103f259
commit 23731f793f
2 changed files with 17 additions and 4 deletions

View file

@ -2,6 +2,7 @@
#include <ELECHOUSE_CC1101_SRC_DRV.h> #include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <SPI.h> #include <SPI.h>
#include <WebServer.h> #include <WebServer.h>
#include <esp_task_wdt.h>
#include "Utils.h" #include "Utils.h"
#include "ConfigSettings.h" #include "ConfigSettings.h"
#include "Somfy.h" #include "Somfy.h"
@ -2113,8 +2114,12 @@ void SomfyShade::processWaitingFrame() {
this->emitState(); this->emitState();
} }
else if(this->isIdle()) { else if(this->isIdle()) {
if(this->simMy())
this->moveToMyPosition(); // Call out like this (instead of move to target) so that we don't get some of the goofy tilt only problems.
else {
if(this->myPos >= 0.0f && this->myPos <= 100.0f) this->p_target(this->myPos); if(this->myPos >= 0.0f && this->myPos <= 100.0f) this->p_target(this->myPos);
if(this->myTiltPos >= 0.0f && this->myTiltPos <= 100.0f) this->p_tiltTarget(this->myTiltPos); if(this->myTiltPos >= 0.0f && this->myTiltPos <= 100.0f) this->p_tiltTarget(this->myTiltPos);
}
this->setMovement(0); this->setMovement(0);
this->lastFrame.processed = true; this->lastFrame.processed = true;
this->emitCommand(cmd, "remote", this->lastFrame.remoteAddress); this->emitCommand(cmd, "remote", this->lastFrame.remoteAddress);
@ -2538,9 +2543,14 @@ void SomfyShade::processInternalCommand(somfy_commands cmd, uint8_t repeat) {
case somfy_commands::My: case somfy_commands::My:
if(this->isIdle()) { if(this->isIdle()) {
Serial.printf("Shade #%d is idle\n", this->getShadeId()); Serial.printf("Shade #%d is idle\n", this->getShadeId());
if(this->simMy()) {
this->moveToMyPosition();
}
else {
if(this->myTiltPos >= 0.0f && this->myTiltPos <= 100.0f) this->p_tiltTarget(this->myTiltPos); if(this->myTiltPos >= 0.0f && this->myTiltPos <= 100.0f) this->p_tiltTarget(this->myTiltPos);
if(this->myPos >= 0.0f && this->myPos <= 100.0f && this->tiltType != tilt_types::tiltonly) this->p_target(this->myPos); if(this->myPos >= 0.0f && this->myPos <= 100.0f && this->tiltType != tilt_types::tiltonly) this->p_target(this->myPos);
} }
}
else { else {
if(this->tiltType == tilt_types::tiltonly) { if(this->tiltType == tilt_types::tiltonly) {
this->p_target(100.0f); this->p_target(100.0f);
@ -2881,6 +2891,7 @@ void SomfyGroup::sendCommand(somfy_commands cmd, uint8_t repeat) {
// is expected to be called internally when the motor needs commanded. // is expected to be called internally when the motor needs commanded.
if(this->bitLength == 0) this->bitLength = somfy.transceiver.config.type; if(this->bitLength == 0) this->bitLength = somfy.transceiver.config.type;
SomfyRemote::sendCommand(cmd, repeat); SomfyRemote::sendCommand(cmd, repeat);
switch(cmd) { switch(cmd) {
case somfy_commands::My: case somfy_commands::My:
this->p_direction(0); this->p_direction(0);
@ -2894,6 +2905,7 @@ void SomfyGroup::sendCommand(somfy_commands cmd, uint8_t repeat) {
default: default:
break; break;
} }
for(uint8_t i = 0; i < SOMFY_MAX_GROUPED_SHADES; i++) { for(uint8_t i = 0; i < SOMFY_MAX_GROUPED_SHADES; i++) {
if(this->linkedShades[i] != 0) { if(this->linkedShades[i] != 0) {
SomfyShade *shade = somfy.getShadeById(this->linkedShades[i]); SomfyShade *shade = somfy.getShadeById(this->linkedShades[i]);
@ -3931,6 +3943,7 @@ void SomfyShadeController::sendFrame(somfy_frame_t &frame, uint8_t repeat) {
} }
for(uint8_t i = 0; i < repeat; i++) { for(uint8_t i = 0; i < repeat; i++) {
this->transceiver.sendFrame(frm, frame.bitLength == 56 ? 7 : 6, frame.bitLength); this->transceiver.sendFrame(frm, frame.bitLength == 56 ? 7 : 6, frame.bitLength);
esp_task_wdt_reset();
} }
this->transceiver.endTransmit(); this->transceiver.endTransmit();
} }

Binary file not shown.