
From: Simon Glass <sjg@chromium.org> Add documentation and a simple test for the setcurs and lcdputs commands. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org> --- doc/usage/cmd/lcdputs.rst | 57 +++++++++++++++++++++++++++++++++++++++ doc/usage/cmd/setcurs.rst | 52 +++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 2 ++ test/dm/video.c | 20 ++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 doc/usage/cmd/lcdputs.rst create mode 100644 doc/usage/cmd/setcurs.rst diff --git a/doc/usage/cmd/lcdputs.rst b/doc/usage/cmd/lcdputs.rst new file mode 100644 index 00000000000..f34dbb3e3f1 --- /dev/null +++ b/doc/usage/cmd/lcdputs.rst @@ -0,0 +1,57 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +.. index:: + single: lcdputs (command) + +lcdputs command +=============== + +Synopsis +-------- + +:: + + lcdputs <string> + +Description +----------- + +The lcdputs command prints a string to the video framebuffer at the current +cursor position. + +string + Text string to display on the video console + +Examples +-------- + +Print a simple string:: + + => lcdputs "Hello World" + +Combine with setcurs to position text:: + + => setcurs 10 5 + => lcdputs "Positioned text" + +Print multiple lines:: + + => setcurs 0 0 + => lcdputs "Line 1" + => setcurs 0 1 + => lcdputs "Line 2" + +Configuration +------------- + +The lcdputs command is available if CONFIG_CMD_VIDEO=y. + +See also +-------- + +* :doc:`setcurs` - set cursor position + +Return value +------------ + +The return value $? is 0 (true) on success, 1 (false) on failure. diff --git a/doc/usage/cmd/setcurs.rst b/doc/usage/cmd/setcurs.rst new file mode 100644 index 00000000000..7aa2a4f454d --- /dev/null +++ b/doc/usage/cmd/setcurs.rst @@ -0,0 +1,52 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +.. index:: + single: setcurs (command) + +setcurs command +=============== + +Synopsis +-------- + +:: + + setcurs <col> <row> + +Description +----------- + +The setcurs command sets the cursor position on the video console. + +col + Column position in pixels (0-based) + +row + Row position in pixels (0-based) + + +Examples +-------- + +Set cursor to column 10, row 5:: + + => setcurs 10 5 + +Move cursor to top left:: + + => setcurs 0 0 + +Configuration +------------- + +The setcurs command is available if CONFIG_CMD_VIDEO=y. + +See also +-------- + +* :doc:`lcdputs` - print string on video framebuffer + +Return value +------------ + +The return value $? is 0 (true) on success, 1 (false) on failure. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 21d6d120e7c..0f271c1280d 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -85,6 +85,7 @@ Shell commands cmd/if cmd/itest cmd/imxtract + cmd/lcdputs cmd/load cmd/loadb cmd/loadm @@ -117,6 +118,7 @@ Shell commands cmd/scmi cmd/scp03 cmd/seama + cmd/setcurs cmd/setexpr cmd/sf cmd/shim diff --git a/test/dm/video.c b/test/dm/video.c index 702e9854005..287ba24eb6a 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -1080,3 +1080,23 @@ static int dm_test_video_backspace_truetype(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_video_backspace_truetype, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +/* video commands */ +static int dm_test_video_cmd(struct unit_test_state *uts) +{ + struct udevice *dev, *con; + + ut_assertok(select_vidconsole(uts, "vidconsole0")); + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, "8x16", 0)); + + ut_assertok(run_command("setcurs 10 5", 0)); + + ut_assertok(run_command("lcdputs \"Test string\"", 0)); + ut_asserteq(188, video_compress_fb(uts, dev, false)); + ut_assertok(video_check_copy_fb(uts, dev)); + + return 0; +} +DM_TEST(dm_test_video_cmd, UTF_SCAN_PDATA | UTF_SCAN_FDT); -- 2.43.0