-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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: auxdisplay: Add driver for common 7-segment display #68501
base: main
Are you sure you want to change the base?
Conversation
68be124
to
682a00d
Compare
struct auxdisplay_gpio_7seg_data *data = dev->data; | ||
uint32_t ib, ic; | ||
|
||
for (ib = 0, ic = 0; ib < cfg->digit_count && ic < len; 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.
For the other drivers, this always writes from the last position, whilst for a 7-segment display you might want (or expect) that, it deviates from the API:
* @brief Write data to auxiliary display screen at current position
What are your thoughts on adding position get/set and having write update the current character and advancing the position (also thinking this can be used on hex segment displays also)?
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 is actually a consideration for handling decimal points. For example, if you want to display 10.3
, the decimal point is the third character in the data. However, on a 7-segment display, it is part of the second digit (0
). Therefore, I need to do some processing in the write
function, so that when the current character is identified as '.'
, the decimal point of the previous digit is lit.
return -ENODEV; | ||
} | ||
|
||
snprintk(data, sizeof(data), "8.8.8."); |
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.
Would be good if this sample adapted to the number of characters in the display
for (ib = 0, ic = 0; ib < cfg->digit_count && ic < len; ic++) { | ||
if (ch[ic] >= '0' && ch[ic] <= '9') { | ||
cfg->buffer[ib++] = DIGITS[ch[ic] - '0']; | ||
} else if (ch[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.
This does not check that a dot segment is present
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.
It's okay here since it's just setting the buffer bits and not actually updating the GPIOs directly. The DP
bit will be ignored if only 7 GPIOs are present, as handled in the auxdisplay_gpio_7seg_timer_expiry_fn
function below.
682a00d
to
9a37357
Compare
Oh, wow! I have a new idea. Maybe I should separate this into an LED strip (or LED controller) driver, probably named |
It's an option. For LED displays they are usually numeric, alphanumeric or hex, so auxdisplay can work with all of those. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
@xingrz - is there any chance that this could be reopened? I guess that this fell off the radar during the last release cycle. I would be happy to re-review 😄 |
@cfriedt Well, I’m not sure. I’m uncertain if this idea is fully developed. I’ve noticed that in actual projects, people often use dedicated LED driver ICs or GPIO expanders instead of the MCU’s GPIOs to drive the 7-segment displays. This approach provides enough driving power and minimizes IO usage. I think we should consider these scenarios, but I don’t have any concrete ideas yet. Let’s keep this PR closed for now. Perhaps in the future, someone interested might discover it and offer some new insights. |
Port expanders are natively supported in zephyr through the GPIO interface so should be fine |
I have a board in front of me that just uses GPIO as well without a driver. Depending on the brightness level required, I think it's reasonable in some circumstances. |
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.
Wasn't aware this got updated, minor change request for the binding compatible then looks good to go!
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#define DT_DRV_COMPAT gpio_7_segment |
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.
should have zephyr prefix
}; | ||
}; | ||
|
||
compatible: "gpio-7-segment" |
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.
needs zephyr,
prefix
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This is so close to being done @xingrz |
9a37357
to
74228b0
Compare
@kartben Thanks for you suggestions. Also rebased to include the |
d26c697
to
3c94e1e
Compare
}; | ||
}; | ||
|
||
compatible: "zephyr,gpio-7-segment" |
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 put a zephyr,
prefix if this binding is already based on linux ? why not just keep the linux compatible ?
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.
No, it’s not based on Linux, and they are not compatible. This driver was introduced a few months before a similar one was added to the Linux kernel. It’s a completely different implementation, with additional features such as multi-digit support.
@xingrz would you be able to come back to this? |
3c94e1e
to
d5e0de5
Compare
Rebased to align with #82121. Additionally, I added a |
d5e0de5
to
286a0d2
Compare
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.
Pending request for change re: README has actually not been addressed, sorry that I missed it earlier today
Apologies for missing that as well. I'll address it as soon as possible. |
14a5702
to
6992fec
Compare
This commit introduces a new driver for a common GPIO-driven 7-segment display. supporting both common anode and common cathode configurations. Signed-off-by: Chen Xingyu <[email protected]>
This commit introduces a new sample for the Auxiliary display driver. The sample demonstrates counting from 0 to 1000, with an interval of 100ms between each increment. This sample primarily serves to demonstrate the capabilities of segment displays. Signed-off-by: Chen Xingyu <[email protected]>
6992fec
to
92a721d
Compare
Rebased to include the recently merged This PR is now ready for review. |
@xingrz for future, when people should look at a review again they need to be requested, use the refresh icon next to each name in the reviewers list |
This PR introduces a new driver for a common GPIO-driven 7-segment display. supporting both common anode and common cathode configurations.
It also includes a new sample demonstrates counting from 0 to 1000, with an interval of 100ms between each increment.