Skip to content

Commit

Permalink
Merge pull request #11 from WHILL/feature/add_set_battery_saving
Browse files Browse the repository at this point in the history
Update add set-battery-saving command
  • Loading branch information
GeorgeMandokoro authored Dec 4, 2024
2 parents 2aca5e6 + 161add3 commit 14e4cd0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<your_obj_name>.set_battery_saving(low_battery_level=<Integer -100~100>, sounds_buzzer=<True/False>)
```
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
<your_obj_name>.send_joystick(front=<Integer -100~100>, side=<Integer -100~100>)
Expand Down
7 changes: 6 additions & 1 deletion whill/whill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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,
}

Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 14e4cd0

Please sign in to comment.