DeanIsMe/SevSeg

Initialize with blank instead of zero

DRSDavidSoft opened this issue · 1 comments

Description of the issue

When the SevSeg object is instantiated, the Seven Segment displays a 0. for a split second before the arduino program sets the desired characters within the loop. This happens because of the line defined in:

void SevSeg::begin

setNewNum(0, 0); // Initialise the number displayed to 0

Preview

sevseg

In order to test this out, I wrote the following:

	// Specify the configuration for my display.
	byte numDigits = 4;
	byte hardwareConfig = COMMON_ANODE; 
	bool resistorsOnSegments = true;

	bool updateWithDelays = false;
	bool leadingZeros = false;

	byte digitPins[] = {DIGIT_1, DIGIT_2, DIGIT_3, DIGIT_4};
	byte segmentPins[] = { A, B, C, D, E, F, G, DP }

	// Set a sample message that I'd like to display, instead of "0."
	sevseg.setChars("boot");

	// ↓ Where the problem occurs:
	sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins,
		resistorsOnSegments, updateWithDelays, leadingZeros);

	sevseg.setBrightness(50);

	// Keep the last set `digitCodes` by `begin()` and display them.
	while(true) {
		sevseg.refreshDisplay(); 
	}

Request

Now, I can use call sevseg.setChars("boot"); immediately after sevseg.begin(), but this doesn't fix the split-second issue. I'd like to prevent displaying the 0. altogether.

Possible solutions

  • a. SevSeg should not use setNewNum(0, 0); in the begin() at all; it should use blank() instead.
  • b. SevSeg::begin() adds a new argument, e.g.: startingChars, or blankOnInit to specify whether it should display zeros at first, or blank the screen.
  • c. Rewrite the logic to set the working mode, if it's number-only, or mixed mode.

That's a good suggestion - blank is more appropriate. I think that when that line was written, the library actually didn't support characters and didn't even have a blank function.
Changed in the most recent commit.