fb: cfb_shell: Add `draw point` command Add the `draw point` command to execute the `cfb_draw_point()` API. This command render single dot. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
diff --git a/subsys/fb/cfb_shell.c b/subsys/fb/cfb_shell.c index 3758f3d..c872db3 100644 --- a/subsys/fb/cfb_shell.c +++ b/subsys/fb/cfb_shell.c
@@ -18,6 +18,7 @@ #define HELP_NONE "[none]" #define HELP_INIT "call \"cfb init\" first" #define HELP_PRINT "<col: pos> <row: pos> \"<text>\"" +#define HELP_DRAW_POINT "<x> <y0>" #define HELP_INVERT "[<x> <y> <width> <height>]" static const struct device *const dev = @@ -143,6 +144,30 @@ return err; } +static int cmd_draw_point(const struct shell *sh, size_t argc, char *argv[]) +{ + int err; + struct cfb_position pos; + + if (!dev) { + shell_error(sh, HELP_INIT); + return -ENODEV; + } + + pos.x = strtol(argv[1], NULL, 10); + pos.y = strtol(argv[2], NULL, 10); + + err = cfb_draw_point(dev, &pos); + if (err) { + shell_error(sh, "Failed point drawing to Framebuffer error=%d", err); + return err; + } + + err = cfb_framebuffer_finalize(dev); + + return err; +} + static int cmd_scroll_vert(const struct shell *sh, size_t argc, char *argv[]) { int err = 0; @@ -542,6 +567,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_cmd_draw, SHELL_CMD_ARG(text, NULL, HELP_PRINT, cmd_draw_text, 4, 0), + SHELL_CMD_ARG(point, NULL, HELP_DRAW_POINT, cmd_draw_point, 3, 0), SHELL_SUBCMD_SET_END );