Thank you for the quick reply. That sounds like it would require me to understand your C++ code and write new code, is that correct? It looks very complex.
It's not really complex for a programmer. If you aren't one it is in deed not as easy. It is more or less just adding a "case 456:"..."break;" to the M code list in commands.cpp and add what you want to do. You find lots of samples, e.g. READ(77); reads pin 77 state. Of cours eit must be f´defined as input before.
It's not really complex for a programmer. If you aren't one it is in deed not as easy. It is more or less just adding a "case 456:"..."break;" to the M code list in commands.cpp and add what you want to do. You find lots of samples, e.g. READ(77); reads pin 77 state. Of cours eit must be f´defined as input before.
What do you want to achieve with this?
I am executing different GCODE programs based on four external switch inputs. I am serving the GCODE with a simple custom python server. I want to read the state of the switches using the Arduino Mega2560 as opposed to adding additional hardware to the system to read the switches.
In order to keep the required code modifications limited to one location in the code, and since this was strictly for a temporary setup, I wrote the new case this way. A bit clumsy and redundant, but straightforward. Also, my way has the drawback of being Arduino-specific.
Comments
It is more or less just adding a "case 456:"..."break;" to the M code list in commands.cpp and add what you want to do. You find lots of samples, e.g. READ(77); reads pin 77 state. Of cours eit must be f´defined as input before.
What do you want to achieve with this?
SET_INPUT(pinNumber);
then you can read them with READ(pinNumber) and buid a number 0-15 from the 4 bits.
case 130: // M130
Com::println();
or you get problems with host software because you are not finishing the line and that can lead to issues.
Also Commands::waitUntilEndOfAllMoves(); means it waits for moves to stop, so you should not use it during a print.
should be inside Printer::setup where all hardware gets initialized.
Apart from this it would work.