Skip to content

drivers/tm1637: add driver and tests for tm1637 7-segment display #21112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 25, 2025

Conversation

N11cc00
Copy link
Contributor

@N11cc00 N11cc00 commented Dec 27, 2024

Contribution description

This is a 4 digit display driver for the TM1637 7-segment display. It can display base 10 integers on a range from 9999 to -999, with or without leading zeros and variable brightness. The display can be cleared, too.

The driver was implemented according to a subset of all functionality and adheres to the specification .

Testing procedure

A test can be found in tests/drivers/tm1637/. The test covers all possible configurations for the driver and contains default pin configuration in tm1637_params.h.

Issues/PRs references

A similar display driver is still in review at PR #20981, but isn't compatible with this 4 pin display.

Images

20241227_184429

@github-actions github-actions bot added Area: doc Area: Documentation Area: tests Area: tests and testing framework Area: drivers Area: Device drivers labels Dec 27, 2024
Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, this looks quite good to me.

The CI has a few comments (check in the code view here):

  • One line is longer than 100 chars, please add a line break
  • A few files have no terminating newline. (Btw: What editor are you using? Maybe we can add a config to our repo that your editor will pick up. IMO it is better to automate such tedious style things and concentrate.)

Btw: I think negative numbers and leading zeros will result in the minus sign to be overwritten by a zero, or did I read the code incorrectly?

Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, great code quality! I have mostly nits below.

You've rightfully already mentioned #20981. IIRC, the idea was there to provide a unified driver for different kinds of 7-segment displays. How does yours differ and could it be integrated somehow? Otherwise, we should rename the driver in the other PR back to something more specific.

@mguetschow mguetschow added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 3, 2025
@riot-ci
Copy link

riot-ci commented Jan 3, 2025

Murdock results

✔️ PASSED

c274204 drivers/tm1637: tests for the tm1637 7-segment display

Success Failures Total Runtime
10287 0 10287 44m:13s

Artifacts

Copy link
Contributor

@Enoch247 Enoch247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly reviewed the API only so far. I had a few suggestions that I noted. Thank you for the great contribution!

/**
* @brief see @ref tm1637_params_t
*/
#define TM1637_PARAM_CLK GPIO_PIN(0, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest setting the default to GPIO_UNDEF. Then add an assert to the init function to check that the pins are defined. There is no sane default you could ever define. Better to fail loudly then quietly do the wrong thing.

Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost ready I'd say. If you bring the hardware one of those days I can test locally and confirm its working :)

/**
* @brief Delay between bits in milliseconds
*/
#define BIT_TIME_MS 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any maximum times? If not, then I'd say leave as is.

@mguetschow
Copy link
Contributor

LGTM now, thanks for bearing with us and thanks for your contribution! @Enoch247 do you want to have a second look?

@mguetschow
Copy link
Contributor

Oh, and please squash the commits together with git rebase -i master and rename the commit (and the PR) according to RIOT's Contributing Guide .

@Enoch247
Copy link
Contributor

I don't currently have the time to do a full review, but it looks like all my previous concerns have been addressed.

@N11cc00 N11cc00 changed the title TM1637 7-segment display driver drivers/tm1637: add driver and tests for tm1637 7-segment display Feb 27, 2025
@N11cc00 N11cc00 force-pushed the tm1637 branch 3 times, most recently from 9264efb to 5c78bb7 Compare March 5, 2025 12:04
Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and tested locally to work as expected. Please squash and rename the commits to follow the convention.

@mguetschow mguetschow added this pull request to the merge queue Mar 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 20, 2025
@mguetschow mguetschow added this pull request to the merge queue Mar 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 21, 2025
@mguetschow mguetschow added CI: full build disable CI build filter CI: no fast fail don't abort PR build after first error CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: full build disable CI build filter CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 21, 2025
@mguetschow
Copy link
Contributor

mguetschow commented Mar 21, 2025

Please add a Makefile.ci with the following content to tests/drivers/tm1637:

BOARD_INSUFFICIENT_MEMORY := \
    atmega8 \
    #

(your test doesn't fit there as the CI reports)

@mguetschow mguetschow added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: full build disable CI build filter labels Mar 25, 2025
@mguetschow mguetschow enabled auto-merge March 25, 2025 13:04
@mguetschow mguetschow added this pull request to the merge queue Mar 25, 2025
Merged via the queue into RIOT-OS:master with commit d2fbe23 Mar 25, 2025
28 checks passed
@mguetschow mguetschow added this to the Release 2025.04 milestone Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: doc Area: Documentation Area: drivers Area: Device drivers Area: tests Area: tests and testing framework CI: no fast fail don't abort PR build after first error CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants