Skip to content

Commit 6b193ff

Browse files
committed
Corrected device mode bug and library init bug.
Device mode has to be an unsigned char because upon first power up the EEPROM is 0xFF (-1 or 255). The 1" displays are common cathode but with the PNP/NPN configuration of OpenSegment, it actually inverts the signals so we need to use common anode to get the library to work.
1 parent 4d64de6 commit 6b193ff

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

firmware/Serial 7-Segment Display/Serial_7_Segment_Display_Firmware/Serial_7_Segment_Display_Firmware.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ SevSeg myDisplay; //Create an instance of the object
4040
//Global variables
4141
unsigned int analogValue6 = 0; //These are used in analog meter mode
4242
unsigned int analogValue7 = 0;
43-
char deviceMode; //This variable is useds to select which mode the device should be in
43+
unsigned char deviceMode; // This variable is useds to select which mode the device should be in
4444
unsigned char commandMode = 0; // Used to indicate if a commandMode byte has been received
4545

4646
// Struct for circular data buffer data received over UART, SPI and I2C are all sent into a single buffer
@@ -78,13 +78,11 @@ void setup()
7878

7979
interrupts(); // Turn interrupts on, and les' go
8080

81-
//Preload the display buffer, should only be used during code development
81+
//Preload the display buffer with a default
8282
display.digits[0] = 1;
8383
display.digits[1] = 2;
8484
display.digits[2] = 3;
8585
display.digits[3] = 4;
86-
87-
myDisplay.SetBrightness(100); //Set the display to 100% bright
8886
}
8987

9088
// The display is constantly PWM'd in the loop()

firmware/Serial 7-Segment Display/Serial_7_Segment_Display_Firmware/System_Functions.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ void setupDisplay()
126126

127127
int numberOfDigits = 4; //Do you have a 2 or 4 digit display?
128128

129-
int displayType = COMMON_CATHODE; //SparkFun 1" displays are common cathode
129+
//The 1" SparkFun displays are common cathode but because of the PNP and NPN
130+
//transistor configuration we are using, we need inverted signals:
131+
//1 to turn a digit on, 0 to turn a segment on
132+
//This is the same as a common anode setup.
133+
int displayType = COMMON_ANODE;
130134

131135
//Initialize the SevSeg library with all the pins needed for this type of display
132136
myDisplay.Begin(displayType, numberOfDigits,

0 commit comments

Comments
 (0)