DCC-EX / dcc-ex.github.io

The DCC-EX website, written in reStructuredText, generated using sphinx, and served by GitHub pages.
https://dcc-ex.com
GNU General Public License v3.0
12 stars 32 forks source link

[Documentation Update]: Capture Chris' dirty tricks #595

Open peteGSX opened 1 year ago

peteGSX commented 1 year ago

Documentation details

For example: ... Move the CLEVER calls list to myClever.h:

CLEVER(TRN1, SNS1_TRN1, RI_1_TRN1)       // Turnout, Button, route_ind
CLEVER(TRN2, SNS2_TRN2, RI_2_TRN2)       // Turnout, Button, route_ind

Change the CLEVER macro definition to do this:

// First pass, create the button watching loop
#define CLEVER(turnout, button, route_ind) \
    IF(button) \
       IFCLOSED(turnout) THROW(turnout) ENDIF \
    ELSE \
      IF(-button) IFTHROWN(turnout) CLOSE(turnout) ENDIF \
    ENDIF

AUTOSTART SEQUENCE(1) 
#include "myClever.h"
FOLLOW(1)
#undef CLEVER

// Now replace the clever macro so it creates the ON handlers 
#define CLEVER(turnout, button, route_ind) \
      ONTHROW(turnout) SET(route_ind) DONE \
      ONCLOSE(turnout) RESET(route_ind) DONE

// Pass 2 create the ON handlers 
#include "myClever.h"

This sneaky and dirty trick (including the same list more than once with different macro definitions) is exactly how EXRAIL works its magic for all its commands.

Page with issues

No response

SweaterMichael commented 4 months ago

So, for us non-geniuses, where does the later part of this code fit into DCC-EX?