ghnotgood opened a new pull request, #18362:
URL: https://github.com/apache/nuttx/pull/18362
## Summary
Improve checks for the position outside of the LCD's area; fix the input
when possible.
Also, slightly improve the documentation.
## Impact
Improve developer's experience:
- Add error/info messages.
- Guess the values when the position is outside of the LCD's area.
## Testing
I have used the `show_color` procedure below to test the use of
`LCDDEVIO_PUTAREA` and `LCDDEVIO_PUTRUN` ioctl for `/dev/lcd0`. Originally,
there was a bug in my `show_color` test procedure:
```
$ ,d
diff --git i/lcd/main.c w/lcd/main.c
index 5fb222b..cde9f5b 100644
--- i/lcd/main.c
+++ w/lcd/main.c
@@ -110,7 +110,7 @@ show_color(uint16_t color)
struct lcddev_area_s draw;
draw.col_start = 0;
- draw.col_end = vi.xres - 1;
+ draw.col_end = vi.xres;
draw.data = (uint8_t *)data;
for (i = 0; i < vi.yres; i++) {
```
which made the program fail without error mesage. It was my misunderstanding
of the constraints on the input parameters of `_puturn` and `_putarea`.
```
static void
show_color(uint16_t color)
{
int fd, r;
fb_coord_t i;
struct lcd_planeinfo_s pi;
struct fb_videoinfo_s vi;
uint16_t *data;
fd = open(CONFIG_VTK15_NUTTX_TEST_LCD_DEV, O_RDONLY);
ASSERT(0 <= fd);
r = ioctl(fd, LCDDEVIO_GETPLANEINFO, &pi);
ASSERT(0 == r);
r = ioctl(fd, LCDDEVIO_GETVIDEOINFO, &vi);
ASSERT(0 == r);
ASSERT(0 <= vi.xres);
ASSERT(0 <= vi.yres);
/* Allocate a single row of given color for LCD test. */
data = (uint16_t *)malloc(vi.xres * (pi.bpp >> 3));
ASSERT(NULL != data);
for (i = 0; i < vi.xres; i++) {
data[i] = color;
}
/* Use putarea to test the LCD. */
struct lcddev_area_s draw;
draw.col_start = 0;
draw.col_end = vi.xres - 1;
draw.data = (uint8_t *)data;
for (i = 0; i < vi.yres; i++) {
draw.row_start = i;
draw.row_end = i;
r = ioctl(fd, LCDDEVIO_PUTAREA, (unsigned long)&draw);
ASSERT(0 == r);
}
draw.data = NULL;
/* Use putrun and inverted color to test the LCD. */
for (i = 0; i < vi.xres; i++) {
data[i] = ~color;
}
struct lcddev_run_s run;
run.col = 0;
run.npixels = vi.xres;
run.data = (uint8_t *)data;
for (i = 0; i < vi.yres; i++) {
run.row = i;
r = ioctl(fd, LCDDEVIO_PUTRUN, (unsigned long)&run);
ASSERT(0 == r);
}
run.data = NULL;
free(data);
data = NULL;
r = close(fd);
ASSERT(0 == r);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]