2022-07-19 07:34 AM
2022-08-18 11:54 PM
Welcome, @SRehm.2, to the community!
We're sorry that the answer took a little while to come:
The condition mentioned is called a ternary operator, not specific to Arduino, which is based on C++, but also available in C. If you wanted to use this for the assignment to a variable, you can use it exactly like this.
Does it answer your question?
Regards
/Peter
2022-08-18 11:54 PM
Welcome, @SRehm.2, to the community!
We're sorry that the answer took a little while to come:
The condition mentioned is called a ternary operator, not specific to Arduino, which is based on C++, but also available in C. If you wanted to use this for the assignment to a variable, you can use it exactly like this.
Does it answer your question?
Regards
/Peter
2022-10-04 06:54 PM
That code is written by someone, who doesn't know the C/C++ languages, because the following code does exactly the same:
(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_10) == GPIO_PIN_SET);
But it's safer and more efficient to convert it to this:
(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_10) != GPIO_PIN_RESET);