From 161add37e2a9fc6c0d25b0e3c3ca267a14eeb62d Mon Sep 17 00:00:00 2001 From: g-man Date: Wed, 4 Dec 2024 14:48:49 +0900 Subject: [PATCH] Update add set-battery-saving command --- README.md | 8 ++++++++ whill/whill.py | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index abcc27a..061be77 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,14 @@ Turn on/off a WHILL. `power_state_command` is a bool with `True` to power WHILL ``` Enable/Disable power supply to the interface connector. `True` to enable power supply. **For Model CR only.** +```python +.set_battery_saving(low_battery_level=, sounds_buzzer=) +``` +Configure battery protection settings. **For Model CR2 only.** +`low_battery_level` is battery charge level to engage the standby mode with range 1 ~ 90. +`sounds_buzzer` is Enable/Disable a buzzing sound at the battery charge level of `low_battery_level` + 10 percentage points. `True` to enable a buzzing sound when battery level low. +As default, `low_battery_level` is 19 and `sounds_buzzer` is True. + ### Motor Control ```python .send_joystick(front=, side=) diff --git a/whill/whill.py b/whill/whill.py index 3714a2e..38a0baa 100644 --- a/whill/whill.py +++ b/whill/whill.py @@ -21,7 +21,7 @@ class CommandID(IntEnum): SET_JOYSTICK = auto() SET_SPEED_PROFILE = auto() SET_BATTERY_VOLTAGE_OUT = auto() - RESERVE_1 = auto() + SET_BATTERY_SAVING = auto() RESERVE_2 = auto() SET_VELOCITY = auto() @@ -39,6 +39,7 @@ class PowerCommand(IntEnum): CommandID.SET_JOYSTICK: 4, CommandID.SET_SPEED_PROFILE: 11, CommandID.SET_BATTERY_VOLTAGE_OUT: 2, + CommandID.SET_BATTERY_SAVING: 3, CommandID.SET_VELOCITY: 6, } @@ -221,6 +222,10 @@ def set_battery_voltage_output_mode(self, vbatt_on_off): command_bytes = [self.CommandID.SET_BATTERY_VOLTAGE_OUT, vbatt_on_off] return self.send_command(command_bytes) + def set_battery_saving(self, low_battery_level=19, sounds_buzzer=True): + command_bytes = [self.CommandID.SET_BATTERY_SAVING, low_battery_level, sounds_buzzer] + return self.send_command(command_bytes) + def hold_joy_core(self, front, side, timeout=1000): while self.__timeout_count < timeout: if self.__stop_event.is_set():