fb: cfb_shell: Add `draw rect` command
Add the `draw rect` command to execute the `cfb_draw_rect()` API.
This command render rectangle.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
diff --git a/subsys/fb/cfb_shell.c b/subsys/fb/cfb_shell.c
index a37dfd7..0d70c02 100644
--- a/subsys/fb/cfb_shell.c
+++ b/subsys/fb/cfb_shell.c
@@ -20,6 +20,7 @@
#define HELP_PRINT "<col: pos> <row: pos> \"<text>\""
#define HELP_DRAW_POINT "<x> <y0>"
#define HELP_DRAW_LINE "<x0> <y0> <x1> <y1>"
+#define HELP_DRAW_RECT "<x0> <y0> <x1> <y1>"
#define HELP_INVERT "[<x> <y> <width> <height>]"
static const struct device *const dev =
@@ -195,6 +196,32 @@
return err;
}
+static int cmd_draw_rect(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_rect(dev, &start, &end);
+ if (err) {
+ shell_error(sh, "Failed rectanble 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;
@@ -596,6 +623,7 @@
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_CMD_ARG(rect, NULL, HELP_DRAW_RECT, cmd_draw_rect, 5, 0),
SHELL_SUBCMD_SET_END
);