From 3af0de91c1a87336bee2988dd1d04a1843505e5b Mon Sep 17 00:00:00 2001 From: Christian Kuetbach Date: Fri, 2 Jan 2015 14:59:13 +0100 Subject: [PATCH] changing direction of bit significance seemed to be some kind of "buggy". --- arduino-code/ICMIMax7219.cpp | 16 +++++++++------- arduino-code/ICMIMax7219.h | 19 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/arduino-code/ICMIMax7219.cpp b/arduino-code/ICMIMax7219.cpp index 81518aa..4eaa30b 100644 --- a/arduino-code/ICMIMax7219.cpp +++ b/arduino-code/ICMIMax7219.cpp @@ -174,14 +174,16 @@ void ICMIMax7219::setDigitRaw(uint8_t which, uint8_t value) { if (which >= 0 && which < this->digitCount) { - // Apply the bit translation to the value + // Apply the bit translation to the value uint8_t translatedValue = value; - bitWrite(translatedValue, 6, bitRead(value, 0)); - bitWrite(translatedValue, 5, bitRead(value, 1)); - bitWrite(translatedValue, 4, bitRead(value, 2)); - bitWrite(translatedValue, 2, bitRead(value, 4)); - bitWrite(translatedValue, 1, bitRead(value, 5)); - bitWrite(translatedValue, 0, bitRead(value, 6)); + bitWrite(translatedValue, 7, bitRead(value, 0)); + bitWrite(translatedValue, 6, bitRead(value, 1)); + bitWrite(translatedValue, 5, bitRead(value, 2)); + bitWrite(translatedValue, 4, bitRead(value, 3)); + bitWrite(translatedValue, 3, bitRead(value, 4)); + bitWrite(translatedValue, 2, bitRead(value, 5)); + bitWrite(translatedValue, 1, bitRead(value, 6)); + bitWrite(translatedValue, 0, bitRead(value, 7)); // register parameter is between 0 and 7, register address is simply +1 writeRegister(which + 1, translatedValue); } diff --git a/arduino-code/ICMIMax7219.h b/arduino-code/ICMIMax7219.h index d3a90dd..fea5d14 100644 --- a/arduino-code/ICMIMax7219.h +++ b/arduino-code/ICMIMax7219.h @@ -99,6 +99,7 @@ class ICMIMax7219 */ void enable(boolean enable); + /** * Sets the register content of the designated digit/row to the specified value. * Each of the eight bits in value represents a single segment/column of the @@ -112,18 +113,18 @@ class ICMIMax7219 * * bit In | bit sent | semgent * -------+----------+--------- - * 0 | 6 | A - * 1 | 5 | B - * 2 | 4 | C - * 3 | 3 | D - * 4 | 2 | E - * 5 | 1 | F - * 6 | 0 | G - * 7 | 7 | DP + * 0 | 7 | A + * 1 | 6 | B + * 2 | 5 | C + * 3 | 4 | D + * 4 | 3 | E + * 5 | 2 | F + * 6 | 1 | G + * 7 | 0 | DP * * Example: the value to display a 5 on the display (segments A, F, G, C, D) would be * B01101101. This is the value passed to this method. The translated value - * sent to the IC would be B01011011. + * sent to the IC would be B10110110. * * @param which the index of the digit/row to configure. The value must be * between 0 and the value of digitCount (given in the constructor)