Fixes
This commit is contained in:
30
marlin2.h
30
marlin2.h
@@ -19,46 +19,42 @@
|
||||
|
||||
namespace esphome::marlin2 {
|
||||
|
||||
class Marlin2 : public PollingComponent, public uart::UARTDevice {
|
||||
class Marlin2 : public Component, public uart::UARTDevice {
|
||||
public:
|
||||
Marlin2() = default;
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
void add_sensor(const std::string &name, sensor::Sensor *sens);
|
||||
sensor::Sensor *find_sensor(const std::string &key);
|
||||
void publish_sensor(const std::string &key, float value);
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
void add_text_sensor(const std::string &name, text_sensor::TextSensor *tSens);
|
||||
text_sensor::TextSensor *find_text_sensor(const std::string &key);
|
||||
void publish_text_sensor(const std::string &key, const std::string &value);
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
void add_select(const std::string &name, select::Select *sel);
|
||||
select::Select *find_select(const std::string &key);
|
||||
#endif
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
void add_binary_sensor(const std::string &name, binary_sensor::BinarySensor *bs);
|
||||
binary_sensor::BinarySensor *find_binary_sensor(const std::string &key);
|
||||
void publish_binary_sensor(const std::string &key, bool value);
|
||||
#endif
|
||||
|
||||
void set_max_sd_files(uint8_t n) { max_sd_files_ = n; }
|
||||
|
||||
void write(std::string gcode);
|
||||
std::string to_dos_name(std::string filename);
|
||||
std::string from_dos_name(std::string dos_filename);
|
||||
void write(const std::string &gcode);
|
||||
std::string to_dos_name(const std::string &filename);
|
||||
std::string from_dos_name(const std::string &dos_filename);
|
||||
|
||||
float get_setup_priority() const override { return setup_priority::LATE; }
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
std::string marlin_output_;
|
||||
std::string marlin_response_output_;
|
||||
std::string marlin_time_;
|
||||
std::string printer_state_;
|
||||
|
||||
float print_progress_ = 0;
|
||||
double print_time_offset_ = 0;
|
||||
uint8_t max_sd_files_ = 20;
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
@@ -75,14 +71,20 @@ class Marlin2 : public PollingComponent, public uart::UARTDevice {
|
||||
#endif
|
||||
|
||||
void process_line();
|
||||
void set_printer_state(std::string status);
|
||||
void set_printer_state(const std::string &status);
|
||||
void publish_sd_files();
|
||||
int process_temp_msg(float *ext_temperature, float *ext_set_temperature, float *bed_temperature, float *bed_set_temperature);
|
||||
float process_progress_msg();
|
||||
int process_print_time_msg(double *current, double *remaining, float progress);
|
||||
|
||||
private:
|
||||
unsigned long millis_progress_ = 0;
|
||||
template<typename T>
|
||||
static T *find_in_(std::vector<std::pair<std::string, T *>> &vec, const std::string &key) {
|
||||
for (auto &pair : vec)
|
||||
if (pair.first == key) return pair.second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::string> file_table_;
|
||||
bool listing_file_ = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user