Usage Examples
(state ? true : false) //1:0
#define USART_DIR_TX(state) (state ? ([true]) : ([false]))
#define OUTPUT_PIN(state) (state ? (LATAbis.LATA1 = 1) : (LATAbis.LATA1 = 0)) //1:0
bytesThisSector = (bytesLeftToWrite > 512) ? 512 : bytesLeftToWrite;
#define LED_OUTPUT_ON(state) (state ? (rs485_leds_output |= 0x01) : (rs485_leds_output &= ~0x01))
Multiple actions within a ternary operator
You comma seperate them:
#define IO_BUTTONS_COL_1(state) (state ? (TRISBbits.TRISB1 = 1) : (TRISBbits.TRISB1 = 0, LATBbits.LATB1 = 0))
