ili9341: Initial import of ili9341 LCD driver#9948
Conversation
|
Yeah! Thanks @bergzand :) |
|
@aabadie Which board had this display on it? And what is the most useful default pinout for it? |
stm32-f429i-disc1
Look at this branch and in particular, this commit, the second commit also provides some cleanup (edit: fixed the commit links) |
aabadie
left a comment
There was a problem hiding this comment.
Had a quick pass of review and found minor things. I also think some parts of the code could be uncrustified (missing spaces around some operators).
Otherwise, see my previous comment about having default params for the stm32f429i-disc1 board and params initialization.
The test application also needs a README.
And finally, one question: the driver doesn't allow to display images. Do you have an idea how this could be done ?
drivers/ili9341/Makefile
Outdated
| @@ -0,0 +1,2 @@ | |||
| MODULE = ili9341 | |||
drivers/include/ili9341.h
Outdated
| } ili9341_t; | ||
|
|
||
|
|
||
| int ili9341_init(ili9341_t* dev, ili9341_params_t* prms); |
There was a problem hiding this comment.
Missing doxygen documentation
There was a problem hiding this comment.
Hey, I checked for that, will fix 😄
The driver works by selecting an area on the display and update all pixels in that area. This closely match the lower level hardware. So yes, an image is possible, but I'd have to generate something from a bitmap. Say we have an image of the RIOT logo of X by Y pixels, we can use the If I have some time I can try to build it, otherwise feel free to open an PR on my branch :) |
|
By the way, I tested this PR (with my 2 extra commits applied) and it works like a charm. |
|
Just verified that this also works fine on the
Just for reference, I used this configuration in : I took the pin assignment from here. |
|
@x3ro, can you try this branch ? I tested it on the disc1 version. It uses the right way of passing driver parameters and I'd like @bergzand to include my changes in his PR (I don't know why I can't open a PR on top of this one) |
|
@aabadie I have some time this weekend to work on the driver, just have to build a small setup to test the device. |
|
Hey @aabadie, yeah your branch works fine. I'm just wondering whether the pin information should really go in the driver, given that it's quite board specific. Also, why are you using magic numbers for the ports instead of e.g. |
|
Any news here @bergzand ?
I would say that this is not required. Maybe a comment in the driver would be enough. It just that this screen is provided by this board, which is already available in RIOT.
If we use |
|
@aabadie That would also be fixed by removing the pin info from the driver and putting it in the board, right? Or in other words, not define |
What do you mean exactly ? using GPIO_UNDEF ? |
Let's start with a rebase here to have all the new board names. |
The name of the pin is indeed
I've made the reset pin optional, |
|
@aabadie I think I've covered all your issues. I've added an little endian mode in case the data is in little endian format. this slows down the driver a bit, so big endian is preferred, but it is useful to have when the source data/image is in little endian format. |
|
There is one remaining issue and that is that I can't seem to read data from the display. While not necessarily an issue when using the device, it would be nice to have. @aabadie Could you please test if reading data from the display works for you? I'm not sure if it is because of my hardware or that I'm doing something wrong in the driver. I'd rather not block this PR on this bug since it is not really critical for using the display. |
drivers/ili9341/ili9341.c
Outdated
| spi_release(dev->params.spi); | ||
| } | ||
|
|
||
| static void ili9341_set_area(ili9341_t *dev, uint16_t x1, uint16_t x2, |
There was a problem hiding this comment.
Maybe it is an idea to add this to the public API. Together with a write function that allows one to set n bytes in memory this would allow the writing of an area in multiple chunked writes. I have no use case for this, so feel free to ignore.
There was a problem hiding this comment.
We can always extend the API in a follow up PR :)
drivers/include/ili9341.h
Outdated
| * @param[in] dev device descriptor | ||
| * @param[in] cmd command | ||
| * @param[in] data data from the device | ||
| * @param[in] len length of the returned data |
There was a problem hiding this comment.
Seems to me that data is data to the device and len is the length of that data.
drivers/include/ili9341.h
Outdated
| * @param[in] y2 y coordinate of the opposite corner | ||
| * @param[in] color array of colors to fill the area with | ||
| */ | ||
| void ili9341_map(ili9341_t *dev, uint16_t x1, uint16_t x2, uint16_t y1, |
There was a problem hiding this comment.
I don't think the function name is clear. Maybe fill_pixels is clearer?
There was a problem hiding this comment.
Additional observation: x2/y2 seem to be the the x/y-coordinate of the pixel in the opposite corner, not the opposite corner itself (same for all other x2/y2's).
There was a problem hiding this comment.
I don't think the function name is clear. Maybe
fill_pixelsis clearer?
Ack
Additional observation:
x2/y2seem to be the the x/y-coordinate of the pixel in the opposite corner, not the opposite corner itself (same for all other x2/y2's).
So a documentation fix?
There was a problem hiding this comment.
If explained clearly a documentation fix is fine to me, but a code change would enable users to do things like: fill_pixels(x, y, x + picture_width, y + picture_height, picture). (instead of fill_pixels(x, y, x + picture_width - 1, y + picture_height - 1, picture), which isn't as intuitive)
There was a problem hiding this comment.
Renamed to pixmap and added some docs
drivers/include/ili9341.h
Outdated
| void ili9341_fill(ili9341_t *dev, uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, uint16_t color); | ||
|
|
||
| /** | ||
| * @brief Fill a rectangular area with an array of colors |
There was a problem hiding this comment.
I think 'pixels' would be clearer than 'colors'. A note to remind users that the input data should exactly match the size of the area might also be useful.
drivers/ili9341/ili9341.c
Outdated
|
|
||
| int ili9341_init(ili9341_t *dev, const ili9341_params_t *prms) | ||
| { | ||
| memcpy(&dev->params, prms, sizeof(ili9341_params_t)); |
There was a problem hiding this comment.
| memcpy(&dev->params, prms, sizeof(ili9341_params_t)); | |
| dev->params = *prms; /* maybe also rename prms to params ? */ |
| @@ -0,0 +1,71 @@ | |||
| const uint16_t picture[69][128] = { | |||
There was a problem hiding this comment.
Instead of 69, I had to use 70 with an extra empty line at the end of array to avoid having an alone green pixel at the bottom right of the logo.
I have no idea why it was there. One could think of a division by 2 issue but there is no such thing in ili9341_map implementation.
There was a problem hiding this comment.
There was a problem hiding this comment.
And fixed, I was able to reproduce your issue and it should be fixed in the latest iteration.
|
The ST7789V used on the PineTime needs spi mode 3. I git a commit adding that (https://github.com/kaspar030/RIOT/tree/ili9341_spi_mode). Maybe cherry-pick in here? |
|
Otherwise, please address @aabadie's problem and rebase and squash. ;) |
|
@kaspar030 @aabadie: Does it still make sense to name the driver |
drivers/include/ili9341.h
Outdated
| * @brief Device descriptor for a ili9341 | ||
| */ | ||
| typedef struct { | ||
| ili9341_params_t params; /**< I2C device that sensor is connected to */ |
|
Rebased, fixed some issues with the driver, also cleaned a few things up |
|
@aabadie @kaspar030: Still okay to squash? |
Cherry picked! |
|
Please squash and rebase. Just a suggestion that could be nice to use with the test application: put the RIOT logo in a blob and include it to the build ? That would make it easy for testing with other images. What do you think ? |
I think this is not that easy, so I'd rather leave this for somebody else to follow up on. To use the blob Makefile construct, the supplied file needs to be the raw image in rgb 565 format without any metadata. I don't think there is any advantage to including that instead of the image in C header format. What I'd rather see is something similar to the blob construct, but for png images, add a number of PNG images to a Make variable and the build will convert them to C header format in raw rgb 565 format. Then we could even include a repo with RIOT logo images as external package. |
9d0cde8 to
1c047b8
Compare
|
@aabadie Rebased and squashed! |
|
@bergzand, Murdock is reporting some remaining issues. Can you have a look ? |
|
@aabadie I've excluded the image draw from the test when using AVR microcontrollers. On the AVR architecture, the image data ends up in the RAM. The approximately 16KB of image data doesn't fit on those devices. Storing them in flash would require something along the lines of the |
|
@aabadie I've added the Is it okay to squash again? |
|
Please squash! |
This commit adds support for the ili9341 display
|
Squashed! |
|
Tested on |
Thanks @fjmolinas ! |
|
All green, go! |
|
🎉 |
Contribution description
Simple driver and test application of the ili9341
Testing procedure
Test application included
Review notes
I've wrote this driver quite a while ago, it might be missing some of the newer coding practices.
Issues/PRs references
None