this->lcd= NULL;
this->do_buttons = false;
this->idle_time= 0;
+ strcpy(this->playing_file, "Playing file");
}
Panel::~Panel() {
return b;
}
return false;
-}
\ No newline at end of file
+}
+
+void Panel::set_playing_file(string f) {
+ // just copy the first 20 characters after the first / if there
+ size_t n= f.find_last_of('/');
+ if(n == string::npos) n= 0;
+ strncpy(playing_file, f.substr(n+1, 19).c_str(), sizeof(playing_file));
+ playing_file[sizeof(playing_file)-1]= 0;
+}
// file playing from sd
bool is_playing() const;
- void set_playing_file(string f) { playing_file= f; }
- string get_playing_file() { return playing_file; }
+ void set_playing_file(string f);
+ const char* get_playing_file() { return playing_file; }
// public as it is directly accessed by screens... not good
// TODO pass lcd into ctor of each sub screen
double default_hotend_temperature;
double default_bed_temperature;
- string playing_file;
+ char playing_file[20];
};
#endif
void FileScreen::on_main_loop(){
if(this->start_play){
this->start_play= false;
- play(this->play_path);
- panel->set_playing_file(this->play_path);
+ this->panel->set_playing_file(this->play_path);
+ this->play(this->play_path);
this->panel->enter_screen(this->parent);
return;
}
case 0: this->panel->lcd->printf("H%03d/%03dc B%03d/%03dc", this->hotendtemp, this->hotendtarget, this->bedtemp, this->bedtarget); break;
case 1: this->panel->lcd->printf("X%4d Y%4d Z%7.2f", (int)round(this->pos[0]), (int)round(this->pos[1]), this->pos[2]); break;
case 2: this->panel->lcd->printf("%3d%% %2d:%02d %3d%% sd", (int)round(this->current_speed), this->elapsed_time/60, this->elapsed_time%60, this->sd_pcnt_played); break;
- case 3: this->panel->lcd->printf("%19s", panel->is_playing() ? panel->get_playing_file().substr(4, 19).c_str() : "Smoothie ready"); break;
+ case 3: this->panel->lcd->printf("%19s", panel->is_playing() ? panel->get_playing_file() : "Smoothie ready"); break;
}
-
}