Merge remote-tracking branch 'upstream/edge' into feature/e-endstop
[clinton/Smoothieware.git] / src / libs / Kernel.cpp
index bff0af4..0538cb4 100644 (file)
@@ -40,7 +40,6 @@
 
 #define base_stepping_frequency_checksum            CHECKSUM("base_stepping_frequency")
 #define microseconds_per_step_pulse_checksum        CHECKSUM("microseconds_per_step_pulse")
-#define acceleration_ticks_per_second_checksum      CHECKSUM("acceleration_ticks_per_second")
 #define disable_leds_checksum                       CHECKSUM("leds_disable")
 #define grbl_mode_checksum                          CHECKSUM("grbl_mode")
 #define ok_per_line_checksum                        CHECKSUM("ok_per_line")
@@ -99,7 +98,14 @@ Kernel::Kernel(){
 
     //some boards don't have leds.. TOO BAD!
     this->use_leds= !this->config->value( disable_leds_checksum )->by_default(false)->as_bool();
+
+    #ifdef CNC
+    this->grbl_mode= this->config->value( grbl_mode_checksum )->by_default(true)->as_bool();
+    #else
     this->grbl_mode= this->config->value( grbl_mode_checksum )->by_default(false)->as_bool();
+    #endif
+
+    // we exepct ok per line now not per G code, setting this to false will return to the old (incorrect) way of ok per G code
     this->ok_per_line= this->config->value( ok_per_line_checksum )->by_default(true)->as_bool();
 
     this->add_module( this->serial );
@@ -108,7 +114,7 @@ Kernel::Kernel(){
     add_module( this->slow_ticker = new SlowTicker());
 
     this->step_ticker = new StepTicker();
-    this->adc = new(AHB0) Adc();
+    this->adc = new Adc();
 
     // TODO : These should go into platform-specific files
     // LPC17xx-specific
@@ -137,12 +143,11 @@ Kernel::Kernel(){
 
     // Configure the step ticker
     this->base_stepping_frequency = this->config->value(base_stepping_frequency_checksum)->by_default(100000)->as_number();
-    float microseconds_per_step_pulse = this->config->value(microseconds_per_step_pulse_checksum)->by_default(5)->as_number();
-    this->acceleration_ticks_per_second = THEKERNEL->config->value(acceleration_ticks_per_second_checksum)->by_default(1000)->as_number();
+    float microseconds_per_step_pulse = this->config->value(microseconds_per_step_pulse_checksum)->by_default(1)->as_number();
 
-    // Configure the step ticker ( TODO : shouldnt this go into stepticker's code ? )
-    this->step_ticker->set_unstep_time( microseconds_per_step_pulse );
+    // Configure the step ticker
     this->step_ticker->set_frequency( this->base_stepping_frequency );
+    this->step_ticker->set_unstep_time( microseconds_per_step_pulse );
 
     // Core modules
     this->add_module( this->gcode_dispatch = new GcodeDispatch() );
@@ -150,8 +155,8 @@ Kernel::Kernel(){
     this->add_module( this->conveyor       = new Conveyor()      );
     this->add_module( this->simpleshell    = new SimpleShell()   );
 
-    this->planner = new(AHB0) Planner();
-    this->configurator   = new Configurator();
+    this->planner = new Planner();
+    this->configurator = new Configurator();
 }
 
 // return a GRBL-like query string for serial ?
@@ -178,16 +183,10 @@ std::string Kernel::get_query_string()
     }
 
     if(running) {
-        // get real time current actuator position in mm
-        ActuatorCoordinates current_position{
-            robot->actuators[X_AXIS]->get_current_position(),
-            robot->actuators[Y_AXIS]->get_current_position(),
-            robot->actuators[Z_AXIS]->get_current_position()
-        };
-
-        // get machine position from the actuator position using FK
         float mpos[3];
-        robot->arm_solution->actuator_to_cartesian(current_position, mpos);
+        robot->get_current_machine_position(mpos);
+        // current_position/mpos includes the compensation transform so we need to get the inverse to get actual position
+        if(robot->compensationTransform) robot->compensationTransform(mpos, true); // get inverse compensation transform
 
         char buf[128];
         // machine position
@@ -233,7 +232,7 @@ void Kernel::call_event(_EVENT_ENUM id_event, void * argument){
     bool was_idle= true;
     if(id_event == ON_HALT) {
         this->halted= (argument == nullptr);
-        was_idle= conveyor->is_queue_empty(); // see if we were doing anything like printing
+        was_idle= conveyor->is_idle(); // see if we were doing anything like printing
     }
 
     // send to all registered modules