mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 19:12:10 +01:00
Changed last pulse so it sets the final bit to 0. It only should do this if the last bit was 0.
This commit is contained in:
parent
b6bc57e437
commit
ca76d01a1a
4 changed files with 13 additions and 7 deletions
16
Somfy.cpp
16
Somfy.cpp
|
|
@ -1672,23 +1672,28 @@ void Transceiver::sendFrame(byte *frame, uint8_t sync, uint8_t bitLength) {
|
||||||
delayMicroseconds(SYMBOL);
|
delayMicroseconds(SYMBOL);
|
||||||
// Payload starting with the most significant bit. The frame is always supplied in 80 bits
|
// 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.
|
// 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++) {
|
for (byte i = 0; i < bitLength; i++) {
|
||||||
if (((frame[i / 8] >> (7 - (i % 8))) & 1) == 1) {
|
if (((frame[i / 8] >> (7 - (i % 8))) & 1) == 1) {
|
||||||
REG_WRITE(GPIO_OUT_W1TC_REG, pin);
|
REG_WRITE(GPIO_OUT_W1TC_REG, pin);
|
||||||
delayMicroseconds(SYMBOL);
|
delayMicroseconds(SYMBOL);
|
||||||
REG_WRITE(GPIO_OUT_W1TS_REG, pin);
|
REG_WRITE(GPIO_OUT_W1TS_REG, pin);
|
||||||
delayMicroseconds(SYMBOL);
|
delayMicroseconds(SYMBOL);
|
||||||
|
last_bit = 1;
|
||||||
} else {
|
} else {
|
||||||
REG_WRITE(GPIO_OUT_W1TS_REG, pin);
|
REG_WRITE(GPIO_OUT_W1TS_REG, pin);
|
||||||
delayMicroseconds(SYMBOL);
|
delayMicroseconds(SYMBOL);
|
||||||
REG_WRITE(GPIO_OUT_W1TC_REG, pin);
|
REG_WRITE(GPIO_OUT_W1TC_REG, pin);
|
||||||
delayMicroseconds(SYMBOL);
|
delayMicroseconds(SYMBOL);
|
||||||
|
last_bit = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// End with a 0 no matter what. This accommodates the 56-bit protocol by telling the
|
// 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.
|
// motor that there are no more follow on bits.
|
||||||
|
if(last_bit == 0) {
|
||||||
REG_WRITE(GPIO_OUT_W1TS_REG, pin);
|
REG_WRITE(GPIO_OUT_W1TS_REG, pin);
|
||||||
//delayMicroseconds(SYMBOL/2);
|
//delayMicroseconds(SYMBOL);
|
||||||
|
}
|
||||||
|
|
||||||
// Inter-frame silence for 56-bit protocols are around 34ms. However, an 80 bit protocol should
|
// 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
|
// 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
|
// 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
|
// the remote it appears to be closer to 27500us. The delayMicoseconds call cannot be called with
|
||||||
// values larger than 16383.
|
// values larger than 16383.
|
||||||
|
if(bitLength != 80) {
|
||||||
|
delayMicroseconds(13717);
|
||||||
|
delayMicroseconds(13717);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if(bitLength == 80)
|
if(bitLength == 80)
|
||||||
delayMicroseconds(15055);
|
delayMicroseconds(15055);
|
||||||
else
|
else
|
||||||
delayMicroseconds(30415);
|
delayMicroseconds(30415);
|
||||||
*/
|
*/
|
||||||
if(bitLength != 80) {
|
|
||||||
delayMicroseconds(13750);
|
|
||||||
delayMicroseconds(13750);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RECEIVE_ATTR Transceiver::handleReceive() {
|
void RECEIVE_ATTR Transceiver::handleReceive() {
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -1215,7 +1215,7 @@ class Somfy {
|
||||||
sendShadeMyPosition(shadeId, pos) {
|
sendShadeMyPosition(shadeId, pos) {
|
||||||
console.log(`Sending My Position for shade id ${shadeId} to ${pos}`);
|
console.log(`Sending My Position for shade id ${shadeId} to ${pos}`);
|
||||||
let overlay = waitMessage(document.getElementById('divContainer'));
|
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();
|
this.closeShadePositioners();
|
||||||
overlay.remove();
|
overlay.remove();
|
||||||
console.log(response);
|
console.log(response);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue