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>
This commit is contained in:
parent
59a6092849
commit
92efbeeec6
1 changed files with 28 additions and 0 deletions
|
|
@ -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 @@ static int cmd_draw_line(const struct shell *sh, size_t argc, char *argv[])
|
|||
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_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_CMD_ARG(rect, NULL, HELP_DRAW_RECT, cmd_draw_rect, 5, 0),
|
||||
SHELL_SUBCMD_SET_END
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue