Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing direction of bit significance seemed to be some kind of "buggy" #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions arduino-code/ICMIMax7219.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
19 changes: 10 additions & 9 deletions arduino-code/ICMIMax7219.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down