From 9ff2f4bc387361650b819a2c55649682cad9b827 Mon Sep 17 00:00:00 2001 From: bdring Date: Sun, 28 Feb 2021 08:54:00 -0600 Subject: [PATCH] See which switch caused the hard limit - Used for debugging - Set Message/Level=Debug to activate looks like this... [MSG:Pn:X] ALARM:1 --- Grbl_Esp32/src/Limits.cpp | 5 +++++ Grbl_Esp32/src/Report.cpp | 10 ++++++++++ Grbl_Esp32/src/Report.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/Grbl_Esp32/src/Limits.cpp b/Grbl_Esp32/src/Limits.cpp index 41596e9d..bed2007a 100644 --- a/Grbl_Esp32/src/Limits.cpp +++ b/Grbl_Esp32/src/Limits.cpp @@ -52,6 +52,11 @@ void IRAM_ATTR isr_limit_switches() { int evt; xQueueSendFromISR(limit_sw_queue, &evt, NULL); #else + // Debugging...Show what axis triggered the ISR + if (static_cast(message_level->get()) == MsgLevel::Debug) { + grbl_msg_sendf(CLIENT_ALL, MsgLevel::Debug, "Pn:%s", maskToString(limits_get_state())); + } + # ifdef HARD_LIMIT_FORCE_STATE_CHECK // Check limit pin state. if (limits_get_state()) { diff --git a/Grbl_Esp32/src/Report.cpp b/Grbl_Esp32/src/Report.cpp index 892230e8..e9f2a6d5 100644 --- a/Grbl_Esp32/src/Report.cpp +++ b/Grbl_Esp32/src/Report.cpp @@ -956,4 +956,14 @@ void reportTaskStackSize(UBaseType_t& saved) { #endif } +String maskToString(uint32_t mask) { + String str = ""; + for (int i = 0; i < MAX_N_AXIS; i++) { + if (mask & bit(i)) { + str += "XYZABC"[i]; + } + } + return str; +} + void __attribute__((weak)) forward_kinematics(float* position) {} // This version does nothing. Make your own to do something with it diff --git a/Grbl_Esp32/src/Report.h b/Grbl_Esp32/src/Report.h index 2ffcecee..eac4aaa0 100644 --- a/Grbl_Esp32/src/Report.h +++ b/Grbl_Esp32/src/Report.h @@ -129,3 +129,5 @@ char* reportAxisNameMsg(uint8_t axis); char* reportAxisNameMsg(uint8_t axis, uint8_t dual_axis); void reportTaskStackSize(UBaseType_t& saved); + +String maskToString(uint32_t mask);