From f05129d92aa4f4a3a662d248825923dcbc4158fb Mon Sep 17 00:00:00 2001 From: lich0 Date: Sun, 28 Apr 2024 16:51:16 +0800 Subject: [PATCH] fix_temp --- ChargeLimiter/main.mm | 30 +++++++- Readme.md | 12 +-- www/float.html | 29 ++++---- www/help_en.md | 6 +- www/help_zh_CN.md | 6 +- www/index.html | 68 +++++++++++------ www/js/app.js | 169 ++++++++++++++++++++++++++++++++++++------ www/js/float.js | 13 +++- www/js/history.js | 101 +++++++++++++++++++------ www/js/utils.js | 3 + 10 files changed, 338 insertions(+), 99 deletions(-) diff --git a/ChargeLimiter/main.mm b/ChargeLimiter/main.mm index e379bc7..ca26196 100644 --- a/ChargeLimiter/main.mm +++ b/ChargeLimiter/main.mm @@ -445,6 +445,19 @@ static void onBatteryEventEnd() { } } +static float getTempAsC(NSString* key) { + NSNumber* temp_mode = getlocalKV(@"temp_mode"); + NSNumber* temp = getlocalKV(key); + float temp_c = temp.intValue / 100.0; + if (temp_mode.intValue == 0) { // °C + return temp_c; + } else if (temp_mode.intValue == 1) { // °F + float temp_f = (temp_c - 32) / 1.8; + return temp_f; + } + return 0; +} + static void onBatteryEvent(io_service_t serv) { @autoreleasepool { NSDictionary* old_bat_info = bat_info; @@ -459,14 +472,14 @@ static void onBatteryEvent(io_service_t serv) { NSNumber* charge_below = getlocalKV(@"charge_below"); NSNumber* charge_above = getlocalKV(@"charge_above"); NSNumber* enable_temp = getlocalKV(@"enable_temp"); - NSNumber* charge_temp_above = getlocalKV(@"charge_temp_above"); - NSNumber* charge_temp_below = getlocalKV(@"charge_temp_below"); NSNumber* capacity = bat_info[@"CurrentCapacity"]; NSNumber* is_charging = bat_info[@"IsCharging"]; NSNumber* is_inflow_enabled = bat_info[@"ExternalConnected"]; BOOL is_adaptor_connected = isAdaptorConnect(bat_info); NSNumber* adv_disable_inflow = getlocalKV(@"adv_disable_inflow"); NSNumber* temperature_ = bat_info[@"Temperature"]; + float charge_temp_above = getTempAsC(@"charge_temp_above"); + float charge_temp_below = getTempAsC(@"charge_temp_below"); float temperature = temperature_.intValue / 100.0; // 优先级: 电量极低 > 停充(电量>温度) > 充电(电量>温度) > 插电 do { @@ -493,7 +506,7 @@ static void onBatteryEvent(io_service_t serv) { } break; } - if (enable_temp.boolValue && temperature >= charge_temp_above.intValue) { // 停充-温度高,优先级=3 + if (enable_temp.boolValue && temperature >= charge_temp_above) { // 停充-温度高,优先级=3 if (is_charging.boolValue) { NSFileLog(@"stop charging for high temperature"); setBatteryStatus(NO); @@ -523,7 +536,7 @@ static void onBatteryEvent(io_service_t serv) { break; } if ([mode isEqualToString:@"charge_on_plug"]) { - if (enable_temp.boolValue && temperature <= charge_temp_below.intValue) { // 充电-温度低,优先级=5 + if (enable_temp.boolValue && temperature <= charge_temp_below) { // 充电-温度低,优先级=5 if (is_adaptor_connected) { if (adv_disable_inflow.boolValue && !is_inflow_enabled.boolValue) { NSFileLog(@"enable inflow for low temperature"); @@ -579,6 +592,7 @@ static void initConf(BOOL reset) { @"charge_below": @20, @"charge_above": @80, @"enable_temp": @NO, + @"temp_mode": @0, @"charge_temp_above": @35, @"charge_temp_below": @10, @"acc_charge": @NO, @@ -715,6 +729,14 @@ static void showFloatwnd(BOOL flag) { }); } else if ([key isEqualToString:@"adv_def_thermal_mode"]) { setThermalSimulationMode(val); + } else if ([key isEqualToString:@"temp_mode"]) { + NSLog(@"%@ aa1", log_prefix); + NSArray* vals = nsreq[@"vals"]; + if (vals != nil && vals.count >= 2) { + NSLog(@"%@ aa1 %@ %@", log_prefix, vals[0], vals[1]); + setlocalKV(@"charge_temp_below", vals[0]); + setlocalKV(@"charge_temp_above", vals[1]); + } } return @{ @"status": @0, diff --git a/Readme.md b/Readme.md index 389d20e..53c3a73 100644 --- a/Readme.md +++ b/Readme.md @@ -37,6 +37,7 @@ CL支持第三方电池吗? 为什么手机用一会不充电了?(小白经常遇到的问题) * CL并非傻瓜式工具,如果开启了温控请根据实际情况调整温度上下限,否则到达上限会停止充电,下限又无法达到自然无法充电. * CL的设计思路就是减少充电次数,因此不会连着usb就充电,充电/停充都有触发条件,请仔细查看本页说明. +* 电池由于老化严重健康度低,刚启动系统时可以使用CL,一段时间后CL再也无法控制充电/停充.此种情况无法使用CL. CL可以不依赖越狱或巨魔类工具吗? * CL需要用到私有API所以无法上架. @@ -50,9 +51,10 @@ CL可以不依赖越狱或巨魔类工具吗? ## 测试电池兼容性   在使用CL前需要测试电池兼容性,如果不支持请放弃使用 -* 1.测试电池是否支持停充.关闭CL全局开关,在“正在充电”按钮开启的状态下,手动关闭之,若120秒内按钮有反应则电池支持停充,但如果停充后有较大持续电池电流(>=5mA)则无法支持停充(有些电池返回电池电流值有误,此时以实际电量变化为准). +* 1.测试电池是否支持停充.关闭CL全局开关,关闭"高级"中所有选项,在“正在充电”按钮开启的状态下,手动关闭之,若120秒内按钮有反应则电池支持停充,但如果停充后有较大持续电池电流(>=5mA)则无法支持停充(有些电池返回电池电流值有误,此时以实际电量变化为准). * 2.测试电池是否支持智能停充.开启"高级-智能停充",其余同1. -* 3,测试电池是否支持禁流.关闭CL全局开关,在“电源已连接”按钮开启的状态下,手动关闭之,若120秒内按钮有反应则电池支持禁流,但如果禁流后有较大持续电流(>=5mA)则无法支持禁流(有些电池返回电池电流值有误,此时以实际电量变化为准). +* 3.测试电池是否支持禁流.关闭CL全局开关,在“电源已连接”按钮开启的状态下,手动关闭之,若120秒内按钮有反应则电池支持禁流,但如果禁流后有较大持续电流(>=5mA)则无法支持禁流(有些电池返回电池电流值有误,此时以实际电量变化为准). +* 有的电池因为老化而健康度过低,会出现刚重启系统时可以使用上述方式停充但过一段时间就再也无法停充,这种电池也无法被CL所兼容. * 若电池既不支持停充也不支持禁流则永远不被CL支持. * 如果使用CL过程中,健康度以不正常的方式下降,请自行调整高级菜单中的选项或卸载CL. @@ -323,6 +325,7 @@ Will the battery health percentage increase after using CL for a period of time? Why does my iPhone won't charge any more after using for a while(Most questions from freshman)? * CL is not a fully-automatic tool, please set the threshhold carefully according to the actual temperature if temperature control is enabled, or CL will surely stop charging and won't re-charge any more. * CL is designed to minimize the charging count, so it won't start charging or recover charging for connecting to a power source in "Plug and charge" mode, but will start charging for re-connecting to a power source. +* There are a few cases of battery with low health cause this problem. In this case, CL can contorl charge/discharge normally after a system reboot, but will fail to control after tens of minutes. CL is unavailable for this kind of battery. Is it possible to install CL without Jailbreak or TrollStore(-like) environment? * Private api is used in CL, so it is impossible to be published to Appstore. @@ -335,12 +338,11 @@ How to cool down the battery in summer? ## Compatibility -关闭全局开关 - Please test battery compatibility before using CL, stop and uninstall CL if unsupported -* 1.Check compatibility of ChargeInhibit. Disable CL by toggling the "Enable" button first, then disable charging by toggling the "Charging" button, any change within 120 seconds means ChargeInhibit is supported, unless the InstantAmperage keep above 5mA after being disabled.(InstantAmperage may be invalid for a few kinds of batteries, in this case take a look at capacity increasement) +* 1.Check compatibility of ChargeInhibit. Disable CL by toggling the "Enable" button first, and disable all options in "Advanced", then disable charging by toggling the "Charging" button, any change within 120 seconds means ChargeInhibit is supported, unless the InstantAmperage keep above 5mA after being disabled.(InstantAmperage may be invalid for a few kinds of batteries, in this case take a look at capacity increasement) * 2.Check compatibility of PredictiveChargingInhibit. Enable it from "Advanced-Predictive charging inhibit", then follow steps in '1'. * 3.Check compatibility of DisableInflow. Disable CL by toggling the "Enable" button first, then disable inflow by toggling the "External connected" button when it is enabled, any change within 120 seconds means DisableInflow is supported, unless the InstantAmperage keep above 5mA after being disabled.(InstantAmperage may be invalid for a few kinds of batteries, in this case take a look at capacity increasement) +* There are a few cases of battery with low health prevent CL from working well. In this case, CL can contorl charge/discharge normally after a system reboot, but will fail to control after tens of minutes. CL is unavailable for this kind of battery. * The battery will never be supported by CL if neither ChargeInhibit nor DisableInflow is supported. * If the health of battery keep dropping abnormally while using CL, please adjust the configuration in Advanced menu, or just uninstall CL. diff --git a/www/float.html b/www/float.html index 07872e7..d6ed664 100644 --- a/www/float.html +++ b/www/float.html @@ -43,8 +43,9 @@ margin-bottom: 0; } - .tip-line { - height: 12px; + .el-row, i, span { + top: -5px; + height: 12px !important; } .thermometer { @@ -75,12 +76,14 @@ font-size: 12px; } - .spinner { + .ban { + font-size: 12; margin-top: 5px; + margin-left: 10px; } #app { - padding-left: 10px; + padding-left: 5px; background-color:white; border-radius: 15px; opacity: 0.5; @@ -89,14 +92,14 @@
-
- -
-
- +
+
+ +
diff --git a/www/help_en.md b/www/help_en.md index 4df5876..d199835 100644 --- a/www/help_en.md +++ b/www/help_en.md @@ -30,6 +30,7 @@ Will the battery health percentage increase after using CL for a period of time? Why does my iPhone won't charge any more after using for a while(Most questions from freshman)? * CL is not a fully-automatic tool, please set the threshhold carefully according to the actual temperature if temperature control is enabled, or CL will surely stop charging and won't re-charge any more. * CL is designed to minimize the charging count, so it won't start charging or recover charging for connecting to a power source in "Plug and charge" mode, but will start charging for re-connecting to a power source. +* There are a few cases of battery with low health cause this problem. In this case, CL can contorl charge/discharge normally after a system reboot, but will fail to control after tens of minutes. CL is unavailable for this kind of battery. Is it possible to install CL without Jailbreak or TrollStore(-like) environment? * Private api is used in CL, so it is impossible to be published to Appstore. @@ -43,9 +44,10 @@ How to cool down the battery in summer? ## Compatibility Please test battery compatibility before using CL, stop and uninstall CL if unsupported -* 1.Check compatibility of ChargeInhibit. Disable CL by toggling the "Enable" button first, then disable charging by toggling the "Charging" button, any change within 120 seconds means ChargeInhibit is supported, unless the InstantAmperage keep above 5mA after being disabled.(InstantAmperage may be invalid for a few kinds of batteries, in this case take a look at capacity increasement) +* 1.Check compatibility of ChargeInhibit. Disable CL by toggling the "Enable" button first, and disable all options in "Advanced", then disable charging by toggling the "Charging" button, any change within 120 seconds means ChargeInhibit is supported, unless the InstantAmperage keep above 5mA after being disabled.(InstantAmperage may be invalid for a few kinds of batteries, in this case take a look at capacity increasement) * 2.Check compatibility of PredictiveChargingInhibit. Enable it from "Advanced-Predictive charging inhibit", then follow steps in '1'. * 3.Check compatibility of DisableInflow. Disable CL by toggling the "Enable" button first, then disable inflow by toggling the "External connected" button when it is enabled, any change within 120 seconds means DisableInflow is supported, unless the InstantAmperage keep above 5mA after being disabled.(InstantAmperage may be invalid for a few kinds of batteries, in this case take a look at capacity increasement) +* There are a few cases of battery with low health prevent CL from working well. In this case, CL can contorl charge/discharge normally after a system reboot, but will fail to control after tens of minutes. CL is unavailable for this kind of battery. * The battery will never be supported by CL if neither ChargeInhibit nor DisableInflow is supported. * If the health of battery keep dropping abnormally while using CL, please adjust the configuration in Advanced menu, or just uninstall CL. @@ -204,7 +206,7 @@ curl http://localhost:1230 -d '{"api":"get_conf","key":"enable"}' -H "content-ty |request |type |description | |------------|-----------|--------------------------------| -|api |string |get_bat_info | +|api |string |get_bat_info | |response | | | |status |integer |0:成功 | |data | |数据 | diff --git a/www/help_zh_CN.md b/www/help_zh_CN.md index 636e516..f82e725 100644 --- a/www/help_zh_CN.md +++ b/www/help_zh_CN.md @@ -27,6 +27,7 @@ CL支持第三方电池吗? 为什么手机用一会不充电了?(小白经常遇到的问题) * CL并非傻瓜式工具,如果开启了温控请根据实际情况调整温度上下限,否则到达上限会停止充电,下限又无法达到自然无法充电. * CL的设计思路就是减少充电次数,因此不会连着usb就充电,充电/停充都有触发条件,请仔细查看本页说明. +* 电池由于老化严重健康度低,刚启动系统时可以使用CL,一段时间后CL再也无法控制充电/停充.此种情况无法使用CL. CL可以不依赖越狱或巨魔类工具吗? * CL需要用到私有API所以无法上架. @@ -40,9 +41,10 @@ CL可以不依赖越狱或巨魔类工具吗? ## 测试电池兼容性   在使用CL前需要测试电池兼容性,如果不支持请放弃使用 -* 1.测试电池是否支持停充.关闭CL全局开关,在“正在充电”按钮开启的状态下,手动关闭之,若120秒内按钮有反应则电池支持停充,但如果停充后有较大持续电池电流(>=5mA)则无法支持停充(有些电池返回电池电流值有误,此时以实际电量变化为准). +* 1.测试电池是否支持停充.关闭CL全局开关,关闭"高级"中所有选项,在“正在充电”按钮开启的状态下,手动关闭之,若120秒内按钮有反应则电池支持停充,但如果停充后有较大持续电池电流(>=5mA)则无法支持停充(有些电池返回电池电流值有误,此时以实际电量变化为准). * 2.测试电池是否支持智能停充.开启"高级-智能停充",其余同1. * 3.测试电池是否支持禁流.关闭CL全局开关,在“电源已连接”按钮开启的状态下,手动关闭之,若120秒内按钮有反应则电池支持禁流,但如果禁流后有较大持续电流(>=5mA)则无法支持禁流(有些电池返回电池电流值有误,此时以实际电量变化为准). +* 有的电池因为老化而健康度过低,会出现刚重启系统时可以使用上述方式停充但过一段时间就再也无法停充,这种电池也无法被CL所兼容. * 若电池既不支持停充也不支持禁流则永远不被CL支持. * 如果使用CL过程中,健康度以不正常的方式下降,请自行调整高级菜单中的选项或卸载CL. @@ -207,7 +209,7 @@ curl http://localhost:1230 -d '{"api":"get_conf","key":"enable"}' -H "content-ty |请求 |类型 |描述 | |------------|-----------|--------------------------------| -|api |字符串 |get_bat_info | +|api |字符串 |get_bat_info | |响应 | | | |status |整型 |0:成功 | |data | |数据 | diff --git a/www/index.html b/www/index.html index 23fab50..d414ab9 100755 --- a/www/index.html +++ b/www/index.html @@ -189,6 +189,19 @@ .el-slider__marks-text { font-size: 8px !important; } + + .el-slider__runway { + margin-top: 0; + margin-bottom: 0; + } + + .el-slider { + padding-bottom: 20px; + } + + .temp-icon { + padding: 3px 5px 3px 5px; + } @@ -273,60 +286,73 @@ - + {{$t("start_charge")}} - {{$t("CurrentCapacity")}} ≤ + {{$t("Capacity")}}(%) ≤ - + - - % + + + + - + {{$t("stop_charge")}} - {{$t("CurrentCapacity")}} ≥ + {{$t("Capacity")}}(%) ≥ - + - - % + + + + {{$t("temp_ctrl")}} + {{temp_unit}}
@@ -438,7 +464,7 @@