-
Notifications
You must be signed in to change notification settings - Fork 2k
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
drivers/digit7seg: add 4-digit 7-segment display driver #20981
base: master
Are you sure you want to change the base?
Conversation
Hi @Enoch247, I’ve finished my PR! I'm sure it can be improved, especially the sha5461as_display function. Could you please review it when you have a moment? |
Thanks for the contribution. I'll try to review this tonight. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the level of abstraction provided by the driver is too low. I expected to be able to pass it a number or array of digits to display. Currently the driver requires applications to manually set a bitfield with each bit corresponding to the display's segments. The application must also know the mapping of the bits to segments.
597003f
to
9050c76
Compare
Thank you for reviewing my PR. |
9050c76
to
005250f
Compare
It is not my preference, but if you have a reason to do it this way, can you please describe it so that I better understand. |
BTW, in the future, please hold off to squash/force push until requested once a PR is submitted. It makes the process a bit easier. See here for some helpful tips. |
Great work adding the documentation for the driver! Its not always the fun part of writing code, but it will really help users of your driver in the future. |
61d694f
to
50d790a
Compare
Add to force push cause the fixup commit message was more than 50 char. |
drivers/digit7seg: add return value doc in header and remove unused params in digit7seg_t drivers/digit7seg: add return value doc in header drivers/digit7seg: add return value doc in header
50d790a
to
37ceefb
Compare
The PR is ready for review! :D |
Thanks. Sorry for the delay. I will set aside some time this weekend to look it over, if not sooner. |
As state before, I think that there needs to be a way for applications to send numbers to the display. As far as I see, the driver's API allows to manually set the display's segments, but that is the exception rather than the normal way an application would want to interact with a numeric display driver. Something like: int digit7seg_set(digit7seg_t *dev, int val, int scale);
int digit7seg_set_digit(digit7seg_t *dev, unsigned digit, unsigned val);
|
OK, I'll do it as soon as I can! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this! Some first comments from my side below.
/** | ||
* @ingroup drivers_digit7seg | ||
* @file | ||
* @brief Device driver for less than 5 digits of 7 segments without IC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @brief Device driver for less than 5 digits of 7 segments without IC | |
* @brief Device driver for up to 4 digits of 7 segments without IC |
do we really want such restriction?
* @param[in] value the value as an uint8_t, a is equal to the first bit | ||
* b the second.... dp the 8th bit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a user, I would expect the driver to do the number to 7-segment-bit conversion for me.
* b the second.... dp the 8th bit. | ||
* | ||
* @return 0 on success | ||
* @return -1 when an incorrect digit is passed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return -1 when an incorrect digit is passed | |
* @return -1 when an invalid index is passed |
?
|
||
## About | ||
|
||
This driver was developed to works with [5461AS](http://www.topliteusa.com/uploadfile/2014/0825/A-5461AS.pdf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This driver was developed to works with [5461AS](http://www.topliteusa.com/uploadfile/2014/0825/A-5461AS.pdf) | |
This driver was developed to work with [5461AS](http://www.topliteusa.com/uploadfile/2014/0825/A-5461AS.pdf) |
## About | ||
|
||
This driver was developed to works with [5461AS](http://www.topliteusa.com/uploadfile/2014/0825/A-5461AS.pdf) | ||
in a way that all 4 digits (and less) with 7 segments without integrated controller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in a way that all 4 digits (and less) with 7 segments without integrated controller | |
in a way that up to 4 digits with 7 segments without integrated controller |
|
||
static void _shift_display(void *arg, int chan) | ||
{ | ||
(void)chan; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why having the variable in this private function if it is unused?
uint32_t temp_value = value << (index * BYTE_BITS); | ||
uint32_t up_value = dev->value >> ((index + 1) * BYTE_BITS); | ||
up_value <<= ((index + 1) * BYTE_BITS); | ||
uint32_t down_value = ((0b00000001 << (index * BYTE_BITS)) - 1) & dev->value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's worth adding some explaining comments to what this code does.
|
||
#define DIGIT7SEG_MAX_DIGITS (4) /**< Max pin number, can be below or equal */ | ||
#ifndef DIGIT7SEG_TIMER_HZ | ||
# define DIGIT7SEG_TIMER_HZ MHZ(1) /**< default timer hz */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# define DIGIT7SEG_TIMER_HZ MHZ(1) /**< default timer hz */ | |
# define DIGIT7SEG_TIMER_HZ MHZ(1) /**< default timer hz */ |
as per the Coding Convention. please also check other places
#ifndef DIGIT7SEG_TIMER_HZ | ||
# define DIGIT7SEG_TIMER_HZ MHZ(1) /**< default timer hz */ | ||
#endif | ||
#ifndef DIGIT7SEG_DELAY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to prefix all those "over-writeable" parameters with CONFIG_
.
This driver was developed to works with [5461AS](http://www.topliteusa.com/uploadfile/2014/0825/A-5461AS.pdf) | ||
in a way that all 4 digits (and less) with 7 segments without integrated controller | ||
can be controlled into [RIOT-OS](https://github.com/RIOT-OS/RIOT). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is worth mentioning one free HW timer as a prerequisites for using this driver here.
Contribution description
Added riot/drivers/sha5461as to control a 4-digit 7-segment display (plus decimal point).Testing procedure
A test is available in tests/drivers/sha5461as, designed for the Arduino Nano 33 BLE. The test will display "8" segment by segment on each digit, followed by "RIOT," and then it will stop.Issues/PRs references