@@ -107,7 +107,7 @@ def handle_chg_limit_enable(switch):
107107 )
108108 except ec_exceptions .ECError as e :
109109 if e .ec_status == ec_exceptions .EcStatus .EC_RES_INVALID_COMMAND :
110- app .no_support .append (ec_commands .framework_laptop .EC_CMD_CHARGE_LIMIT )
110+ app .no_support .append (ec_commands .framework_laptop .EC_CMD_CHARGE_LIMIT_CONTROL )
111111 self .chg_limit_enable .set_sensitive (False )
112112 else :
113113 raise e
@@ -186,31 +186,47 @@ def handle_extender_enable(switch):
186186 )
187187
188188 def _update_battery (self , app ):
189- if ec_commands .framework_laptop .EC_CMD_BATTERY_EXTENDER in app .no_support :
190- return False
189+ success = False
191190
192- try :
193- ec_extender = ec_commands .framework_laptop .get_battery_extender (
194- app .cros_ec
195- )
191+ # Charge Limiter
192+ if not ec_commands .framework_laptop .EC_CMD_CHARGE_LIMIT_CONTROL in app .no_support :
193+ try :
194+ ec_limit = ec_commands .framework_laptop .get_charge_limit (app .cros_ec )
195+ self .chg_limit_label .set_label (f"{ ec_limit [0 ]} %" )
196+ self .bat_limit_label .set_label (f"{ ec_limit [1 ]} %" )
196197
197- self .bat_ext_stage .set_subtitle (str (ec_extender ["current_stage" ]))
198- self .bat_ext_trigger_time .set_subtitle (
199- format_timedelta (ec_extender ["trigger_timedelta" ])
200- )
201- self .bat_ext_reset_time .set_subtitle (
202- format_timedelta (ec_extender ["reset_timedelta" ])
203- )
204- except ec_exceptions .ECError as e :
205- if e .ec_status == ec_exceptions .EcStatus .EC_RES_INVALID_COMMAND :
206- app .no_support .append (
207- ec_commands .framework_laptop .EC_CMD_BATTERY_EXTENDER
198+ success = True
199+ except ec_exceptions .ECError as e :
200+ if e .ec_status == ec_exceptions .EcStatus .EC_RES_INVALID_COMMAND :
201+ app .no_support .append (ec_commands .framework_laptop .EC_CMD_CHARGE_LIMIT_CONTROL )
202+ else :
203+ raise e
204+
205+ # Battery Extender
206+ if not ec_commands .framework_laptop .EC_CMD_BATTERY_EXTENDER in app .no_support :
207+ try :
208+ ec_extender = ec_commands .framework_laptop .get_battery_extender (
209+ app .cros_ec
208210 )
209- return False
210- else :
211- raise e
212211
213- return app .current_page == 2
212+ self .bat_ext_stage .set_subtitle (str (ec_extender ["current_stage" ]))
213+ self .bat_ext_trigger_time .set_subtitle (
214+ format_timedelta (ec_extender ["trigger_timedelta" ])
215+ )
216+ self .bat_ext_reset_time .set_subtitle (
217+ format_timedelta (ec_extender ["reset_timedelta" ])
218+ )
219+
220+ success = True
221+ except ec_exceptions .ECError as e :
222+ if e .ec_status == ec_exceptions .EcStatus .EC_RES_INVALID_COMMAND :
223+ app .no_support .append (
224+ ec_commands .framework_laptop .EC_CMD_BATTERY_EXTENDER
225+ )
226+ else :
227+ raise e
228+
229+ return app .current_page == 2 and success
214230
215231def format_timedelta (timedelta ):
216232 days = f"{ timedelta .days } days, " if timedelta .days else ""
0 commit comments