ESPHome 2025.5.0
Loading...
Searching...
No Matches
cap1188.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
8
9#include <vector>
10
11namespace esphome {
12namespace cap1188 {
13
14enum {
28};
29
31 public:
32 void set_channel(uint8_t channel) { channel_ = channel; }
33 void process(uint8_t data) { this->publish_state(static_cast<bool>(data & (1 << this->channel_))); }
34
35 protected:
36 uint8_t channel_{0};
37};
38
40 public:
41 void register_channel(CAP1188Channel *channel) { this->channels_.push_back(channel); }
42 void set_touch_threshold(uint8_t touch_threshold) { this->touch_threshold_ = touch_threshold; };
43 void set_allow_multiple_touches(bool allow_multiple_touches) {
44 this->allow_multiple_touches_ = allow_multiple_touches ? 0x41 : 0x80;
45 };
46 void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
47 void setup() override;
48 void dump_config() override;
49 float get_setup_priority() const override { return setup_priority::DATA; }
50 void loop() override;
51
52 protected:
53 std::vector<CAP1188Channel *> channels_{};
54 uint8_t touch_threshold_{0x20};
56
58
62
63 enum ErrorCode {
64 NONE = 0,
66 } error_code_{NONE};
67};
68
69} // namespace cap1188
70} // namespace esphome
Base class for all binary_sensor-type classes.
void publish_state(bool state)
Publish a new state to the front-end.
void process(uint8_t data)
Definition cap1188.h:33
void set_channel(uint8_t channel)
Definition cap1188.h:32
void set_reset_pin(GPIOPin *reset_pin)
Definition cap1188.h:46
void set_allow_multiple_touches(bool allow_multiple_touches)
Definition cap1188.h:43
enum esphome::cap1188::CAP1188Component::ErrorCode NONE
void register_channel(CAP1188Channel *channel)
Definition cap1188.h:41
void set_touch_threshold(uint8_t touch_threshold)
Definition cap1188.h:42
std::vector< CAP1188Channel * > channels_
Definition cap1188.h:53
float get_setup_priority() const override
Definition cap1188.h:49
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
@ CAP1188_STAND_BY_CONFIGURATION
Definition cap1188.h:21
@ CAP1188_INTERUPT_REPEAT
Definition cap1188.h:26
@ CAP1188_MANUFACTURE_ID
Definition cap1188.h:20
@ CAP1188_SENSOR_INPUT_STATUS
Definition cap1188.h:16
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7