瀏覽代碼

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 7 年之前
父節點
當前提交
f42fd547af
共有 2 個文件被更改,包括 21 次插入1 次删除
  1. 8
    1
      docs/console_config.md
  2. 13
    0
      src/shell.c

+ 8
- 1
docs/console_config.md 查看文件

104
 Usage: `load`
104
 Usage: `load`
105
 
105
 
106
 Loads the current configuration from flash into the buffer.  Useful if you want
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
 ### get_cfg
110
 ### get_cfg
110
 
111
 
123
 
124
 
124
 Prints the contents of the configuration buffer.
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
 ### toggle_giveback
133
 ### toggle_giveback
127
 
134
 
128
 Usage: `toggle_giveback`
135
 Usage: `toggle_giveback`

+ 13
- 0
src/shell.c 查看文件

165
     pdb_config_print(chp, &tmpcfg);
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
 static void cmd_toggle_giveback(BaseSequentialStream *chp, int argc, char *argv[])
180
 static void cmd_toggle_giveback(BaseSequentialStream *chp, int argc, char *argv[])
169
 {
181
 {
170
     (void) argv;
182
     (void) argv;
232
     {"load", cmd_load, "Load the stored configuration into the buffer"},
244
     {"load", cmd_load, "Load the stored configuration into the buffer"},
233
     {"get_cfg", cmd_get_cfg, "Print the stored configuration"},
245
     {"get_cfg", cmd_get_cfg, "Print the stored configuration"},
234
     {"get_tmpcfg", cmd_get_tmpcfg, "Print the configuration buffer"},
246
     {"get_tmpcfg", cmd_get_tmpcfg, "Print the configuration buffer"},
247
+    {"clear_flags", cmd_clear_flags, "Clear all flags"},
235
     {"toggle_giveback", cmd_toggle_giveback, "Toggle the GiveBack flag"},
248
     {"toggle_giveback", cmd_toggle_giveback, "Toggle the GiveBack flag"},
236
     /* TODO {"toggle_var_bat", cmd_toggle_var_bat, "Toggle the Var/Bat flag"},*/
249
     /* TODO {"toggle_var_bat", cmd_toggle_var_bat, "Toggle the Var/Bat flag"},*/
237
     {"set_v", cmd_set_v, "Set the voltage in millivolts"},
250
     {"set_v", cmd_set_v, "Set the voltage in millivolts"},

Loading…
取消
儲存