diff options
Diffstat (limited to 'esphome/config/my_components/mycc1101')
| -rw-r--r-- | esphome/config/my_components/mycc1101/__init__.py | 22 | ||||
| -rw-r--r-- | esphome/config/my_components/mycc1101/mycc1101.h | 39 |
2 files changed, 61 insertions, 0 deletions
diff --git a/esphome/config/my_components/mycc1101/__init__.py b/esphome/config/my_components/mycc1101/__init__.py new file mode 100644 index 0000000..14261fb --- /dev/null +++ b/esphome/config/my_components/mycc1101/__init__.py | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | import esphome.codegen as cg | ||
| 2 | from esphome.components import spi, remote_base | ||
| 3 | import esphome.config_validation as cv | ||
| 4 | from esphome.const import CONF_ID, CONF_PROTOCOL, CONF_CODE | ||
| 5 | from esphome.components import cc1101 | ||
| 6 | from types import FunctionType | ||
| 7 | |||
| 8 | cc1101.MULTI_CONF_NO_DEFAULT = True | ||
| 9 | AUTO_LOAD = ["cc1101"] | ||
| 10 | DEPENDENCIES = cc1101.DEPENDENCIES | ||
| 11 | |||
| 12 | ns = cg.esphome_ns.namespace("cc1101") | ||
| 13 | MyCC1101Component = ns.class_("MyCC1101Component", cc1101.CC1101Component)#, cg.Component, spi.SPIDevice) | ||
| 14 | |||
| 15 | CONFIG_SCHEMA = cc1101.CONFIG_SCHEMA.extend( | ||
| 16 | { | ||
| 17 | cv.GenerateID(): cv.declare_id(MyCC1101Component), | ||
| 18 | } | ||
| 19 | ) | ||
| 20 | |||
| 21 | to_code = cc1101.to_code | ||
| 22 | |||
diff --git a/esphome/config/my_components/mycc1101/mycc1101.h b/esphome/config/my_components/mycc1101/mycc1101.h new file mode 100644 index 0000000..95f714d --- /dev/null +++ b/esphome/config/my_components/mycc1101/mycc1101.h | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "esphome/components/cc1101/cc1101.h" | ||
| 4 | #include "esphome/components/cc1101/cc1101defs.h" | ||
| 5 | |||
| 6 | namespace esphome { | ||
| 7 | namespace cc1101 { | ||
| 8 | |||
| 9 | static const char *const TAG = "mycc1101"; | ||
| 10 | |||
| 11 | class MyCC1101Component : public CC1101Component { | ||
| 12 | public: | ||
| 13 | void idle() { | ||
| 14 | ESP_LOGD(TAG, "idle"); | ||
| 15 | this->send_(Command::IDLE); | ||
| 16 | } | ||
| 17 | |||
| 18 | void power_down() { | ||
| 19 | ESP_LOGD(TAG, "power_down"); | ||
| 20 | this->send_(Command::IDLE); | ||
| 21 | this->send_(Command::PWD); | ||
| 22 | } | ||
| 23 | |||
| 24 | void wakeup() { | ||
| 25 | ESP_LOGD(TAG, "wakeup"); | ||
| 26 | this->cs_->digital_write(false); | ||
| 27 | delayMicroseconds(10); | ||
| 28 | this->cs_->digital_write(true); | ||
| 29 | delayMicroseconds(200); | ||
| 30 | |||
| 31 | this->send_(Command::IDLE); | ||
| 32 | |||
| 33 | // set patable after after wakeup | ||
| 34 | this->set_output_power(this->output_power_requested_); | ||
| 35 | } | ||
| 36 | }; | ||
| 37 | |||
| 38 | } // namespace cc1101 | ||
| 39 | } // namespace esphome | ||
