return this;
}
-
-
-
+// Helper for screens to send a gcode
+void PanelScreen::send_gcode(std::string g) {
+ Gcode gcode(g, &(StreamOutput::NullStream));
+ THEKERNEL->call_event(ON_GCODE_RECEIVED, &gcode );
+}
Panel* panel;
PanelScreen* parent;
+
+ protected:
+ void send_gcode(std::string g);
};
#include "modules/robot/RobotPublicAccess.h"
using namespace std;
-#define JOGGING_SPEED_MM_MIN 1200
-
ControlScreen::ControlScreen(){
this->control_mode = NULL_CONTROL_MODE;
}
string g(buf, n);
send_gcode(g);
}
-
-void ControlScreen::send_gcode(std::string g) {
- Gcode gcode(g, &(StreamOutput::NullStream));
- THEKERNEL->call_event(ON_GCODE_RECEIVED, &gcode );
-}
-
private:
void clicked_menu_entry(uint16_t line);
void display_axis_line(char axis);
- void send_gcode(std::string msg);
void enter_axis_control(char axis);
void enter_menu_control();
void get_current_pos(double *p);
void ExtruderScreen::clicked_menu_entry(uint16_t line){
switch( line ){
case 0: this->panel->enter_screen(this->parent); return;
- case 1: send_gcode("G91"); send_gcode("G1 E5"); send_gcode("G90"); break;
- case 2: send_gcode("G91"); send_gcode("G1 E-5"); send_gcode("G90"); break;
+ case 1: send_command("G91"); send_command("G1 E5"); send_command("G90"); break;
+ case 2: send_command("G91"); send_command("G1 E-5"); send_command("G90"); break;
}
}
-void ExtruderScreen::send_gcode(const char* gcstr) {
- string gcode(gcstr);
+void ExtruderScreen::send_command(const char* gcstr) {
+ string cmd(gcstr);
struct SerialMessage message;
- message.message = gcode;
+ message.message = cmd;
message.stream = &(StreamOutput::NullStream);
THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
}
void clicked_menu_entry(uint16_t line);
private:
- void send_gcode(const char* gcstr);
+ void send_command(const char* gcstr);
};
#endif
void PrepareScreen::clicked_menu_entry(uint16_t line){
switch( line ){
case 0: this->panel->enter_screen(this->parent); break;
- case 1: send_gcode("G28"); break;
- case 2: send_gcode("G92 X0 Y0 Z0"); break;
+ case 1: send_command("G28"); break;
+ case 2: send_command("G92 X0 Y0 Z0"); break;
case 3: this->preheat(); break;
case 4: this->cooldown(); break;
case 5: this->panel->enter_screen(this->extruder_screen); break;
- case 6: send_gcode("M84"); break;
+ case 6: send_command("M84"); break;
//case 7: this->panel->enter_screen(this->temp_screen ); break;
}
THEKERNEL->public_data->set_value( temperature_control_checksum, bed_checksum, &t );
}
-void PrepareScreen::send_gcode(const char* gcstr) {
- string gcode(gcstr);
+void PrepareScreen::send_command(const char* gcstr) {
+ string cmd(gcstr);
struct SerialMessage message;
- message.message = gcode;
+ message.message = cmd;
message.stream = &(StreamOutput::NullStream);
THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
}
PanelScreen* temp_screen;
void preheat();
void cooldown();
- void send_gcode(const char* gcstr);
+ void send_command(const char* gcstr);
};
#endif
#include <string>
using namespace std;
-WatchScreen::WatchScreen(){}
+WatchScreen::WatchScreen(){
+ speed_changed= false;
+}
void WatchScreen::on_enter(){
this->panel->lcd->clear();
// see if speed is being changed
if(this->panel->control_value_change()) {
this->current_speed= this->panel->get_control_value();
- if(this->current_speed <= 1.0) {
+ if(this->current_speed < 1.0) {
this->current_speed= 1.0;
this->panel->set_control_value(this->current_speed);
this->panel->reset_counter();
}else{
// change actual speed
- set_current_speed();
+ this->speed_changed= true; // flag main loop to isseu g code
this->refresh_screen(false);
}
}
}
}
+// queuing gcodes needs to be done from main loop
+void WatchScreen::on_main_loop() {
+ if(!this->speed_changed) return;
+ this->speed_changed= false;
+ set_speed();
+}
+
// fetch the data we are displaying
void WatchScreen::get_temp_data() {
void *returned_data;
return 0.0;
}
-void WatchScreen::set_current_speed() {
- bool ok= THEKERNEL->public_data->set_value( robot_checksum, speed_override_percent_checksum, &this->current_speed );
- if(!ok) this->current_speed= 0;
-
-}
-
void WatchScreen::get_current_pos(double *cp){
void *returned_data;
return "Smoothie ready";
}
+
+void WatchScreen::set_speed(){
+ // change pos by issuing a M220 Snnn
+ char buf[32];
+ int n= snprintf(buf, sizeof(buf), "M220 S%f", this->current_speed);
+ string g(buf, n);
+ send_gcode(g);
+}
WatchScreen();
void on_refresh();
void on_enter();
+ void on_main_loop();
void display_menu_line(uint16_t line);
private:
void get_temp_data();
double get_current_speed();
- void set_current_speed();
+ void set_speed();
void get_current_pos(double *cp);
void get_sd_play_info();
const char* get_status();
+ bool speed_changed;
int hotendtemp;
int hotendtarget;
int bedtemp;