From e2c55c5d77315bc8be8f2f7be9bc9a0c74e986a7 Mon Sep 17 00:00:00 2001 From: gflaser-au <43978849+gflaser-au@users.noreply.github.com> Date: Sun, 11 Nov 2018 23:23:01 +1000 Subject: [PATCH 1/2] Control pins can now be individually disabled --- Grbl_Esp32/system.cpp | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/Grbl_Esp32/system.cpp b/Grbl_Esp32/system.cpp index e29a9e0f..2328732c 100644 --- a/Grbl_Esp32/system.cpp +++ b/Grbl_Esp32/system.cpp @@ -1,6 +1,6 @@ /* system.cpp - Header for system level commands and real-time processes - Part of Grbl + art of Grbl Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC 2018 - Bart Dring This file was modified for use on the ESP32 @@ -24,16 +24,23 @@ void system_ini() // Renamed from system_init() due to conflict with esp32 files { // setup control inputs +#ifdef CONTROL_SAFETY_DOOR_PIN pinMode(CONTROL_SAFETY_DOOR_PIN, INPUT); - pinMode(CONTROL_RESET_PIN, INPUT); - pinMode(CONTROL_FEED_HOLD_PIN, INPUT); - pinMode(CONTROL_CYCLE_START_PIN, INPUT); + attachInterrupt(digitalPinToInterrupt(CONTROL_SAFETY_DOOR_PIN), isr_control_inputs, CHANGE); +#endif +#ifdef CONTROL_RESET_PIN + pinMode(CONTROL_RESET_PIN, INPUT); + attachInterrupt(digitalPinToInterrupt(CONTROL_RESET_PIN), isr_control_inputs, CHANGE); +#endif +#ifdef CONTROL_FEED_HOLD_PIN + pinMode(CONTROL_FEED_HOLD_PIN, INPUT); + attachInterrupt(digitalPinToInterrupt(CONTROL_FEED_HOLD_PIN), isr_control_inputs, CHANGE); +#endif +#ifdef CONTROL_CYCLE_START_PIN + pinMode(CONTROL_CYCLE_START_PIN, INPUT); + attachInterrupt(digitalPinToInterrupt(CONTROL_CYCLE_START_PIN), isr_control_inputs, CHANGE); +#endif - // attach interrupt to them - attachInterrupt(digitalPinToInterrupt(CONTROL_SAFETY_DOOR_PIN), isr_control_inputs, CHANGE); - attachInterrupt(digitalPinToInterrupt(CONTROL_RESET_PIN), isr_control_inputs, CHANGE); - attachInterrupt(digitalPinToInterrupt(CONTROL_FEED_HOLD_PIN), isr_control_inputs, CHANGE); - attachInterrupt(digitalPinToInterrupt(CONTROL_CYCLE_START_PIN), isr_control_inputs, CHANGE); } void IRAM_ATTR isr_control_inputs() @@ -421,12 +428,19 @@ uint8_t system_control_get_state() #endif - uint8_t control_state = 0; + uint8_t control_state = 0; +#ifdef CONTROL_SAFETY_DOOR_PIN if (digitalRead(CONTROL_SAFETY_DOOR_PIN)) { control_state |= CONTROL_PIN_INDEX_SAFETY_DOOR; } +#endif +#ifdef CONTROL_RESET_PIN if (digitalRead(CONTROL_RESET_PIN)) { control_state |= CONTROL_PIN_INDEX_RESET; } +#endif +#ifdef CONTROL_FEED_HOLD_PIN if (digitalRead(CONTROL_FEED_HOLD_PIN)) { control_state |= CONTROL_PIN_INDEX_FEED_HOLD; } +#endif +#ifdef CONTROL_CYCLE_START_PIN if (digitalRead(CONTROL_CYCLE_START_PIN)) { control_state |= CONTROL_PIN_INDEX_CYCLE_START; } - +#endif #ifdef INVERT_CONTROL_PIN_MASK control_state ^= INVERT_CONTROL_PIN_MASK; #endif From 8ad102d109de388702269d2275423e56f9114d5d Mon Sep 17 00:00:00 2001 From: gflaser-au <43978849+gflaser-au@users.noreply.github.com> Date: Sun, 11 Nov 2018 23:28:41 +1000 Subject: [PATCH 2/2] fixed header comment - accidental deletion --- Grbl_Esp32/system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Grbl_Esp32/system.cpp b/Grbl_Esp32/system.cpp index 2328732c..7785e590 100644 --- a/Grbl_Esp32/system.cpp +++ b/Grbl_Esp32/system.cpp @@ -1,6 +1,6 @@ /* system.cpp - Header for system level commands and real-time processes - art of Grbl + Part of Grbl Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC 2018 - Bart Dring This file was modified for use on the ESP32