title: Convert and mask bits of little endian to big endian
body: <p>I am working on a Qt/C++ application. I want to show state of 3 hall sensors so I read it from  micro-controller this way:</p>
  
  <pre><code>uint8_t state = getState(whichMotor);
  int numChars = sprintf(sBuff, "%d", state);
  HAL_UART_Transmit_DMA(&amp;huart3, sBuff, numChars);
  </code></pre>
  
  <p>State can be any 1, 5, 4, 6, 2 or 3.</p>
  
  <p>Then in my Qt application I have 3 labels and want to show if corresponding bit is set in the number I receive from UART. I am sure I get the correct number, when I show it as integer its fine. But to break it down into 3 bits into three labels I fail as it just shows 1 1 1 or 0 0 0.</p>
  
  <p>Here is my code on PC:</p>
  
  <pre><code>const void MotorWidget::setHallState(const QString&amp; s)
  {
   int hallState = s.toInt();
   ui-&gt;lbValueHallC-&gt;setText(hallState &amp; 0b100 &gt; 0 ? "1" : "0");
   ui-&gt;lbValueHallB-&gt;setText(hallState &amp; 0b010 &gt; 0 ? "1" : "0");
   ui-&gt;lbValueHallA-&gt;setText(hallState &amp; 0b001 &gt; 0 ? "1" : "0");
  }
  </code></pre>
  
  <p>For example, if I receive <code>hallState</code> as 5, label C should show "1", label B should show "0" and label A should show "1"...but as I said I only get 111 or 000 regardless of what I receive.</p>
  
  <p>I suspect this might be big-endian little-endian thing...but I have no idea how to fix it</p>