DeanIsMe / SevSeg

Seven segment display controller library for Arduino
MIT License
331 stars 130 forks source link

Initialize with blank instead of zero #39

Closed DRSDavidSoft closed 6 years ago

DRSDavidSoft commented 6 years ago

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

https://github.com/DeanIsMe/SevSeg/blob/327fe023a47870cd7379b23ff14240fb0d466a7b/SevSeg.cpp#L211

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

DeanIsMe commented 6 years ago

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.