add feed hold and release (! and ~) to usb serial as per grbl
authorJim Morris <morris@wolfman.com>
Thu, 28 Jan 2016 22:46:04 +0000 (14:46 -0800)
committerJim Morris <morris@wolfman.com>
Thu, 28 Jan 2016 22:46:04 +0000 (14:46 -0800)
src/libs/Kernel.cpp
src/libs/Kernel.h
src/libs/USBDevice/USBSerial/USBSerial.cpp

index 542d0ae..6bd2f7a 100644 (file)
@@ -46,6 +46,7 @@ Kernel* Kernel::instance;
 // The kernel is the central point in Smoothie : it stores modules, and handles event calls
 Kernel::Kernel(){
     halted= false;
+    feed_hold= false;
 
     instance= this; // setup the Singleton instance of the kernel
 
@@ -164,6 +165,8 @@ std::string Kernel::get_query_string()
         str.append("Alarm,");
     }else if(homing) {
         str.append("Home,");
+    }else if(feed_hold) {
+        str.append("Hold,");
     }else if(this->conveyor->is_queue_empty()) {
         str.append("Idle,");
     }else{
index 7d83382..36f037d 100644 (file)
@@ -47,6 +47,9 @@ class Kernel {
         bool is_halted() const { return halted; }
         bool is_grbl_mode() const { return grbl_mode; }
 
+        void set_feed_hold(bool f) { feed_hold= f; }
+        bool get_feed_hold() const { return feed_hold; }
+
         std::string get_query_string();
 
         // These modules are available to all other modules
@@ -74,6 +77,7 @@ class Kernel {
             bool use_leds:1;
             bool halted:1;
             bool grbl_mode:1;
+            bool feed_hold:1;
         };
 
 };
index 6810b86..e4ece61 100644 (file)
@@ -207,6 +207,16 @@ bool USBSerial::USBEvent_EPOut(uint8_t bEP, uint8_t bEPStatus)
             continue;\r
         }\r
 \r
+        if(c[i] == '!'){ // safe pause\r
+            THEKERNEL->set_feed_hold(true);\r
+            continue;\r
+        }\r
+\r
+        if(c[i] == '~'){ // safe resume\r
+            THEKERNEL->set_feed_hold(false);\r
+            continue;\r
+        }\r
+\r
         if (flush_to_nl == false)\r
             rxbuf.queue(c[i]);\r
 \r
@@ -315,6 +325,10 @@ void USBSerial::on_main_loop(void *argument)
             nl_in_rx = 0;\r
         }\r
     }\r
+\r
+    // if we are in feed hold we do not process anything\r
+    if(THEKERNEL->get_feed_hold()) return;\r
+\r
     if (nl_in_rx)\r
     {\r
         string received;\r