From d966c960c13ae8375c09f7b9f5b9aab53891e607 Mon Sep 17 00:00:00 2001 From: thefenriswolf Date: Tue, 16 Mar 2021 18:03:37 +0100 Subject: [PATCH] wasptool: add --battery to check battery level Signed-off-by: thefenriswolf --- tools/wasptool | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/wasptool b/tools/wasptool index befcd98..ccca180 100755 --- a/tools/wasptool +++ b/tools/wasptool @@ -189,6 +189,9 @@ def handle_exec(c, fname): print_log(log) log.close() +def handle_battery_level(c): + print(f'Battery: {c.run_command("watch.battery.level()")}%') + def handle_memory_free(c): # wasp namespace to avoid having to import into the global space print(f'Before GC: {c.run_command("wasp.gc.mem_free()"):7}') @@ -329,6 +332,8 @@ if __name__ == '__main__': description='Wasp-os command and control client') parser.add_argument('--as', dest='upload_as', default=None, help="Filename to use on the target (e.g. wasptool --upload docs/main/chrono.py --as main.py") + parser.add_argument('--battery', action='store_true', + help="Report remaining battery charge") parser.add_argument('--bootloader', action='store_true', help="Reboot into the bootloader mode for OTA update") parser.add_argument('--binary', action='store_true', @@ -441,5 +446,8 @@ if __name__ == '__main__': if args.bootloader: handle_reset(console, ota=True) sys.exit(0) + + if args.battery: + handle_battery_level(console) console.unsync()