Tighten up autopid to produce better results
[clinton/Smoothieware.git] / src / modules / tools / temperaturecontrol / PID_Autotuner.h
index bc0e715..dbf9214 100644 (file)
@@ -8,30 +8,29 @@
 #include <stdint.h>
 
 #include "Module.h"
-#include "TemperatureControl.h"
-#include "StreamOutput.h"
+
+class TemperatureControl;
+class StreamOutput;
 
 class PID_Autotuner : public Module
 {
 public:
     PID_Autotuner();
-    void     begin(TemperatureControl *, double, StreamOutput *, int cycles = 8);
-    void     abort();
 
-    void     on_module_loaded(void);
+    void on_module_loaded(void);
     uint32_t on_tick(uint32_t);
-    void     on_idle(void *);
-    void     on_gcode_received(void *);
+    void on_idle(void *);
+    void on_gcode_received(void *);
 
 private:
+    void begin(float, StreamOutput *, int );
+    void abort();
     void finishUp();
 
-    TemperatureControl *t;
+    TemperatureControl *temp_control;
     float target_temperature;
     StreamOutput *s;
 
-    volatile bool tick;
-
     float *peaks;
     int requested_cycles;
     float noiseBand;
@@ -42,11 +41,15 @@ private:
     int peakType;
     float *lastInputs;
     int peakCount;
-    bool justchanged;
     float absMax, absMin;
     float oStep;
     int output;
-    unsigned long tickCnt;
+    volatile unsigned long tickCnt;
+    struct {
+        bool justchanged:1;
+        volatile bool tick:1;
+        bool firstPeak:1;
+    };
 };
 
 #endif /* _PID_AUTOTUNE_H */