#define PSWITCH_TMAIN 38 #define PSWITCH_TSLOW 7 #define PSWITCH_SPOWER 1 #define PSWITCH(tPort, tVar, tSub) int tVar; \ void tSub () { pswitch_change(tPort, tVar); } void pswitch_change (const int port, int & state_var) { SetPower(port, OUT_FULL); if (state_var) { SetDirection(port, OUT_FWD); } else { SetDirection(port, OUT_REV); } On(port); Wait(PSWITCH_TMAIN); SetPower(port, PSWITCH_SPOWER); Wait(PSWITCH_TSLOW); Off(port); if (state_var) state_var = 0; else state_var = 1; }