Skip to content

Commit

Permalink
Adaptation for charging function being off by default. (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihuanhuan authored Jun 7, 2024
1 parent dcb3708 commit 1337282
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
19 changes: 5 additions & 14 deletions core/src/trezor/uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,11 @@ def ctrl_charge_switch(enable: bool) -> None:
@param enable: True to open, False to close
"""
if enable:
if not utils.CHARGE_ENABLE:
if utils.CHARGE_ENABLE is None or not utils.CHARGE_ENABLE:
BLE_CTRL.ctrl(0x82, b"\x06")
utils.CHARGE_ENABLE = True
else:
if utils.CHARGE_ENABLE:
if utils.CHARGE_ENABLE is None or utils.CHARGE_ENABLE:
BLE_CTRL.ctrl(0x82, b"\x07")
utils.CHARGE_ENABLE = False

Expand All @@ -634,15 +634,6 @@ def ctrl_wireless_charge(enable: bool) -> None:
"""Request to open or close charge.
@param enable: True to open, False to close
"""
if enable:
if (
utils.CHARGE_WIRELESS_STATUS != utils.CHARGE_WIRELESS_STOP
and not utils.CHARGE_ENABLE
):
ctrl_charge_switch(True)
else:
if (
utils.CHARGE_WIRELESS_STATUS != utils.CHARGE_WIRELESS_STOP
and utils.CHARGE_ENABLE
):
ctrl_charge_switch(False)
if utils.CHARGE_WIRELESS_STATUS == utils.CHARGE_WIRELESS_STOP:
return
ctrl_charge_switch(enable)
2 changes: 1 addition & 1 deletion core/src/trezor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def board_version() -> str:
CHARGE_WIRELESS_START = const(1)
CHARGE_WIRELESS_CHARGING = const(2)
CHARGE_WIRELESS_STATUS = CHARGE_WIRELESS_STOP
CHARGE_ENABLE = True
CHARGE_ENABLE: bool | None = None
CHARGING = False

if __debug__:
Expand Down

0 comments on commit 1337282

Please sign in to comment.