Skip to content

fix-MFS_INVERT_DIGIT_SELECT#24

Merged
hpsaturn merged 2 commits into
hpsaturn:masterfrom
marcosabcarvalho:support-black-button-clone-display
Jun 8, 2026
Merged

fix-MFS_INVERT_DIGIT_SELECT#24
hpsaturn merged 2 commits into
hpsaturn:masterfrom
marcosabcarvalho:support-black-button-clone-display

Conversation

@marcosabcarvalho

Copy link
Copy Markdown
Contributor

Pull Request: Add compatibility option for active-low digit select displays

Description

This PR adds a compatibility option for Multi Function Shield clones whose 4-digit display uses active-low digit select.

Some shield clones use the same 74HC595 display pins as the classic board:

DATA  = D8
CLOCK = D7
LATCH = D4

but their digit select lines are active LOW. With the current behavior, the display lights up but shows malformed characters instead of values such as 1234.

The classic display behavior is preserved by default. The new option can be enabled with:

#define MFS_INVERT_DIGIT_SELECT 1

For the original/classic behavior, keep:

#define MFS_INVERT_DIGIT_SELECT 0

This PR adds small helper functions to normalize the segment byte and the digit-select byte depending on the selected hardware profile:

normalizeSegmentValue(...)
normalizeDigitSelect(...)

For active-low digit select displays, the working digit values are:

digit 0 = 0xFE
digit 1 = 0xFD
digit 2 = 0xFB
digit 3 = 0xF7

This keeps the compatibility behavior isolated, documented, and does not require changes to the public API.

Additional changes

This PR also includes a small update to the Alarm_Clock example.

The previous example used the older initialization style:

#include <TimerOne.h>

Timer1.initialize();
MFS.initialize(&Timer1);

However, the current hpsaturn MultiFuncShield library exposes:

MFS.initialize();

and does not accept a TimerOne* parameter. The example was adjusted to remove the direct TimerOne dependency and use the current initialization style:

MFS.userInterrupt = clockISR;
MFS.initialize();

This avoids compilation errors such as:

no matching function for call to 'MultiFuncShield::initialize(TimerOne*)'

Documentation

This PR adds a new documentation file:

readme-fix-MFS_INVERT_DIGIT_SELECT-problem.md

The new README documents:

  • the active-low digit select compatibility issue;
  • the observed symptoms;
  • the tested pin mapping;
  • the working digit select values;
  • how to enable MFS_INVERT_DIGIT_SELECT;
  • a minimal test sketch for verification.

Related Issues

No related issue yet.

This PR is based on a hardware compatibility issue found while testing a Multi Function Shield clone with a 4-digit display driven by two 74HC595 shift registers.

Tests

I tested the change on an Arduino UNO with a Multi Function Shield clone using two 74HC595 shift registers.

The display pins were confirmed as:

DATA  = D8
CLOCK = D7
LATCH = D4

The display was tested manually and worked correctly with active-low digit select values:

0xFE, 0xFD, 0xFB, 0xF7

Display test sketch

#include <MultiFuncShield.h>

void setup() {
  MFS.initialize();
}

void loop() {
  MFS.write(1234);
  delay(1500);

  MFS.write(5678);
  delay(1500);

  MFS.write(8888);
  delay(1500);

  MFS.write(1111);
  delay(1500);

  MFS.write("Hi");
  delay(1500);

  MFS.write("End");
  delay(1500);
}

Expected and observed output:

1234
5678
8888
1111
Hi
End

Alarm Clock example test

The Alarm_Clock example was also checked with the current initialization style:

MFS.userInterrupt = clockISR;
MFS.initialize();

This avoids the previous TimerOne-based initialization error and keeps the example compatible with the current library API.

Suggested PR title

Add compatibility option for active-low digit select displays

Comment thread src/MultiFuncShield.cpp Outdated
Comment thread readme-FIX_MFS_INVERT_DIGIT_SELECT.md Outdated
@hpsaturn

hpsaturn commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Thanks for your PR. Please only resolve these only code review comments that I did to merge it.

@marcosabcarvalho

Copy link
Copy Markdown
Contributor Author

Done. I removed the separate README file and added a short note in the main README. I also kept the default value as 0 to preserve backward compatibility.

@hpsaturn hpsaturn merged commit 92a9b6b into hpsaturn:master Jun 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants