Possibe Fixes of the pointer

This commit is contained in:
Václav Španinger 2024-12-28 10:07:17 +01:00
parent 8733fb7737
commit 63c165d21e
2 changed files with 8 additions and 8 deletions

View File

@ -135,7 +135,7 @@ namespace esphome {
//Parse Printitme
if(MarlinOutput.find("echo:Print time: ") == 0) {
int* d=0, h=0, m=0, s=0;
float* d=0, h=0, m=0, s=0;
unsigned long current=0, remaining=0;
if (process_print_time_msg(&d, &h, &m, &s, &current, &remaining) != 0) {
@ -229,18 +229,18 @@ namespace esphome {
return ((float) current / (float) total) * 100.0;
}
int Marlin2::process_print_time_msg(int d, int h, int m, int s, unsigned long* current, unsigned long* remaining){
int Marlin2::process_print_time_msg(float** d, float* h, float* m, float* s, unsigned long* current, unsigned long* remaining){
MarlinTime = MarlinOutput.substr(16);
ESP_LOGD(TAG,MarlinTime.c_str());
if (sscanf(MarlinTime.c_str() ,"%dd %dh %dm %ds", &d, &h, &m, &s)!=4) {
if (sscanf(MarlinTime.c_str() ,"%fd %fh %fm %fs", &d, &h, &m, &s)!=4) {
d=0;
if (sscanf(MarlinTime.c_str() ,"%dh %dm %ds", &h, &m, &s)!=3) {
if (sscanf(MarlinTime.c_str() ,"%fh %fm %fs", &h, &m, &s)!=3) {
d=0; h=0;
if (sscanf(MarlinTime.c_str() ,"%dm %ds", &m, &s)!=2) {
if (sscanf(MarlinTime.c_str() ,"%fm %fs", &m, &s)!=2) {
d=0; h=0; m=0;
if (sscanf(MarlinTime.c_str() ,"%ds", &s)!=1) {
if (sscanf(MarlinTime.c_str() ,"%fs", &s)!=1) {
MarlinOutput="";
return;
}
@ -248,7 +248,7 @@ namespace esphome {
}
}
current = static_cast<float>((d*24*60*60) + (h*60*60) + (m*60) + (s));
current = ((d)*24*60*60) + ((h)*60*60) + ((m)*60) + (s);
return 0;

View File

@ -22,7 +22,7 @@ class Marlin2 : public PollingComponent, /*public text_sensor::TextSensor,*/ pub
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();
int process_print_time_msg(int d, int h, int m, int s, unsigned long* current, unsigned long* remaining);
int process_print_time_msg(float** d, float* h, float* m, float* s, unsigned long* current, unsigned long* remaining);
std::string MarlinOutput;
std::string MarlinTime;