Quick question - what does this code do?

While going through the Adafruit ILI9341 library saw this line:
for(uint8_t bit = 0x80; bit; bit >>= 1){
I'm wondering, does it really means that every iteration of the 'for' loop contents of 'bit' variable is shifted right y one position?
And what is the end condition of this loop - 'bit' is left there by itself not equal to anything..
Thank you.

When you wrote a small test sketch which then printed 'bit' to the serial monitor, what was printed?

for(uint8_t bit = 0x80; bit; bit >>= 1)


'bit' is left there by itself not equal to anything.

The contents of a byte variable are ALWAYS equal to some value between and including 0 and 255.

Yes, that is indeed what happens if to run the code:
for (uint8_t bit = 0x80; bit; bit >>= 1) {
Serial.println(bit, BIN);

1 'traveled' to the right as the loop run.
(leading zeros were omitted in serial monitor)

But it still do not see why the loop stops once 1 reached the right side..

"bit" is an expression in C/C++ that returns the value of the variable bit.

When that value is zero, the loop terminates.

Sort of got it :smiley:
Thank you))

You could use these values to mask off bits in a variable to see if they are set or reset.