This commit is contained in:
Václav Španinger 2025-06-16 11:07:46 +02:00
parent fd901fd1e1
commit 68ab694d8a
3 changed files with 22 additions and 1 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
s
__pycache__/*

View File

@ -218,6 +218,23 @@ namespace esphome {
return;
}
size_t first_space = MarlinOutput.find(' ');
size_t second_space = MarlinOutput.find(' ', first_space + 1);
if(second_space == std::string::npos && first_space == std::string::npos) {
std::string short_name = MarlinOutput.substr(0, first_space);
std::string long_name = MarlinOutput.substr(second_space + 1);
file_table_[long_name] = short_name;
ESP_LOGD(TAG, "Uloženo do tabulky: %s => %s", long_name.c_str(), short_name.c_str());
//reset string for next line
MarlinOutput="";
return;
}
ESP_LOGD(TAG, "#%s#",MarlinOutput.c_str());
MarlinOutput="";
return;

View File

@ -1,5 +1,7 @@
#pragma once
#include <string>
#include <unordered_map>
#include "esphome/core/component.h"
#include "esphome/components/uart/uart.h"
#ifdef USE_SENSOR
@ -15,7 +17,6 @@ class Marlin2 : public PollingComponent, public uart::UARTDevice {
public:
Marlin2() = default;
#ifdef USE_SENSOR
void add_sensor(const std::string& sName, sensor::Sensor *sens);
sensor::Sensor* find_sensor(std::string key);
@ -55,6 +56,7 @@ class Marlin2 : public PollingComponent, public uart::UARTDevice {
private:
unsigned long millisProgress=0;
std::unordered_map<std::string, std::string> file_table_;
};
} // namespace esphome