esphome/esphome/components/hx711/hx711.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
817 B
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/core/esphal.h"
#include "esphome/components/sensor/sensor.h"
namespace esphome {
namespace hx711 {
enum HX711Gain {
HX711_GAIN_128 = 1,
HX711_GAIN_32 = 2,
HX711_GAIN_64 = 3,
};
class HX711Sensor : public sensor::Sensor, public PollingComponent {
public:
void set_dout_pin(GPIOPin *dout_pin) { dout_pin_ = dout_pin; }
void set_sck_pin(GPIOPin *sck_pin) { sck_pin_ = sck_pin; }
void set_gain(HX711Gain gain) { gain_ = gain; }
void setup() override;
void dump_config() override;
float get_setup_priority() const override;
void update() override;
protected:
bool read_sensor_(uint32_t *result);
GPIOPin *dout_pin_;
GPIOPin *sck_pin_;
HX711Gain gain_{HX711_GAIN_128};
};
} // namespace hx711
} // namespace esphome