Преглед изворни кода

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 година
родитељ
комит
6f5d5f8021
2 измењених фајлова са 16 додато и 0 уклоњено
  1. 3
    0
      src/config.c
  2. 13
    0
      src/shell.c

+ 3
- 0
src/config.c Прегледај датотеку

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

+ 13
- 0
src/shell.c Прегледај датотеку

@@ -274,6 +274,18 @@ static void cmd_toggle_giveback(BaseSequentialStream *chp, int argc, char *argv[
274 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 289
 static void cmd_set_v(BaseSequentialStream *chp, int argc, char *argv[])
278 290
 {
279 291
     if (argc != 1) {
@@ -397,6 +409,7 @@ static const struct pdbs_shell_cmd commands[] = {
397 409
     {"get_tmpcfg", cmd_get_tmpcfg, "Print the configuration buffer"},
398 410
     {"clear_flags", cmd_clear_flags, "Clear all flags"},
399 411
     {"toggle_giveback", cmd_toggle_giveback, "Toggle the GiveBack flag"},
412
+    {"toggle_hv_preferred", cmd_toggle_hv_preferred, "Toggle the HV_Preferred flag"},
400 413
     /* TODO {"toggle_var_bat", cmd_toggle_var_bat, "Toggle the Var/Bat flag"},*/
401 414
     {"set_v", cmd_set_v, "Set the voltage in millivolts"},
402 415
     {"set_i", cmd_set_i, "Set the current in milliamps"},

Loading…
Откажи
Сачувај