esphome/esphome/components/ttp229_lsf/ttp229_lsf.h
Otto Winter 8e75980ebd
Cleanup dashboard JS (#491)
* Cleanup dashboard JS

* Add vscode

* Save start_mark/end_mark

* Updates

* Updates

* Remove need for cv.nameable

It's a bit hacky but removes so much bloat from integrations

* Add enum helper

* Document APIs, and Improvements

* Fixes

* Fixes

* Update PULL_REQUEST_TEMPLATE.md

* Updates

* Updates

* Updates
2019-04-22 21:56:30 +02:00

36 lines
962 B
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/components/binary_sensor/binary_sensor.h"
#include "esphome/components/i2c/i2c.h"
namespace esphome {
namespace ttp229_lsf {
class TTP229Channel : public binary_sensor::BinarySensor {
public:
void set_channel(uint8_t channel) { channel_ = channel; }
void process(uint16_t data) { this->publish_state(data & (1 << this->channel_)); }
protected:
uint8_t channel_;
};
class TTP229LSFComponent : public Component, public i2c::I2CDevice {
public:
void register_channel(TTP229Channel *channel) { this->channels_.push_back(channel); }
void setup() override;
void dump_config() override;
float get_setup_priority() const override { return setup_priority::DATA; }
void loop() override;
protected:
std::vector<TTP229Channel *> channels_{};
enum ErrorCode {
NONE = 0,
COMMUNICATION_FAILED,
} error_code_{NONE};
};
} // namespace ttp229_lsf
} // namespace esphome