1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-29 17:19:50 +02:00

Merge pull request #53 from gflaser-au/ctrl_inputs

Allow Ctrl inputs to be disabled
This commit is contained in:
bdring
2018-11-15 09:00:31 -06:00
committed by GitHub

View File

@@ -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