Been looking at a line of code from a freak from the past that I am having an issue with understanding.
uint8_t button_scan; uint8_t buttons = 0; uint8_t butos = 0; uint8_t last_buttons = 0; . . buttons = ((button_scan & 0x04) == 0); //<----this is bugging me butos = buttons && !last_buttons; last_buttons = buttons; . . . .
button_scan is loaded with a value in an ISR...Thats all well and good, and when the code hits the line above is where I am getting hung up over what is exactly going on. It seems that 'buttons' equals the bitwise AND of button_scan with 0x04 (0x04 isolates the bit to test), thats all and well, but I cannot understand what the '== 0' is all about.
I am guessing that this:
((button_scan & 0x04) == 0)
is the same as:
if((button_scan & 0x04) == 0)
which means that if button_scan and 0x04 == 0,..... buttons = 1.