examples/touchscreen/tc_main.c: Appease nxstyle

This commit is contained in:
YAMAMOTO Takashi 2020-11-11 10:21:04 +09:00 committed by Xiang Xiao
parent 89a4d02fce
commit c8f2f0f262

View File

@ -109,6 +109,7 @@ int main(int argc, FAR char *argv[])
{ {
nsamples = strtol(argv[1], NULL, 10); nsamples = strtol(argv[1], NULL, 10);
} }
printf("tc_main: nsamples: %d\n", nsamples); printf("tc_main: nsamples: %d\n", nsamples);
/* Open the touchscreen device for reading */ /* Open the touchscreen device for reading */
@ -127,104 +128,105 @@ int main(int argc, FAR char *argv[])
* touchscreen samples. * touchscreen samples.
*/ */
for (;;) for (; ; )
{ {
/* Flush any output before the loop entered or from the previous pass /* Flush any output before the loop entered or from the previous pass
* through the loop. * through the loop.
*/ */
fflush(stdout); fflush(stdout);
#ifdef CONFIG_EXAMPLES_TOUCHSCREEN_MOUSE #ifdef CONFIG_EXAMPLES_TOUCHSCREEN_MOUSE
/* Read one sample */ /* Read one sample */
iinfo("Reading...\n"); iinfo("Reading...\n");
nbytes = read(fd, &sample, sizeof(struct mouse_report_s)); nbytes = read(fd, &sample, sizeof(struct mouse_report_s));
iinfo("Bytes read: %d\n", nbytes); iinfo("Bytes read: %d\n", nbytes);
/* Handle unexpected return values */ /* Handle unexpected return values */
if (nbytes < 0) if (nbytes < 0)
{ {
errval = errno; errval = errno;
if (errval != EINTR) if (errval != EINTR)
{ {
printf("tc_main: read %s failed: %d\n", printf("tc_main: read %s failed: %d\n",
CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval); CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval);
errval = 3; errval = 3;
goto errout_with_dev; goto errout_with_dev;
} }
printf("tc_main: Interrupted read...\n"); printf("tc_main: Interrupted read...\n");
} }
else if (nbytes != sizeof(struct mouse_report_s)) else if (nbytes != sizeof(struct mouse_report_s))
{ {
printf("tc_main: Unexpected read size=%d, expected=%d, Ignoring\n", printf("tc_main: Unexpected read size=%d, expected=%d, Ignoring\n",
nbytes, sizeof(struct mouse_report_s)); nbytes, sizeof(struct mouse_report_s));
} }
/* Print the sample data on successful return */ /* Print the sample data on successful return */
else else
{ {
printf("Sample :\n"); printf("Sample :\n");
printf(" buttons : %02x\n", sample.buttons); printf(" buttons : %02x\n", sample.buttons);
printf(" x : %d\n", sample.x); printf(" x : %d\n", sample.x);
printf(" y : %d\n", sample.y); printf(" y : %d\n", sample.y);
#ifdef CONFIG_MOUSE_WHEEL #ifdef CONFIG_MOUSE_WHEEL
printf(" wheel : %d\n", sample.wheel); printf(" wheel : %d\n", sample.wheel);
#endif #endif
} }
#else #else
/* Read one sample */ /* Read one sample */
iinfo("Reading...\n"); iinfo("Reading...\n");
nbytes = read(fd, &sample, sizeof(struct touch_sample_s)); nbytes = read(fd, &sample, sizeof(struct touch_sample_s));
iinfo("Bytes read: %d\n", nbytes); iinfo("Bytes read: %d\n", nbytes);
/* Handle unexpected return values */ /* Handle unexpected return values */
if (nbytes < 0) if (nbytes < 0)
{ {
errval = errno; errval = errno;
if (errval != EINTR) if (errval != EINTR)
{ {
printf("tc_main: read %s failed: %d\n", printf("tc_main: read %s failed: %d\n",
CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval); CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval);
errval = 3; errval = 3;
goto errout_with_dev; goto errout_with_dev;
} }
printf("tc_main: Interrupted read...\n"); printf("tc_main: Interrupted read...\n");
} }
else if (nbytes != sizeof(struct touch_sample_s)) else if (nbytes != sizeof(struct touch_sample_s))
{ {
printf("tc_main: Unexpected read size=%ld, expected=%d, Ignoring\n", printf("tc_main: Unexpected read size=%ld, expected=%d, "
(long)nbytes, sizeof(struct touch_sample_s)); "Ignoring\n",
} (long)nbytes, sizeof(struct touch_sample_s));
}
/* Print the sample data on successful return */ /* Print the sample data on successful return */
else else
{ {
printf("Sample :\n"); printf("Sample :\n");
printf(" npoints : %d\n", sample.npoints); printf(" npoints : %d\n", sample.npoints);
printf("Point 1 :\n"); printf("Point 1 :\n");
printf(" id : %d\n", sample.point[0].id); printf(" id : %d\n", sample.point[0].id);
printf(" flags : %02x\n", sample.point[0].flags); printf(" flags : %02x\n", sample.point[0].flags);
printf(" x : %d\n", sample.point[0].x); printf(" x : %d\n", sample.point[0].x);
printf(" y : %d\n", sample.point[0].y); printf(" y : %d\n", sample.point[0].y);
printf(" h : %d\n", sample.point[0].h); printf(" h : %d\n", sample.point[0].h);
printf(" w : %d\n", sample.point[0].w); printf(" w : %d\n", sample.point[0].w);
printf(" pressure : %d\n", sample.point[0].pressure); printf(" pressure : %d\n", sample.point[0].pressure);
} }
#endif #endif
if (nsamples && --nsamples <= 0) if (nsamples && --nsamples <= 0)
{ {
break; break;
} }
} }
errout_with_dev: errout_with_dev:
close(fd); close(fd);