Skip to content
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
12 changes: 12 additions & 0 deletions src/LedControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ void LedControl::setChar(int addr, int digit, char value, boolean dp) {
spiTransfer(addr, digit+1,v);
}

void LedControl::setByte(int addr, int digit, byte value, boolean dp) {
int offset;
byte index,v;

offset=addr*8;
v = value;
if(dp)
v|=B10000000;
status[offset+digit]=v;
spiTransfer(addr, digit+1,v);
}

void LedControl::spiTransfer(int addr, volatile byte opcode, volatile byte data) {
//Create an array with the data to shift out
int offset=addr*2;
Expand Down
24 changes: 24 additions & 0 deletions src/LedControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,30 @@ class LedControl {
* dp sets the decimal point.
*/
void setChar(int addr, int digit, char value, boolean dp);

/*
* Display a specified byte on a 7-Segment Display.
* Specify a byte in the format: B_______
* where the blanks are either 1's or 0's corresponding to the on-off state of each of the segments A-G.
*
* Diagram of the 7-segments:
* --A--
* | |
* F B
* | |
* --G--
* | |
* E C
* | |
* --D--
*
* Params:
* addr address of the display
* digit the position of the digit on the display (0..7)
* value the value to be displayed, with each bit corresponding to a segment A-G
* dp sets the decimal point.
*/
void setByte(int addr, int digit, byte value, boolean dp);
};

#endif //LedControl.h
Expand Down