2024-12-27 10:47:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "esphome/core/component.h"
|
|
|
|
#include "esphome/components/sensor/sensor.h"
|
|
|
|
#include "esphome/components/uart/uart.h"
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
|
2024-12-27 14:04:48 +00:00
|
|
|
class Marlin2 : public PollingComponent , public uart::UARTDevice {
|
2024-12-27 10:47:42 +00:00
|
|
|
public:
|
2024-12-27 11:21:33 +00:00
|
|
|
void setup() override;
|
|
|
|
float get_setup_priority() const override { return setup_priority::LATE; }
|
2024-12-27 14:04:48 +00:00
|
|
|
void update() override;
|
2024-12-27 20:06:46 +00:00
|
|
|
void add_sensor(const std::string& sName, sensor::Sensor *sens);
|
|
|
|
sensor::Sensor* find_sensor(std::string key);
|
2024-12-27 14:04:48 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void process_line();
|
|
|
|
int process_temp_msg(float* ext_temperature, float* ext_set_temperature, float* bed_temperature, float* bed_set_temperature);
|
|
|
|
float process_progress_msg();
|
2024-12-27 20:06:46 +00:00
|
|
|
int process_print_time_msg(int* d, int* h, int* m, unsigned long* current, unsigned long* remaining);
|
|
|
|
|
2024-12-27 14:04:48 +00:00
|
|
|
std::string MarlinOutput;
|
2024-12-27 20:41:13 +00:00
|
|
|
std::string MarlinTime;
|
2024-12-27 20:25:10 +00:00
|
|
|
std::string PrinterState;
|
|
|
|
|
2024-12-27 20:06:46 +00:00
|
|
|
std::vector<std::pair<std::string, sensor::Sensor *>> sensors;
|
2024-12-27 14:04:48 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned long millisProgress=0;
|
2024-12-27 10:47:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace esphome
|