Unverified Commit 3883e49b authored by Alexander Entinger's avatar Alexander Entinger Committed by GitHub

Merge pull request #82 from luco5826/master

Minor optimization in shiftOut function
parents ffeca151 4d074e8a
...@@ -42,10 +42,13 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) ...@@ -42,10 +42,13 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
uint8_t i; uint8_t i;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if (bitOrder == LSBFIRST) if (bitOrder == LSBFIRST) {
digitalWrite(dataPin, !!(val & (1 << i))); digitalWrite(dataPin, val & 1);
else val >>= 1;
digitalWrite(dataPin, !!(val & (1 << (7 - i)))); } else {
digitalWrite(dataPin, (val & 128) != 0);
val <<= 1;
}
digitalWrite(clockPin, HIGH); digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW); digitalWrite(clockPin, LOW);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment