summaryrefslogtreecommitdiffstats
path: root/esphome/config/my_components/mycc1101/mycc1101.h
blob: 95f714d0ff5e85bea5959759c808dcb1cbba2f34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once

#include "esphome/components/cc1101/cc1101.h"
#include "esphome/components/cc1101/cc1101defs.h"

namespace esphome {
namespace cc1101 {

static const char *const TAG = "mycc1101";

class MyCC1101Component : public CC1101Component {
  public:
    void idle() {
      ESP_LOGD(TAG, "idle");
      this->send_(Command::IDLE);
    }

    void power_down() {
      ESP_LOGD(TAG, "power_down");
      this->send_(Command::IDLE);
      this->send_(Command::PWD);
    }

    void wakeup() {
      ESP_LOGD(TAG, "wakeup");
      this->cs_->digital_write(false);
      delayMicroseconds(10);
      this->cs_->digital_write(true);
      delayMicroseconds(200);

      this->send_(Command::IDLE);

      // set patable after after wakeup
      this->set_output_power(this->output_power_requested_);
    }
};

}  // namespace cc1101
}  // namespace esphome