MCPcopy Create free account
hub / github.com/bdring/FluidNC / gc_wait_on_input

Function gc_wait_on_input

FluidNC/src/GCode.cpp:2047–2082  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2045overloaded(Ts...) -> overloaded<Ts...>;
2046
2047static Error gc_wait_on_input(bool is_digital, objnum_t input_number, WaitOnInputMode mode, float timeout) {
2048 // TODO - only Immediate read mode is supported
2049 if (mode == WaitOnInputMode::Immediate) {
2050 float result;
2051 if (is_digital) {
2052 if (input_number >= MaxUserDigitalPin) {
2053 return Error::PParamMaxExceeded;
2054 }
2055 auto& pin = config->_userInputs->digitalInput[input_number];
2056 if (pin.undefined()) {
2057 log_error(pin.legend() << " is not defined");
2058 return Error::PParamMaxExceeded;
2059 }
2060 result = (float)pin.get();
2061 set_numbered_param(5399, result);
2062 log_debug("M66: " << pin.legend() << " result=" << result);
2063 } else {
2064 if (input_number >= MaxUserAnalogPin) {
2065 return Error::PParamMaxExceeded;
2066 }
2067 auto& pin = config->_userInputs->analogInput[input_number];
2068 if (pin.undefined()) {
2069 log_error(pin.legend() << " is not defined");
2070 return Error::PParamMaxExceeded;
2071 }
2072 result = (float)pin.get();
2073 set_numbered_param(5399, result);
2074 log_debug("M66: " << pin.legend() << " result=" << result);
2075 }
2076
2077 return Error::Ok;
2078 }
2079
2080 // TODO - implement rest of modes
2081 return Error::GcodeValueWordInvalid;
2082}

Callers 1

gc_execute_lineFunction · 0.85

Calls 4

set_numbered_paramFunction · 0.85
undefinedMethod · 0.80
legendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected