diff --git a/Somfy.cpp b/Somfy.cpp index 85f3319..443d3b6 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -1672,23 +1672,28 @@ void Transceiver::sendFrame(byte *frame, uint8_t sync, uint8_t bitLength) { delayMicroseconds(SYMBOL); // Payload starting with the most significant bit. The frame is always supplied in 80 bits // but if the protocol is calling for 56 bits it will only send 56 bits of the frame. + uint8_t last_bit = 0; for (byte i = 0; i < bitLength; i++) { if (((frame[i / 8] >> (7 - (i % 8))) & 1) == 1) { REG_WRITE(GPIO_OUT_W1TC_REG, pin); delayMicroseconds(SYMBOL); REG_WRITE(GPIO_OUT_W1TS_REG, pin); delayMicroseconds(SYMBOL); + last_bit = 1; } else { REG_WRITE(GPIO_OUT_W1TS_REG, pin); delayMicroseconds(SYMBOL); REG_WRITE(GPIO_OUT_W1TC_REG, pin); delayMicroseconds(SYMBOL); + last_bit = 0; } } // End with a 0 no matter what. This accommodates the 56-bit protocol by telling the // motor that there are no more follow on bits. - REG_WRITE(GPIO_OUT_W1TS_REG, pin); - //delayMicroseconds(SYMBOL/2); + if(last_bit == 0) { + REG_WRITE(GPIO_OUT_W1TS_REG, pin); + //delayMicroseconds(SYMBOL); + } // Inter-frame silence for 56-bit protocols are around 34ms. However, an 80 bit protocol should // reduce this by the transmission of SYMBOL * 24 or 15,360us @@ -1696,16 +1701,17 @@ void Transceiver::sendFrame(byte *frame, uint8_t sync, uint8_t bitLength) { // Below are the original calculations for inter-frame silence. However, when actually inspecting this from // the remote it appears to be closer to 27500us. The delayMicoseconds call cannot be called with // values larger than 16383. + if(bitLength != 80) { + delayMicroseconds(13717); + delayMicroseconds(13717); + } + /* if(bitLength == 80) delayMicroseconds(15055); else delayMicroseconds(30415); */ - if(bitLength != 80) { - delayMicroseconds(13750); - delayMicroseconds(13750); - } } void RECEIVE_ATTR Transceiver::handleReceive() { diff --git a/SomfyController.ino.esp32.bin b/SomfyController.ino.esp32.bin index a6775d0..9e17df7 100644 Binary files a/SomfyController.ino.esp32.bin and b/SomfyController.ino.esp32.bin differ diff --git a/SomfyController.littlefs.bin b/SomfyController.littlefs.bin index b79868b..c295b3e 100644 Binary files a/SomfyController.littlefs.bin and b/SomfyController.littlefs.bin differ diff --git a/data/index.js b/data/index.js index 44f5b07..6b7a95e 100644 --- a/data/index.js +++ b/data/index.js @@ -1215,7 +1215,7 @@ class Somfy { sendShadeMyPosition(shadeId, pos) { console.log(`Sending My Position for shade id ${shadeId} to ${pos}`); let overlay = waitMessage(document.getElementById('divContainer')); - putJSON('/setMyPosition', { shadeId: shadeId, target: pos }, (err, response) => { + putJSON('/setMyPosition', { shadeId: shadeId, target: parseInt(pos, 10) }, (err, response) => { this.closeShadePositioners(); overlay.remove(); console.log(response);