From: Jim Morris Date: Wed, 11 Apr 2018 10:46:35 +0000 (+0100) Subject: Allow non contigous definition of ABC homing endstops X-Git-Url: https://git.hcoop.net/clinton/Smoothieware.git/commitdiff_plain/927cd05f93b84627a7e56bebf3a7d959cd35f774 Allow non contigous definition of ABC homing endstops --- diff --git a/src/modules/communication/GcodeDispatch.cpp b/src/modules/communication/GcodeDispatch.cpp index 94a62834..147038f5 100644 --- a/src/modules/communication/GcodeDispatch.cpp +++ b/src/modules/communication/GcodeDispatch.cpp @@ -260,7 +260,7 @@ try_again: delete gcode; return; - case 115: // M115 Get firmware version and capabilities + case 115: { // M115 Get firmware version and capabilities Version vers; new_message.stream->printf("FIRMWARE_NAME:Smoothieware, FIRMWARE_URL:http%%3A//smoothieware.org, X-SOURCE_CODE_URL:https://github.com/Smoothieware/Smoothieware, FIRMWARE_VERSION:%s, X-FIRMWARE_BUILD_DATE:%s, X-SYSTEM_CLOCK:%ldMHz, X-AXES:%d", vers.get_build(), vers.get_build_date(), SystemCoreClock / 1000000, MAX_ROBOT_ACTUATORS); @@ -279,6 +279,7 @@ try_again: new_message.stream->printf("\nok\n"); return; + } case 117: // M117 is a special non compliant Gcode as it allows arbitrary text on the line following the command { // concatenate the command again and send to panel if enabled diff --git a/src/modules/tools/endstops/Endstops.cpp b/src/modules/tools/endstops/Endstops.cpp index 26681ef5..efc7d154 100644 --- a/src/modules/tools/endstops/Endstops.cpp +++ b/src/modules/tools/endstops/Endstops.cpp @@ -228,6 +228,7 @@ bool Endstops::load_old_config() bool Endstops::load_config() { bool limit_enabled= false; + size_t max_index= 0; std::array temp_axis_array; // needs to be at least XYZ, but allow for ABC { @@ -273,6 +274,9 @@ bool Endstops::load_config() continue; } + // keep track of the maximum index that has been defined + if(i > max_index) max_index= i; + // init pin struct pin_info->debounce= 0; pin_info->axis= toupper(axis[0]); @@ -330,7 +334,8 @@ bool Endstops::load_config() // if no pins defined then disable the module if(endstops.empty()) return false; - // copy to the homing_axis array + // copy to the homing_axis array, make sure that undefined entries are filled in as well + // as the order is important and all slots must be filled upto the max_index for (size_t i = 0; i < temp_axis_array.size(); ++i) { if(temp_axis_array[i].axis == 0) { // was not configured above, if it is XYZ then we need to force a dummy entry @@ -340,6 +345,14 @@ bool Endstops::load_config() t.axis_index= i; t.pin_info= nullptr; // this tells it that it cannot be used for homing homing_axis.push_back(t); + + }else if(i <= max_index) { + // for instance case where we defined C without A or B + homing_info_t t; + t.axis= 'A' + i; + t.axis_index= i; + t.pin_info= nullptr; // this tells it that it cannot be used for homing + homing_axis.push_back(t); } }else{