-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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: Add text display interface #52032
drivers: Add text display interface #52032
Conversation
25f01df
to
a157d2f
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.
some initial comments
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 love that you're adding text-based LCDs here!
It's been a while but would be a great addition on my next demo.
Just a couple of questions / comments:
- Are either of grove or itron displays capable of producing interrupts (e.g. via GPIO)? If so, I would suggest building those capabilities into the drivers.
- Some of the drivers sleep within the API calls. In general, it would be better to use a semaphore or spinlock and either delayed work or an ISR to unlock
Thanks though - I'm really looking forward to seeing this upstream 😁
It might also be useful to wrap API calls in a |
@cfriedt Not sure what you mean here by interrupt, unless you mean if they have user input/buttons/touchscreen? The noritake itron has a busy output line which I did expose here but will hide internally in the driver and not expose externally, HD44780 does not have inputs. |
@thedjnK - a busy line should do for a gpio interrupt. I could make some additional code comments if you need clarification, but my general suggestion was to avoid sleeping (ans also busy looping). Sleeping is usually bad for drivers. Using an interrupt (e.g. a busy line) is one way to avoid sleeping, and another way to avoid sleeping is to use a workqueue. It might be smart to use a dedicated workqueue in this case. |
@cfriedt 😆 this was the comment from the architecture meeting:
I just removed it so I can add it back quickly... |
a157d2f
to
c907d4c
Compare
|
||
rc = i2c_write_dt(&config->bus, clear, sizeof(clear)); | ||
LOG_DBG("clear, delay 20 ms"); | ||
k_sleep(K_MSEC(20)); |
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 avoid sleeping here
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 from the original zephyr driver (copy and paste) and would think sleeping is the only course since the command should be blocking until it is complete (someone raised this in the architecture meeting)
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.
Commands can still be blocking if you use e.g. a semaphore (semaphore can be unlocked via ISR or workqueue).
This is done in a few places in e.g. sensor drivers.
Just a thought.
rc = i2c_write_dt(&config->bus, buf, sizeof(buf)); | ||
|
||
LOG_DBG("set display_state options, delay 5 ms"); | ||
k_sleep(K_MSEC(5)); |
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 avoid sleeping here
i2c_write_dt(&config->bus, buf, sizeof(buf)); | ||
|
||
LOG_DBG("set function options, delay 5 ms"); | ||
k_sleep(K_MSEC(5)); |
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 avoid sleeping here
* VDD to power on, so pause a little here, 30 ms min, so we go 50 | ||
*/ | ||
LOG_DBG("delay 50 ms while the VDD powers on"); | ||
k_sleep(K_MSEC(50)); |
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.
Probably better to move this to something like an enable()
function.
3104e47
to
b41753d
Compare
b41753d
to
ede3b70
Compare
e085483
to
9f54533
Compare
OK I've made some fixes and updates, PM is implemented in my display, added a simple sample application, still some work to do on it. @cfriedt I'm a bit stuck with using interrupts and semaphores, I was about to switch to them on my display driver, then I stopped and paused because that would pose a problem, a problem for me at least, I want to be able to use the display from a bootloader (i.e. mcuboot) and imposing semaphores then means I would need to build mcuboot with mutlthreading support, just enabling that option without using the functions in code adds 4KB to a bootloader build which isn't a small number, and thinking about it, the delays should not really be long for a display (for mine at 38400 baud, assuming you output 40 characters and every 3 characters you have to pause for 4ms, the total time needed to display all that is about 63ms, and whilst the display is busy, other tasks can run perhaps, so at least for my driver (note: noritake display, not the groove) I don't think it's worth changing to interrupts. I don't think it's worth doing either for the groove but that's because that driver is basically a straight up copy and paste from existing zephyr code, I don't have that display to test with so don't want to submit a driver that might be broken and I'm unable to test with. For a HD44780 driver (which will have to come at a later date) I will think about it, although I think that would fall under the same bucket of using |
Device Tree can fix that 😄 Make it a DT property and hook up things in your INIT. |
@cfriedt not for setting up the GPIO, that's already done in this PR, it's for usage of semaphores, the burden of enabling that is too great for a simple bootloader |
@nordicjm - you can use DT properties to compile-in or compile-out support for semaphores. In the non-semaphore version just use a different function pointer for achieving the same thing. Then you get the best of both worlds :-) |
9f54533
to
b16e223
Compare
Just saw this comment: DT describes hardware, not software configuration ;-) |
@gmarull - that's right. In this case the DT would be describing whether or not there are interrupts available for the device (so business as usual) and then the driver would be configured to either use an interrupt-driven routine or polling based on that (also pretty normal, right?). I'm just pointing out that it can be done in a compile-time const way inside of |
That doesn't make sense, if a display needs an interrupt then it needs an interrupt and the driver would have it, if it doesn't need an interrupt then it wouldn't be present in the driver. If there is an optional one then it would down to the driver if it used it or not (and with displays, they are not optional, the display I have here will happily print complete garbage if you do not use and respect the busy line). And from a dts perspective, it's just a phandle-array None of which has any relation to multithreading. |
b16e223
to
79ed8d2
Compare
184e8d9
to
86e082e
Compare
Ports the Jinghua Display JHD1313 LCD (with RGB backlight) driver to use the new auxdisplay driver interface. This driver is used on the seeed grove LCD RGB display, and replaces it. Signed-off-by: Jamie McCrae <spam@helper3000.net>
57c1413
to
a9a1ea0
Compare
.capabilities = { \ | ||
.columns = DT_INST_PROP(inst, columns), \ | ||
.rows = DT_INST_PROP(inst, rows), \ | ||
.mode = DT_ENUM_IDX(DT_DRV_INST(inst), mode), \ |
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.
DT_INST…
.clear_delay = DT_INST_PROP(inst, clear_command_delay_us), \ | ||
.boot_delay = DT_INST_PROP(inst, boot_delay_ms), \ | ||
}; \ | ||
PM_DEVICE_DT_INST_DEFINE(inst, auxdisplay_hd44780_pm_action); \ |
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.
leftover
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.
Removed
|
||
This sample shows how to use the auxiliary display drivers by outputting a | ||
sample "Hello World" text to one. If power management is enabled when | ||
building (:kconfig:option:`CONFIG_PM_DEVICE`), it also demonstrates |
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.
outdated?
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.
Fixed
|
||
k_sleep(K_SECONDS(3)); | ||
|
||
pm_device_action_run(dev, PM_DEVICE_ACTION_SUSPEND); |
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 update?
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.
Removed
fe815fb
to
ed9bc44
Compare
Adds an auxiliary display driver for Hitachi HD44780-based (and compatible) LCD displays. Signed-off-by: Jamie McCrae <spam@helper3000.net>
Add myself as auxiliary display maintainer. Signed-off-by: Jamie McCrae <spam@helper3000.net>
Add myself as auxiliary display maintainer. Signed-off-by: Jamie McCrae <spam@helper3000.net>
Adds a simple auxdisplay sample which outputs hello world and the name of the board. A sample overlay is provided for the nucleo_f746zg board with a Hitachi HD44780-compatible display. Signed-off-by: Jamie McCrae <spam@helper3000.net>
Adds base auxdisplay documentation. Signed-off-by: Jamie McCrae <spam@helper3000.net>
Adds the new auxiliary display peripheral as an unstable API. Signed-off-by: Jamie McCrae <spam@helper3000.net>
Adds a note on unstable auxiliary display support being added, alongside 3 drivers. Signed-off-by: Jamie McCrae <spam@helper3000.net>
ed9bc44
to
6ff540c
Compare
Adds the base driver include file and noritake itron text display dts file for review.
Tested:
Fixes #51912