cap speed override to not less than 1%
authorJim Morris <morris@wolfman.com>
Thu, 1 Aug 2013 06:59:16 +0000 (23:59 -0700)
committerJim Morris <morris@wolfman.com>
Thu, 1 Aug 2013 07:36:06 +0000 (00:36 -0700)
sync watch screen with speed override changed via M220

src/modules/robot/Robot.cpp
src/modules/utils/panel/panels/ReprapDiscountGLCD.cpp
src/modules/utils/panel/screens/WatchScreen.cpp

index 0fee853..15ee5fe 100644 (file)
@@ -138,7 +138,11 @@ void Robot::on_set_public_data(void* argument){
     if(!pdr->starts_with(robot_checksum)) return;
 
     if(pdr->second_element_is(speed_override_percent_checksum)) {
+        // NOTE do not use this while printing!
         double t= *static_cast<double*>(pdr->get_data_ptr());
+        // enforce minimum 1% speed
+        if (t < 1.0) t= 1.0;
+    
         this->seconds_per_minute= t * 0.6;
         pdr->set_taken();
     }
index 21d1f63..d01a841 100644 (file)
@@ -107,5 +107,6 @@ void ReprapDiscountGLCD::bltGlyph(int x, int y, int w, int h, const uint8_t *gly
 void ReprapDiscountGLCD::on_refresh(bool now){
     static int refresh_counts = 0;
     refresh_counts++;
+    // 5Hz refresh rate
     if(now || refresh_counts % 4 == 0 ) this->glcd->refresh();
 }
\ No newline at end of file
index 6539701..7b18cb6 100644 (file)
@@ -43,9 +43,15 @@ void WatchScreen::on_refresh(){
     // see if speed is being changed
     if(this->panel->control_value_change()) {
         this->current_speed= this->panel->get_control_value();
-        // change actual speed
-        set_current_speed();
-        this->refresh_screen(false);
+        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->refresh_screen(false);
+        }
     }
     
     // Update Only every 20 refreshes, 1 a second
@@ -56,6 +62,9 @@ void WatchScreen::on_refresh(){
         get_current_pos(this->pos);
         get_temp_data();
         this->current_speed= get_current_speed();
+        this->panel->set_control_value(this->current_speed); // in case it was changed via M220
+        this->panel->reset_counter();
+
         this->refresh_screen(false);
 
         // for LCDs with leds set them according to heater status