ESPHomeMarlin2/marlin2.cpp

37 lines
716 B
C++
Raw Normal View History

2024-12-27 10:47:42 +00:00
#include "marlin2.h"
#include "esphome/core/log.h"
namespace esphome {
2024-12-27 11:21:33 +00:00
static const char *TAG = "marlin2";
void Marlin2::setup() {
this->write_str("\r\n\r\nM155 S10\r\n");
ESP_LOGV(TAG, "M155 S10");
}
2024-12-27 10:47:42 +00:00
void Marlin2::loop() {
2024-12-27 11:21:33 +00:00
while (this->available()) {
uint8_t c;
this->read_byte(&c);
if (c == '\r')
continue;
if (c == '\n')
this->parse_values_();
else
this->rx_message_.push_back(c);
}
2024-12-27 10:47:42 +00:00
}
2024-12-27 11:21:33 +00:00
void Marlin2::parse_values_() {
std::string s(this->rx_message_.begin(), this->rx_message_.end());
ESP_LOGV(TAG, s);
}
2024-12-27 11:02:11 +00:00
2024-12-27 11:21:33 +00:00
void Marlin2::dump_config() {
ESP_LOGCONFIG(TAG, "Serial CSV Reader");
}
2024-12-27 11:02:11 +00:00
2024-12-27 10:47:42 +00:00
} // namespace esphome