From 487378b71e0587110728f4892d2cd9965ce6608f Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Tue, 3 Oct 2023 16:18:04 +0200 Subject: [PATCH] Ignore interrupts while sending blinds signal Makes transmission more reliable. --- blinds.yaml | 3 +++ somfy.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/blinds.yaml b/blinds.yaml index f64f02e..b885bb6 100644 --- a/blinds.yaml +++ b/blinds.yaml @@ -9,6 +9,9 @@ esphome: includes: - somfy.h + libraries: + - SPI + packages: device_base: !include templates/esp8266.yaml sensor: !include templates/esp8266-vcc.yaml diff --git a/somfy.h b/somfy.h index e0c5979..348ad65 100644 --- a/somfy.h +++ b/somfy.h @@ -1,3 +1,4 @@ +#include #include "esphome.h" namespace { @@ -104,6 +105,8 @@ class SomfyRTS : public Component, public Cover { frame[i] ^= frame[i-1]; } + noInterrupts(); + // Wake-up pulse & silence. digitalWrite(rfPin, HIGH); delayMicroseconds(9415); @@ -150,6 +153,8 @@ class SomfyRTS : public Component, public Cover { delayMicroseconds(30415); } + interrupts(); + // Publish the new rolling code at the end to ensure fast reaction time // when the component is called. This method may be synchronous and // introduces an unpredictable delay.