Sfoglia il codice sorgente

added clear screen command

hathach 12 anni fa
parent
commit
0268e0b787
3 ha cambiato i file con 18 aggiunte e 2 eliminazioni
  1. 1 0
      demos/bsp/boards/ansi_escape.h
  2. 10 2
      demos/host/src/cli.c
  3. 7 0
      demos/host/src/msc_app.c

+ 1 - 0
demos/bsp/boards/ansi_escape.h

@@ -67,6 +67,7 @@
 #define ANSI_CURSOR_BACKWARD(n)  CSI_CODE(#n "D")
 #define ANSI_CURSOR_LINE_DOWN(n) CSI_CODE(#n "E")
 #define ANSI_CURSOR_LINE_UP(n)   CSI_CODE(#n "F")
+#define ANSI_CURSOR_POSITION(n, m) CSI_CODE(#n ";" #m "H")
 
 #define ANSI_ERASE_SCREEN(n)     CSI_CODE(#n "J")
 #define ANSI_ERASE_LINE(n)       CSI_CODE(#n "K")

+ 10 - 2
demos/host/src/cli.c

@@ -81,7 +81,7 @@ static char const * const cli_error_message[] =
     ENTRY(cls     , cli_cmd_clear    , "Clear the screen."                                                   ) \
     ENTRY(ls      , cli_cmd_list     , "List information about the FILEs (the current directory by default).") \
     ENTRY(cd      , cli_cmd_changedir, "change the current directory."                                       ) \
-    ENTRY(cat     , cli_cmd_cat      , "display contents of a text file."                                    ) \
+    ENTRY(cat     , cli_cmd_cat      , "display contents of a file."                                         ) \
     ENTRY(cp      , cli_cmd_copy     , "Copies one or more files to another location."                       ) \
     ENTRY(mkdir   , cli_cmd_mkdir    , "Create a DIRECTORY, if it does not already exist."                   ) \
 
@@ -241,7 +241,8 @@ cli_error_t cli_cmd_help(char * para)
 //--------------------------------------------------------------------+
 cli_error_t cli_cmd_clear(char* p_para)
 {
-  printf(ANSI_ERASE_SCREEN(2));
+  printf(ANSI_ERASE_SCREEN(2) ANSI_CURSOR_POSITION(1,1) );
+  return CLI_ERROR_NONE;
 }
 
 //--------------------------------------------------------------------+
@@ -345,6 +346,13 @@ cli_error_t cli_cmd_cat(char *p_para)
 //--------------------------------------------------------------------+
 // Make Directory command
 //--------------------------------------------------------------------+
+cli_error_t cli_cmd_mkdir(char *p_para)
+{
+  puts("executing mkdir");
+
+  return CLI_ERROR_NONE;
+}
+
 //--------------------------------------------------------------------+
 // COPY command
 //--------------------------------------------------------------------+

+ 7 - 0
demos/host/src/msc_app.c

@@ -95,6 +95,13 @@ void tusbh_msc_mounted_cb(uint8_t dev_addr)
       return;
     }
 
+    puts("---------------------------------------------------------------------");
+    puts("- MASSSTORAGE CLASS CLI IS A NON-MATURE CODE. DISK-WRITING COMMANDS -");
+    puts("- SUCH AS cp(COPY), mkdir(MAKE DIRECTORY) ARE POTENTIAL TO DAMAGE   -");
+    puts("- YOUR USB THUMBDRIVE. USING THOSE COMMANDS ARE AT YOUR OWN RISK.   -");
+    puts("- THE AUTHOR HAS NO RESPONSIBILITY WITH YOUR DEVICE NOR ITS DATA    -");
+    puts("---------------------------------------------------------------------");
+
     f_chdrive(dev_addr-1); // change to newly mounted drive
     f_chdir("/"); // root as current dir