summaryrefslogtreecommitdiffstats
path: root/esphome/config/my_components/mycc1101
diff options
context:
space:
mode:
Diffstat (limited to 'esphome/config/my_components/mycc1101')
-rw-r--r--esphome/config/my_components/mycc1101/__init__.py22
-rw-r--r--esphome/config/my_components/mycc1101/mycc1101.h39
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 @@
1import esphome.codegen as cg
2from esphome.components import spi, remote_base
3import esphome.config_validation as cv
4from esphome.const import CONF_ID, CONF_PROTOCOL, CONF_CODE
5from esphome.components import cc1101
6from types import FunctionType
7
8cc1101.MULTI_CONF_NO_DEFAULT = True
9AUTO_LOAD = ["cc1101"]
10DEPENDENCIES = cc1101.DEPENDENCIES
11
12ns = cg.esphome_ns.namespace("cc1101")
13MyCC1101Component = ns.class_("MyCC1101Component", cc1101.CC1101Component)#, cg.Component, spi.SPIDevice)
14
15CONFIG_SCHEMA = cc1101.CONFIG_SCHEMA.extend(
16 {
17 cv.GenerateID(): cv.declare_id(MyCC1101Component),
18 }
19)
20
21to_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
6namespace esphome {
7namespace cc1101 {
8
9static const char *const TAG = "mycc1101";
10
11class 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