clean up some more headers files
authorJim Morris <morris@wolfman.com>
Tue, 22 Apr 2014 08:33:00 +0000 (01:33 -0700)
committerJim Morris <morris@wolfman.com>
Tue, 22 Apr 2014 08:33:54 +0000 (01:33 -0700)
move printf implementation out of steamoutput header

12 files changed:
src/libs/StreamOutput.cpp
src/libs/StreamOutput.h
src/modules/communication/utils/Gcode.h
src/modules/robot/Robot.cpp
src/modules/tools/endstops/Endstops.cpp
src/modules/tools/extruder/Extruder.cpp
src/modules/tools/switch/Switch.cpp
src/modules/tools/temperaturecontrol/PID_Autotuner.cpp
src/modules/tools/zprobe/ZProbe.cpp
src/modules/tools/zprobe/ZProbe.h
src/modules/utils/currentcontrol/CurrentControl.cpp
src/modules/utils/panel/PanelScreen.cpp

index 97317f0..8957bc8 100644 (file)
@@ -1,3 +1,29 @@
 #include "StreamOutput.h"
 
 NullStreamOutput StreamOutput::NullStream;
+
+int StreamOutput::printf(const char *format, ...)
+{
+    char b[64];
+    char *buffer;
+    // Make the message
+    va_list args;
+    va_start(args, format);
+
+    int size = vsnprintf(b, 64, format, args) + 1; // we add one to take into account space for the terminating \0
+
+    if (size < 64) {
+        buffer = b;
+    } else {
+        buffer = new char[size];
+        vsnprintf(buffer, size, format, args);
+    }
+    va_end(args);
+
+    puts(buffer);
+
+    if (buffer != b)
+        delete[] buffer;
+
+    return size - 1;
+}
index 9ab2528..ac355bc 100644 (file)
@@ -23,32 +23,7 @@ class StreamOutput {
         StreamOutput(){}
         virtual ~StreamOutput(){}
 
-        virtual int printf(const char* format, ...) __attribute__ ((format(printf, 2, 3))) {
-            char b[64];
-            char *buffer;
-            // Make the message
-            va_list args;
-            va_start(args, format);
-
-            int size = vsnprintf(b, 64, format, args)
-                + 1; // we add one to take into account space for the terminating \0
-
-            if (size < 64)
-                buffer = b;
-            else
-            {
-                buffer = new char[size];
-                vsnprintf(buffer, size, format, args);
-            }
-            va_end(args);
-
-            puts(buffer);
-
-            if (buffer != b)
-                delete[] buffer;
-
-            return size - 1;
-        }
+        virtual int printf(const char *format, ...) __attribute__ ((format(printf, 2, 3)));
         virtual int _putc(int c) { return 1; }
         virtual int _getc(void) { return 0; }
         virtual int puts(const char* str) = 0;
index 999932f..b761d06 100644 (file)
 #define GCODE_H
 #include <string>
 using std::string;
-#include "libs/StreamOutput.h"
-// Object to represent a Gcode command
 #include <stdlib.h>
 
+class StreamOutput;
+
+// Object to represent a Gcode command
 class Gcode {
     public:
         Gcode(const string&, StreamOutput*);
-        Gcode(const Gcode& to_copy); 
+        Gcode(const Gcode& to_copy);
         Gcode& operator= (const Gcode& to_copy);
-        
+
         bool   has_letter ( char letter );
 
         float get_value  ( char letter );
index 1be517a..391a808 100644 (file)
@@ -31,6 +31,7 @@ using std::string;
 #include "checksumm.h"
 #include "utils.h"
 #include "ConfigValue.h"
+#include "libs/StreamOutput.h"
 
 #define  default_seek_rate_checksum          CHECKSUM("default_seek_rate")
 #define  default_feed_rate_checksum          CHECKSUM("default_feed_rate")
index 8afda5a..ceacaeb 100644 (file)
@@ -22,6 +22,7 @@
 #include "checksumm.h"
 #include "utils.h"
 #include "ConfigValue.h"
+#include "libs/StreamOutput.h"
 
 #define ALPHA_AXIS 0
 #define BETA_AXIS  1
index 8ceeb75..2ccfb59 100644 (file)
@@ -22,6 +22,7 @@
 #include "checksumm.h"
 #include "ConfigValue.h"
 #include "Gcode.h"
+#include "libs/StreamOutput.h"
 
 #include <mri.h>
 
index da925ad..93ae8a5 100644 (file)
@@ -19,6 +19,7 @@
 #include "Gcode.h"
 #include "checksumm.h"
 #include "ConfigValue.h"
+#include "libs/StreamOutput.h"
 
 #include "MRI_Hooks.h"
 
index 3349102..230fcbf 100644 (file)
@@ -3,6 +3,7 @@
 #include "SlowTicker.h"
 #include "Gcode.h"
 #include "TemperatureControl.h"
+#include "libs/StreamOutput.h"
 
 #include <cmath>        // std::abs
 
index 0a343f3..da94a62 100644 (file)
@@ -140,6 +140,25 @@ bool ZProbe::run_probe(int *steps)
     return r;
 }
 
+/* Run a calibration routine for a delta
+    1. Home
+    2. probe for z bed
+    3. move to base of each tower at 5mm above bed
+    4. probe down to bed
+    5. probe next tower
+    6. calculate trim offsets and apply them
+    7. Home
+    8. Probe center
+    9. calculate delta radius and apply it
+    10. check level
+*/
+
+bool ZProbe::calibrate_delta(Gcode *gcode)
+{
+
+    return true;
+}
+
 void ZProbe::on_gcode_received(void *argument)
 {
     Gcode *gcode = static_cast<Gcode *>(argument);
@@ -184,6 +203,14 @@ void ZProbe::on_gcode_received(void *argument)
             }else{
                 gcode->stream->printf("ZProbe not triggered\n");
             }
+
+        }else if( gcode->g == 32 ) {
+            gcode->mark_as_taken();
+            if(is_delta) {
+                calibrate_delta(gcode);
+            }else{
+                 gcode->stream->printf("Not supported yet\n");
+            }
         }
 
     } else if(gcode->has_m) {
index d8dbbc5..51397e7 100644 (file)
@@ -12,6 +12,7 @@
 #include "Pin.h"
 
 class StepperMotor;
+class Gcode;
 
 class ZProbe: public Module
 {
@@ -27,6 +28,7 @@ public:
 private:
     bool wait_for_probe(int distance[]);
     bool run_probe(int *steps);
+    bool calibrate_delta(Gcode *gcode);
 
     float          feedrate;
     float          steps_per_mm[3];
index 828f476..34188ce 100644 (file)
@@ -3,6 +3,7 @@
 #include "libs/nuts_bolts.h"
 #include "libs/utils.h"
 #include "ConfigValue.h"
+#include "libs/StreamOutput.h"
 
 #include "Gcode.h"
 #include "Config.h"
index fffbe45..68dab38 100644 (file)
@@ -13,6 +13,7 @@
 #include "libs/SerialMessage.h"
 #include "Gcode.h"
 #include "LcdBase.h"
+#include "libs/StreamOutput.h"
 
 #include <string>
 #include <vector>