Commit bfaa51dd4adf59c1b304399381401bfb58ed4099
1 parent
589c659035
Exists in
emb_lf_v2022.04
cmd: add serial console support for the cls command
Currently the cls command does not support the serial console The screen can be cleared in the video uclass, the colored frame buffer console, and the serial console by sending the same escape sequence. This reduces the cls command to a single printf() statement on most boards. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Showing 1 changed file with 8 additions and 2 deletions Side-by-side Diff
cmd/cls.c
... | ... | @@ -11,17 +11,23 @@ |
11 | 11 | #include <lcd.h> |
12 | 12 | #include <video.h> |
13 | 13 | |
14 | +#define CSI "\x1b[" | |
15 | + | |
14 | 16 | static int do_video_clear(struct cmd_tbl *cmdtp, int flag, int argc, |
15 | 17 | char *const argv[]) |
16 | 18 | { |
17 | -#if defined(CONFIG_DM_VIDEO) | |
18 | - struct udevice *dev; | |
19 | + __maybe_unused struct udevice *dev; | |
19 | 20 | |
21 | + /* Send clear screen and home */ | |
22 | + printf(CSI "2J" CSI "1;1H"); | |
23 | +#if defined(CONFIG_DM_VIDEO) | |
24 | +#if !defined(CONFIG_VIDEO_ANSI) | |
20 | 25 | if (uclass_first_device_err(UCLASS_VIDEO, &dev)) |
21 | 26 | return CMD_RET_FAILURE; |
22 | 27 | |
23 | 28 | if (video_clear(dev)) |
24 | 29 | return CMD_RET_FAILURE; |
30 | +#endif | |
25 | 31 | #elif defined(CONFIG_CFB_CONSOLE) |
26 | 32 | video_clear(); |
27 | 33 | #elif defined(CONFIG_LCD) |