-
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/lcd: code deduplication for st7735 and ili9341 #19816
drivers/lcd: code deduplication for st7735 and ili9341 #19816
Conversation
spi_transfer_byte(dev->params->spi, dev->params->cs_pin, cont, data); | ||
} | ||
else { | ||
assert(false); |
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 not just use assert(dev->params->spi != SPI_UNDEF);
at the beginning of the function? (Here and below)
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.
Yeah, the reason is that this change is a split-off from parallel interface implementation where it will be
#if IS_USED(MODULE_LCD_SPI)
if (dev->params->spi != SPI_UNDEF) {
/* SPI serial interface is used */
spi_transfer_byte(dev->params->spi, dev->params->cs_pin, cont, data);
}
else {
#endif
#if IS_USED(MODULE_LCD_PARALLEL)
/* MCU 8080 8-/16-bit parallel interface is used */
_lcd_write_byte_par(dev, cont, data);
#else
assert(false);
#endif
#if IS_USED(MODULE_LCD_SPI)
}
#endif
I can change it, if you want 😄
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.
Let's keep it like this if it's easier for you to rebase once that's merged.
@@ -22,19 +22,19 @@ config HAVE_ST7735 | |||
help | |||
Indicates that an ST7735 display is present. | |||
|
|||
config HAVE_ST7789 |
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 seems unrelated and actually not needed. The pattern here was to group driver module variants module with their HAVE_VARIANT
just after. With that change it looks messed up.
Maybe a better approach is to use:
config MODULE_VARIANT1
...
config MODULE_VARIANT2
...
config HAVE_VARIANT1
...
config HAVE_VARIANT2
...
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 is from the history. When @maribu tried to fix master compilation in CI with PR #19813, he added
config MODULE_ST7789
- bool "ST7789 display driver"
- select MODULE_ST7735
+ bool
+ depends on HAVE_ST7789
+ default y if MODULE_ST7735
+ help
ST7789 display driver
according to my suggestion. This was just from the commit cb0aba6 in this PR. When I rebased, the order has been changed.
Regarding the order, my feeling was that we define a HAVE_*
symbol before it is used in MODULE_*
. I can change it if you want.
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.
Comparing to other drivers the fix doesn't seem correct (I'm not expert enough with this kind of kconfig stuff, that's why I look at other drivers written by HAW). And the order of definition is not a problem apparently. IMHO it's better to have the "MODULE_DRIVER" definition before the "HAVE_DRIVER" since the latter is more for internal use.
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 have changed the order.
Why is this fix not correct? MODULE_ST7789
is only available if the board enables HAVE_ST7789
. The MODULE_ST7789
has to be enabled by default if MODULE_ST7735
is enabled. This corresponds to makefile dependencies.
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.
"HAVE_ST7759" indeed tells the board has it so it can be pulled in automatically. But I manually plug the device to a dev kit and want to pull in myself, I'll also have to pullin the HAVE_ symbol which is not needed for other drivers AFAICT.
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.
But I manually plug the device to a dev kit and want to pull in myself, I'll also have to pullin the HAVE_ symbol
Yes, indeed. Unfortunatly, there was no other a approach to enable the st7789
variant if the board pulls in the module in makefile dependencies. This should become obsolete once the driver varaiants are splitted.
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 just code moved around and will simplify the work for coming PRs on new LCD drivers (not only SPI based). I saw some screenshot in privates that prove the PR is working.
Please squash!
ACK
MODULE_ST7789 is enabled if MODULE_ST7735 is enabled and the board has selected HAVE_ST7789.
In preparation for the parallel interface support the following changes were made: 1. The code for basic communication (acquire/release SPI device, SPI transfers), which were always implemented identically in the individual display drivers again and again, have been moved to the LCD driver as low-level functions and are now used by the display drivers. These low level function allow - code deduplication on one hand and - to define a more abstract communication interface on the other hand that can then be extended by parallel communication 2. Identical GPIO initialization has also been moved from display drivers to the LCD driver.
Using a default implementation of `lcd_set_area` function allows further code deduplication.
7914f95
to
5cb51b1
Compare
bors merge |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
@aabadie Thanks for reviewing and merging. |
Contribution description
In preparation for the parallel interface support the following changes were made:
lcd_set_area
function allows further code deduplication.Finally, the
ili9341
andst7735
drivers only implement the inialization sequence for the LCD driver IC.Testing procedure
tests/drivers/ili9341
should still work for a board with an ILI9341. Tested withesp32-wrover-kit
.tests/drivers/st7735
should still work for a board with a ST77xx. Tested withesp32s3-usb-otg
.Issues/PRs references