Przeglądaj źródła

Add clear_flags command

As the name suggests, it clears all the flags in the configuration
buffer.  This provides a way to easily set all the flags to a known
state, which is nice for implementing libraries that configure PD Buddy
Sink devices.
Clara Hobbs 5 lat temu
rodzic
commit
f42fd547af
2 zmienionych plików z 21 dodań i 1 usunięć
  1. 8
    1
      docs/console_config.md
  2. 13
    0
      src/shell.c

+ 8
- 1
docs/console_config.md Wyświetl plik

@@ -104,7 +104,8 @@ automatically erased if necessary.
104 104
 Usage: `load`
105 105
 
106 106
 Loads the current configuration from flash into the buffer.  Useful if you want
107
-to change some settings while leaving others alone.
107
+to change some settings while leaving others alone.  If there is no
108
+configuration, `No configuration` is printed instead.
108 109
 
109 110
 ### get_cfg
110 111
 
@@ -123,6 +124,12 @@ Usage: `get_tmpcfg`
123 124
 
124 125
 Prints the contents of the configuration buffer.
125 126
 
127
+### clear_flags
128
+
129
+Usage: `clear_flags`
130
+
131
+Clears all the flags in the configuration buffer.
132
+
126 133
 ### toggle_giveback
127 134
 
128 135
 Usage: `toggle_giveback`

+ 13
- 0
src/shell.c Wyświetl plik

@@ -165,6 +165,18 @@ static void cmd_get_tmpcfg(BaseSequentialStream *chp, int argc, char *argv[])
165 165
     pdb_config_print(chp, &tmpcfg);
166 166
 }
167 167
 
168
+static void cmd_clear_flags(BaseSequentialStream *chp, int argc, char *argv[])
169
+{
170
+    (void) argv;
171
+    if (argc > 0) {
172
+        chprintf(chp, "Usage: clear_flags\r\n");
173
+        return;
174
+    }
175
+
176
+    /* Clear all flags */
177
+    tmpcfg.flags = 0;
178
+}
179
+
168 180
 static void cmd_toggle_giveback(BaseSequentialStream *chp, int argc, char *argv[])
169 181
 {
170 182
     (void) argv;
@@ -232,6 +244,7 @@ static const struct pdb_shell_cmd commands[] = {
232 244
     {"load", cmd_load, "Load the stored configuration into the buffer"},
233 245
     {"get_cfg", cmd_get_cfg, "Print the stored configuration"},
234 246
     {"get_tmpcfg", cmd_get_tmpcfg, "Print the configuration buffer"},
247
+    {"clear_flags", cmd_clear_flags, "Clear all flags"},
235 248
     {"toggle_giveback", cmd_toggle_giveback, "Toggle the GiveBack flag"},
236 249
     /* TODO {"toggle_var_bat", cmd_toggle_var_bat, "Toggle the Var/Bat flag"},*/
237 250
     {"set_v", cmd_set_v, "Set the voltage in millivolts"},

Ładowanie…
Anuluj
Zapisz