ESPHome
2024.12.2
esphome
esphome
components
pylontech
pylontech.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/core/defines.h
"
5
#include "
esphome/components/uart/uart.h
"
6
7
namespace
esphome
{
8
namespace
pylontech {
9
10
static
const
uint8_t NUM_BUFFERS = 20;
11
static
const
uint8_t TEXT_SENSOR_MAX_LEN = 8;
12
13
class
PylontechListener
{
14
public
:
15
struct
LineContents
{
16
int
bat_num
= 0,
volt
,
curr
,
tempr
,
tlow
,
thigh
,
vlow
,
vhigh
,
coulomb
,
mostempr
;
17
char
base_st
[TEXT_SENSOR_MAX_LEN],
volt_st
[TEXT_SENSOR_MAX_LEN],
curr_st
[TEXT_SENSOR_MAX_LEN],
18
temp_st
[TEXT_SENSOR_MAX_LEN];
19
};
20
21
virtual
void
on_line_read
(
LineContents
*line);
22
virtual
void
dump_config
();
23
};
24
25
class
PylontechComponent
:
public
PollingComponent
,
public
uart::UARTDevice
{
26
public
:
27
PylontechComponent
();
28
30
void
update()
override
;
32
void
loop
()
override
;
34
void
setup
()
override
;
35
void
dump_config
()
override
;
36
37
float
get_setup_priority()
const override
;
38
39
void
register_listener
(
PylontechListener
*listener) { this->listeners_.push_back(listener); }
40
41
protected
:
42
void
process_line_(std::string &buffer);
43
44
// ring buffer
45
std::string buffer_[NUM_BUFFERS];
46
int
buffer_index_write_ = 0;
47
int
buffer_index_read_ = 0;
48
49
std::vector<PylontechListener *> listeners_{};
50
};
51
52
}
// namespace pylontech
53
}
// namespace esphome
setup
void setup()
loop
void loop()
esphome::pylontech::PylontechComponent
Definition:
pylontech.h:25
uart.h
esphome::pylontech::PylontechListener::LineContents::coulomb
int coulomb
Definition:
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::curr
int curr
Definition:
pylontech.h:16
esphome::pylontech::PylontechListener::dump_config
virtual void dump_config()
esphome::pylontech::PylontechListener::LineContents::thigh
int thigh
Definition:
pylontech.h:16
esphome::pylontech::PylontechComponent::register_listener
void register_listener(PylontechListener *listener)
Definition:
pylontech.h:39
esphome::pylontech::PylontechListener::LineContents
Definition:
pylontech.h:15
esphome::pylontech::PylontechListener::LineContents::temp_st
char temp_st[TEXT_SENSOR_MAX_LEN]
Definition:
pylontech.h:17
esphome::PollingComponent
This class simplifies creating components that periodically check a state.
Definition:
component.h:283
esphome::pylontech::PylontechListener::LineContents::tempr
int tempr
Definition:
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::mostempr
int mostempr
Definition:
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::vlow
int vlow
Definition:
pylontech.h:16
defines.h
esphome::pylontech::PylontechListener::LineContents::curr_st
char curr_st[TEXT_SENSOR_MAX_LEN]
Definition:
pylontech.h:17
esphome::pylontech::PylontechListener::LineContents::volt_st
char volt_st[TEXT_SENSOR_MAX_LEN]
Definition:
pylontech.h:17
esphome::pylontech::PylontechListener::LineContents::tlow
int tlow
Definition:
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::vhigh
int vhigh
Definition:
pylontech.h:16
esphome::uart::UARTDevice
Definition:
uart.h:12
esphome::pylontech::PylontechListener::LineContents::volt
int volt
Definition:
pylontech.h:16
esphome::pylontech::PylontechListener
Definition:
pylontech.h:13
esphome::pylontech::PylontechListener::LineContents::base_st
char base_st[TEXT_SENSOR_MAX_LEN]
Definition:
pylontech.h:17
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
component.h
esphome::pylontech::PylontechListener::on_line_read
virtual void on_line_read(LineContents *line)
esphome::pylontech::PylontechListener::LineContents::bat_num
int bat_num
Definition:
pylontech.h:16
Generated by
1.8.13