esphome-geiger-counter/components/geiger_counter_sensor/geiger_counter_sensor.h

35 lines
1.1 KiB
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/uart/uart.h"
#include "esphome/core/gpio.h"
namespace esphome {
namespace geiger_counter_sensor {
class GeigerCounterSensor : public sensor::Sensor, public PollingComponent, public uart::UARTDevice {
public:
void setup() override;
void update() override;
void loop() override;
void dump_config() override;
void set_green_led_pin(GPIOPin *pin) { green_led_pin_ = pin; }
void set_yellow_led_pin(GPIOPin *pin) { yellow_led_pin_ = pin; }
void set_red_led_pin(GPIOPin *pin) { red_led_pin_ = pin; }
void set_safe_level(float safe_level) { safe_level_ = safe_level; }
void set_warning_level(float warning_level) { warning_level_ = warning_level; }
private:
GPIOPin *green_led_pin_{nullptr};
GPIOPin *yellow_led_pin_{nullptr};
GPIOPin *red_led_pin_{nullptr};
float safe_level_{0.35};
float warning_level_{0.7};
};
} // namespace geiger_counter_sensor
} // namespace esphome
int readline(int readch, char *buffer, int len);