fb: cfb_shell: Add `draw line` command
Add the `draw line` command to execute the `cfb_draw_line()` API.
This command render line.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
diff --git a/subsys/fb/cfb_shell.c b/subsys/fb/cfb_shell.c
index c872db3..a37dfd7 100644
--- a/subsys/fb/cfb_shell.c
+++ b/subsys/fb/cfb_shell.c
@@ -19,6 +19,7 @@
#define HELP_INIT "call \"cfb init\" first"
#define HELP_PRINT "<col: pos> <row: pos> \"<text>\""
#define HELP_DRAW_POINT "<x> <y0>"
+#define HELP_DRAW_LINE "<x0> <y0> <x1> <y1>"
#define HELP_INVERT "[<x> <y> <width> <height>]"
static const struct device *const dev =
@@ -168,6 +169,32 @@
return err;
}
+static int cmd_draw_line(const struct shell *sh, size_t argc, char *argv[])
+{
+ int err;
+ struct cfb_position start, end;
+
+ if (!dev) {
+ shell_error(sh, HELP_INIT);
+ return -ENODEV;
+ }
+
+ start.x = strtol(argv[1], NULL, 10);
+ start.y = strtol(argv[2], NULL, 10);
+ end.x = strtol(argv[3], NULL, 10);
+ end.y = strtol(argv[4], NULL, 10);
+
+ err = cfb_draw_line(dev, &start, &end);
+ if (err) {
+ shell_error(sh, "Failed text 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;
@@ -568,6 +595,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_CMD_ARG(line, NULL, HELP_DRAW_LINE, cmd_draw_line, 5, 0),
SHELL_SUBCMD_SET_END
);