Skip to content

Commit

Permalink
Changed last pulse so it sets the final bit to 0. It only should do t…
Browse files Browse the repository at this point in the history
…his if the last bit was 0.
  • Loading branch information
rstrouse committed Apr 8, 2023
1 parent b6bc57e commit ca76d01
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions Somfy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1672,40 +1672,46 @@ 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
REG_WRITE(GPIO_OUT_W1TC_REG, pin);
// 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() {
Expand Down
Binary file modified SomfyController.ino.esp32.bin
Binary file not shown.
Binary file modified SomfyController.littlefs.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ca76d01

Please sign in to comment.