Browse Source

Support reading and writing the HV_Preferred flag

This commit adds the toggle_hv_preferred command, and makes printed
configuration objects show the state of the HV_Preferred flag.  The
flag still isn't used by anything else yet though.
Clara Hobbs 7 years ago
parent
commit
6f5d5f8021
2 changed files with 16 additions and 0 deletions
  1. 3
    0
      src/config.c
  2. 13
    0
      src/shell.c

+ 3
- 0
src/config.c View File

64
     if (cfg->flags & PDBS_CONFIG_FLAGS_VAR_BAT) {
64
     if (cfg->flags & PDBS_CONFIG_FLAGS_VAR_BAT) {
65
         chprintf(chp, "Var/Bat ");
65
         chprintf(chp, "Var/Bat ");
66
     }
66
     }
67
+    if (cfg->flags & PDBS_CONFIG_FLAGS_HV_PREFERRED) {
68
+        chprintf(chp, "HV_Preferred ");
69
+    }
67
     chprintf(chp, "\r\n");
70
     chprintf(chp, "\r\n");
68
 
71
 
69
     /* Print voltages and current */
72
     /* Print voltages and current */

+ 13
- 0
src/shell.c View File

274
     tmpcfg.flags ^= PDBS_CONFIG_FLAGS_GIVEBACK;
274
     tmpcfg.flags ^= PDBS_CONFIG_FLAGS_GIVEBACK;
275
 }
275
 }
276
 
276
 
277
+static void cmd_toggle_hv_preferred(BaseSequentialStream *chp, int argc, char *argv[])
278
+{
279
+    (void) argv;
280
+    if (argc > 0) {
281
+        chprintf(chp, "Usage: toggle_hv_preferred\r\n");
282
+        return;
283
+    }
284
+
285
+    /* Toggle the HV_Preferred flag */
286
+    tmpcfg.flags ^= PDBS_CONFIG_FLAGS_HV_PREFERRED;
287
+}
288
+
277
 static void cmd_set_v(BaseSequentialStream *chp, int argc, char *argv[])
289
 static void cmd_set_v(BaseSequentialStream *chp, int argc, char *argv[])
278
 {
290
 {
279
     if (argc != 1) {
291
     if (argc != 1) {
397
     {"get_tmpcfg", cmd_get_tmpcfg, "Print the configuration buffer"},
409
     {"get_tmpcfg", cmd_get_tmpcfg, "Print the configuration buffer"},
398
     {"clear_flags", cmd_clear_flags, "Clear all flags"},
410
     {"clear_flags", cmd_clear_flags, "Clear all flags"},
399
     {"toggle_giveback", cmd_toggle_giveback, "Toggle the GiveBack flag"},
411
     {"toggle_giveback", cmd_toggle_giveback, "Toggle the GiveBack flag"},
412
+    {"toggle_hv_preferred", cmd_toggle_hv_preferred, "Toggle the HV_Preferred flag"},
400
     /* TODO {"toggle_var_bat", cmd_toggle_var_bat, "Toggle the Var/Bat flag"},*/
413
     /* TODO {"toggle_var_bat", cmd_toggle_var_bat, "Toggle the Var/Bat flag"},*/
401
     {"set_v", cmd_set_v, "Set the voltage in millivolts"},
414
     {"set_v", cmd_set_v, "Set the voltage in millivolts"},
402
     {"set_i", cmd_set_i, "Set the current in milliamps"},
415
     {"set_i", cmd_set_i, "Set the current in milliamps"},

Loading…
Cancel
Save