Wallacoloo / printipi

3d printing directly through the Raspberry Pi's GPIO pins
MIT License
141 stars 43 forks source link

Implement M119: Get Endstop Status #72

Open Wallacoloo opened 9 years ago

Wallacoloo commented 9 years ago

J.S. sent me the following code for his M119 implementation (in state.h):

} else if (cmd.isM119()) { //output endstop status
        LOGW("Warning (state.h): OP_M119 (output endstop status) not implemented\n");
        std::string msgTRIGGERED = "TRIGGERED";
        std::string msgOPEN = "open";
        return gparse::Response(gparse::ResponseOk,
            "Reporting endstop status x_min:" + ((driver.endstopHit(0) == true ) ? msgTRIGGERED : msgOPEN ) +
            " y_min:" + ((driver.endstopHit(1) == true ) ? msgTRIGGERED : msgOPEN ) +
            " z_min:" + ((driver.endstopHit(2) == true ) ? msgTRIGGERED : msgOPEN )  );

It shouldn't be too difficult to get this to compile with the current devel version / machines.

Wallacoloo commented 9 years ago

Implemented, but the endstops have no labels. So it returns, e.g., Ok triggered open triggered (I lowercased TRIGGERED for compatibility with Teacup).

There are a few ways to fix this:

  1. Add a std::string field to the Endstop object to create a label for it upon instantiation.
  2. Require that endstops are only owned by the CoordMap & query the CoordMap for both the endstop objects and names.

(1) has the downside of being less inline-able. (2) makes implementation slightly easier.

I'll probably go with (1) because putting the Endstops in the ioDrivers tuple is more consistent with the rest of Printipi, although that paradigm might eventually change.