progress
This commit is contained in:
parent
68ab694d8a
commit
91f2dd54be
45
marlin2.cpp
45
marlin2.cpp
@ -86,10 +86,43 @@ namespace esphome {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!MarlinOutput.compare("ok") || !MarlinOutput.compare(" ok")) {
|
if(!MarlinOutput.compare("ok") || !MarlinOutput.compare(" ok")) {
|
||||||
|
listingFile = false;
|
||||||
MarlinOutput="";
|
MarlinOutput="";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!listingFile && MarlinOutput.compare("Begin file list") == 0) {
|
||||||
|
ESP_LOGD(TAG, "Listing of files started!");
|
||||||
|
listingFile = true;
|
||||||
|
//reset string for next line
|
||||||
|
MarlinOutput="";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(listingFile && MarlinOutput.compare(".GCO ")) {
|
||||||
|
int first_space = MarlinOutput.find(' ');
|
||||||
|
int second_space = MarlinOutput.find(' ', first_space + 1);
|
||||||
|
|
||||||
|
if(first_space > 0) {
|
||||||
|
std::string short_name = MarlinOutput.substr(0, first_space);
|
||||||
|
std::string long_name = short_name;
|
||||||
|
|
||||||
|
if (second_space > first_space){
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Parse periodic Temperature read out message
|
//Parse periodic Temperature read out message
|
||||||
if(
|
if(
|
||||||
MarlinOutput.find(" T:") == 0 ||
|
MarlinOutput.find(" T:") == 0 ||
|
||||||
@ -218,17 +251,11 @@ namespace esphome {
|
|||||||
return;
|
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());
|
|
||||||
|
|
||||||
|
if(MarlinOutput.find("End file list") != std::string::npos) {
|
||||||
|
ESP_LOGD(TAG, "Listing of files stopped!");
|
||||||
|
listingFile = false;
|
||||||
//reset string for next line
|
//reset string for next line
|
||||||
MarlinOutput="";
|
MarlinOutput="";
|
||||||
return;
|
return;
|
||||||
|
@ -57,6 +57,7 @@ class Marlin2 : public PollingComponent, public uart::UARTDevice {
|
|||||||
private:
|
private:
|
||||||
unsigned long millisProgress=0;
|
unsigned long millisProgress=0;
|
||||||
std::unordered_map<std::string, std::string> file_table_;
|
std::unordered_map<std::string, std::string> file_table_;
|
||||||
|
bool listingFile = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace esphome
|
} // namespace esphome
|
Loading…
x
Reference in New Issue
Block a user