fix
This commit is contained in:
parent
a3f6b75cba
commit
e1fa90e221
@ -1,10 +1,12 @@
|
|||||||
_________
|
▒█████ ██▓███ ▓█████ ███▄ █ █ █░ ██▀███ ▄▄▄█████▓
|
||||||
/ /\ _ ___ ___ ___
|
▒██▒ ██▒▓██░ ██▒▓█ ▀ ██ ▀█ █ ▓█░ █ ░█░▓██ ▒ ██▒▓ ██▒ ▓▒
|
||||||
/ LE / \ | | | __| \| __|
|
▒██░ ██▒▓██░ ██▓▒▒███ ▓██ ▀█ ██▒▒█░ █ ░█ ▓██ ░▄█ ▒▒ ▓██░ ▒░
|
||||||
/ DE / \ | |__| _|| |) | _|
|
▒██ ██░▒██▄█▓▒ ▒▒▓█ ▄ ▓██▒ ▐▌██▒░█░ █ ░█ ▒██▀▀█▄ ░ ▓██▓ ░
|
||||||
/________/ LE \ |____|___|___/|___|
|
░ ████▓▒░▒██▒ ░ ░░▒████▒▒██░ ▓██░░░██▒██▓ ░██▓ ▒██▒ ▒██▒ ░
|
||||||
\ \ DE /
|
░ ▒░▒░▒░ ▒▓▒░ ░ ░░░ ▒░ ░░ ▒░ ▒ ▒ ░ ▓░▒ ▒ ░ ▒▓ ░▒▓░ ▒ ░░
|
||||||
\ LE \ / -------------------------------------------
|
░ ▒ ▒░ ░▒ ░ ░ ░ ░░ ░░ ░ ▒░ ▒ ░ ░ ░▒ ░ ▒░ ░
|
||||||
\ DE \ / %D %V, %C
|
░ ░ ░ ▒ ░░ ░ ░ ░ ░ ░ ░ ░░ ░ ░
|
||||||
\________\/ -------------------------------------------
|
░ ░ ░ ░ ░ ░ ░
|
||||||
|
-------------------------------------------------------------
|
||||||
|
%D %V, %C
|
||||||
|
-------------------------------------------------------------
|
||||||
|
@ -51,7 +51,7 @@ sed -i '/option disabled/d' /etc/config/wireless
|
|||||||
sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh
|
sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh
|
||||||
|
|
||||||
sed -i '/DISTRIB_REVISION/d' /etc/openwrt_release
|
sed -i '/DISTRIB_REVISION/d' /etc/openwrt_release
|
||||||
echo "DISTRIB_REVISION='R24.7.7'" >> /etc/openwrt_release
|
echo "DISTRIB_REVISION='R24.7.22-D'" >> /etc/openwrt_release
|
||||||
sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release
|
sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release
|
||||||
echo "DISTRIB_DESCRIPTION='OpenWrt '" >> /etc/openwrt_release
|
echo "DISTRIB_DESCRIPTION='OpenWrt '" >> /etc/openwrt_release
|
||||||
|
|
||||||
|
22
package/lean/luci-app-fan/Makefile
Normal file
22
package/lean/luci-app-fan/Makefile
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Copyright (C) 2016 Openwrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
LUCI_TITLE:=LuCI fan control
|
||||||
|
LUCI_DEPENDS:=+coreutils-stat
|
||||||
|
LUCI_PKGARCH:=all
|
||||||
|
PKG_VERSION:=1.0.0-3
|
||||||
|
PKG_RELEASE:=
|
||||||
|
PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com>
|
||||||
|
|
||||||
|
define Package/luci-app-fan/conffiles
|
||||||
|
/etc/config/luci-fan
|
||||||
|
endef
|
||||||
|
|
||||||
|
include $(TOPDIR)/feeds/luci/luci.mk
|
||||||
|
|
||||||
|
# call BuildPackage - OpenWrt buildroot signature
|
||||||
|
|
@ -0,0 +1,38 @@
|
|||||||
|
--[[
|
||||||
|
LuCI - Lua Configuration Interface
|
||||||
|
Copyright 2023 jjm2473
|
||||||
|
]]--
|
||||||
|
|
||||||
|
module("luci.controller.admin.luci-fan", package.seeall)
|
||||||
|
|
||||||
|
function index()
|
||||||
|
require "luci.sys"
|
||||||
|
local appname = "luci-fan"
|
||||||
|
local defaultpage = nil
|
||||||
|
if luci.sys.call("/usr/libexec/fan-control get >/dev/null 2>&1") == 0 then
|
||||||
|
entry({"admin", "system", appname}, cbi("luci-fan"), _("Fan Control"), 60)
|
||||||
|
else
|
||||||
|
entry({"admin", "system", appname}).dependent = true
|
||||||
|
end
|
||||||
|
entry({"admin", "system", appname, "get_fan_info"}, call("get_fan_info"), nil).leaf = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_fan_info(zone, trip)
|
||||||
|
require "luci.util"
|
||||||
|
local words
|
||||||
|
if zone and trip and string.match(zone, "^thermal_zone%d+$") and string.match(trip, "^%d+$") then
|
||||||
|
local fs = require "nixio.fs"
|
||||||
|
words = {
|
||||||
|
luci.util.trim(fs.readfile("/sys/class/thermal/"..zone.."/temp")),
|
||||||
|
luci.util.trim(fs.readfile("/sys/class/thermal/"..zone.."/trip_point_"..trip.."_temp"))
|
||||||
|
}
|
||||||
|
else
|
||||||
|
local sys = require "luci.sys"
|
||||||
|
words = luci.util.split(luci.util.trim(sys.exec("/usr/libexec/fan-control temp 2>/dev/null")), " ")
|
||||||
|
end
|
||||||
|
local zone_temp = tonumber(words[1]) / 1000; -- ˚C
|
||||||
|
local fan_on_temp = tonumber(words[2]) / 1000; -- ˚C
|
||||||
|
luci.http.status(200, "ok")
|
||||||
|
luci.http.prepare_content("application/json")
|
||||||
|
luci.http.write_json({zone_temp=zone_temp, fan_on_temp=fan_on_temp})
|
||||||
|
end
|
93
package/lean/luci-app-fan/luasrc/model/cbi/luci-fan.lua
Normal file
93
package/lean/luci-app-fan/luasrc/model/cbi/luci-fan.lua
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
--[[
|
||||||
|
LuCI - Lua Configuration Interface
|
||||||
|
Copyright 2023 jjm2473
|
||||||
|
]]--
|
||||||
|
|
||||||
|
local m, s, o
|
||||||
|
require "luci.util"
|
||||||
|
|
||||||
|
local fs = require "nixio.fs"
|
||||||
|
|
||||||
|
local sys = require "luci.sys"
|
||||||
|
|
||||||
|
local words = luci.util.split(luci.util.trim(sys.exec("/usr/libexec/fan-control get 2>/dev/null")), " ")
|
||||||
|
|
||||||
|
if #words < 3 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
m = Map("luci-fan", translate("Fan Control"), translate("Control fan start and stop temperature. This plugin can only configure the lowest gear, not necessarily applicable to all devices."))
|
||||||
|
|
||||||
|
s = m:section(SimpleSection)
|
||||||
|
s.template = "luci-fan"
|
||||||
|
s.thermal_zone = words[1]
|
||||||
|
s.trip_point = words[2]
|
||||||
|
s.thermal_type = luci.util.trim(fs.readfile("/sys/class/thermal/"..words[1].."/type"))
|
||||||
|
|
||||||
|
s = m:section(TypedSection, "luci-fan", translate("Fan Settings"))
|
||||||
|
s.addremove = false
|
||||||
|
s.anonymous = true
|
||||||
|
|
||||||
|
o = s:option(Flag, "enabled", translate("Enabled"), translate("Whether to apply the settings"))
|
||||||
|
o.default = 0
|
||||||
|
|
||||||
|
local on_temp = s:option(Value, "on_temp", translate("Fan start temperature") .. " (℃)")
|
||||||
|
on_temp.datatype = "and(uinteger,min(5))"
|
||||||
|
on_temp.rmempty = false
|
||||||
|
on_temp.default = math.floor(tonumber(words[3])/1000)
|
||||||
|
if #words > 3 then
|
||||||
|
on_temp.datatype = string.format("and(uinteger,range(5,%u))", math.floor(tonumber(words[4])/1000 - 1))
|
||||||
|
end
|
||||||
|
|
||||||
|
o = s:option(Value, "off_temp", translate("Fan stop temperature") .. " (℃)", translate("Optional, MUST be lower than the fan start temperature. Default fan start temperature minus 5 ℃"))
|
||||||
|
o.datatype = "uinteger"
|
||||||
|
o.rmempty = true
|
||||||
|
function o.parse(self, section, novld)
|
||||||
|
local fvalue = self:formvalue(section)
|
||||||
|
local fexist = ( fvalue and (#fvalue > 0) ) -- not "nil" and "not empty"
|
||||||
|
|
||||||
|
local vvalue, errtxt = self:validate(fvalue)
|
||||||
|
if not vvalue then
|
||||||
|
if novld then -- and "novld" set
|
||||||
|
return -- then exit without raising an error
|
||||||
|
end
|
||||||
|
if fexist then -- and there is a formvalue
|
||||||
|
self:add_error(section, "invalid", errtxt or self.title .. ": invalid")
|
||||||
|
return -- so data are invalid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local rm_opt = ( self.rmempty or self.optional )
|
||||||
|
local vexist = ( vvalue and (#vvalue > 0) ) and true or false -- not "nil" and "not empty"
|
||||||
|
local eq_def = ( vvalue == self.default ) -- equal_default flag
|
||||||
|
-- (rmempty or optional) and (no data or equal_default)
|
||||||
|
if rm_opt and (not vexist or eq_def) then
|
||||||
|
if self:remove(section) then -- remove data from UCI
|
||||||
|
self.section.changed = true -- and push events
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cvalue = self:cfgvalue(section)
|
||||||
|
local eq_cfg = ( vvalue == cvalue ) -- update equal_config flag
|
||||||
|
-- not forcewrite and no changes, so nothing to write
|
||||||
|
if not self.forcewrite and eq_cfg then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local onvalue = on_temp:validate(on_temp:formvalue(section))
|
||||||
|
if onvalue and #onvalue > 0 then
|
||||||
|
if tonumber(vvalue) >= tonumber(onvalue) then
|
||||||
|
self:add_error(section, "invalid", translate("Fan stop temperature MUST be lower than fan start temperature"))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- write data to UCI; raise event only on changes
|
||||||
|
if self:write(section, vvalue) and not eq_cfg then
|
||||||
|
self.section.changed = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return m
|
30
package/lean/luci-app-fan/luasrc/view/luci-fan.htm
Normal file
30
package/lean/luci-app-fan/luasrc/view/luci-fan.htm
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<div class="cbi-section">
|
||||||
|
<div class="cbi-section-node">
|
||||||
|
<h3><%:Status%></h3>
|
||||||
|
<table class="table">
|
||||||
|
<tbody>
|
||||||
|
<tr class="tr"><td class="td"><%:Thermal zone%></td><td class="td"><%=self.thermal_zone%> (<%:type:%> <%=self.thermal_type%>)</td></tr>
|
||||||
|
<tr class="tr"><td class="td"><%:Trip point%></td><td class="td">trip_point_<%=self.trip_point%></td></tr>
|
||||||
|
<tr class="tr"><td class="td"><%:Fan start temperature%></td><td class="td" id="fan_on_temp"></td></tr>
|
||||||
|
<tr class="tr"><td class="td"><%:Current temperature%></td><td class="td" id="zone_temp"></td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
(function(){
|
||||||
|
var fan_on_temp = document.getElementById('fan_on_temp');
|
||||||
|
var zone_temp = document.getElementById('zone_temp');
|
||||||
|
XHR.poll(3, '<%=url("admin/system/luci-fan/get_fan_info/"..self.thermal_zone.."/"..self.trip_point)%>', null,
|
||||||
|
function(x, st) {
|
||||||
|
if (st) {
|
||||||
|
if (fan_on_temp)
|
||||||
|
fan_on_temp.innerHTML = st.fan_on_temp + ' ℃';
|
||||||
|
if (zone_temp)
|
||||||
|
zone_temp.innerHTML = st.zone_temp + ' ℃';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})()
|
||||||
|
//]]></script>
|
64
package/lean/luci-app-fan/po/templates/luci-fan.pot
Normal file
64
package/lean/luci-app-fan/po/templates/luci-fan.pot
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
msgid ""
|
||||||
|
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:19
|
||||||
|
msgid ""
|
||||||
|
"Control fan start and stop temperature. This plugin can only configure the "
|
||||||
|
"lowest gear, not necessarily applicable to all devices."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:9
|
||||||
|
msgid "Current temperature"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:31
|
||||||
|
msgid "Enabled"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/controller/admin/luci-fan.lua:13
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:19
|
||||||
|
msgid "Fan Control"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:27
|
||||||
|
msgid "Fan Settings"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:34
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:8
|
||||||
|
msgid "Fan start temperature"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:42
|
||||||
|
msgid "Fan stop temperature"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:80
|
||||||
|
msgid "Fan stop temperature MUST be lower than fan start temperature"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:42
|
||||||
|
msgid ""
|
||||||
|
"Optional, MUST be lower than the fan start temperature. Default fan start "
|
||||||
|
"temperature minus 5 ℃"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:3
|
||||||
|
msgid "Status"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:6
|
||||||
|
msgid "Thermal zone"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:7
|
||||||
|
msgid "Trip point"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:31
|
||||||
|
msgid "Whether to apply the settings"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:6
|
||||||
|
msgid "type:"
|
||||||
|
msgstr ""
|
68
package/lean/luci-app-fan/po/zh-cn/luci-fan.po
Normal file
68
package/lean/luci-app-fan/po/zh-cn/luci-fan.po
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Language: zh_Hans\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:19
|
||||||
|
msgid ""
|
||||||
|
"Control fan start and stop temperature. This plugin can only configure the "
|
||||||
|
"lowest gear, not necessarily applicable to all devices."
|
||||||
|
msgstr "控制风扇启停温度。此插件仅配置最低档位触发点,不一定适用于所有设备"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:9
|
||||||
|
msgid "Current temperature"
|
||||||
|
msgstr "当前温度"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:31
|
||||||
|
msgid "Enabled"
|
||||||
|
msgstr "启用"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/controller/admin/luci-fan.lua:13
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:19
|
||||||
|
msgid "Fan Control"
|
||||||
|
msgstr "风扇控制"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:27
|
||||||
|
msgid "Fan Settings"
|
||||||
|
msgstr "风扇设置"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:34
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:8
|
||||||
|
msgid "Fan start temperature"
|
||||||
|
msgstr "风扇启动温度"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:42
|
||||||
|
msgid "Fan stop temperature"
|
||||||
|
msgstr "风扇停止温度"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:80
|
||||||
|
msgid "Fan stop temperature MUST be lower than fan start temperature"
|
||||||
|
msgstr "风扇停止温度必须小于风扇启动温度"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:42
|
||||||
|
msgid ""
|
||||||
|
"Optional, MUST be lower than the fan start temperature. Default fan start "
|
||||||
|
"temperature minus 5 ℃"
|
||||||
|
msgstr "可选,必须小于风扇启动温度。默认风扇启动温度减 5 ℃"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:3
|
||||||
|
msgid "Status"
|
||||||
|
msgstr "状态"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:6
|
||||||
|
msgid "Thermal zone"
|
||||||
|
msgstr "温感区"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:7
|
||||||
|
msgid "Trip point"
|
||||||
|
msgstr "触发点"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/model/cbi/luci-fan.lua:31
|
||||||
|
msgid "Whether to apply the settings"
|
||||||
|
msgstr "是否应用此设置"
|
||||||
|
|
||||||
|
#: /Volumes/data/src/nas-packages-luci/luci/luci-app-fan/luasrc/view/luci-fan.htm:6
|
||||||
|
msgid "type:"
|
||||||
|
msgstr "类型:"
|
4
package/lean/luci-app-fan/root/etc/config/luci-fan
Normal file
4
package/lean/luci-app-fan/root/etc/config/luci-fan
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
config luci-fan
|
||||||
|
option enabled 0
|
||||||
|
# option on_temp 55
|
||||||
|
# option off_temp 50
|
28
package/lean/luci-app-fan/root/etc/init.d/luci-fan
Executable file
28
package/lean/luci-app-fan/root/etc/init.d/luci-fan
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=20
|
||||||
|
|
||||||
|
boot() {
|
||||||
|
/usr/libexec/fan-control init
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
|
start_instance() {
|
||||||
|
local enabled
|
||||||
|
config_get_bool enabled $1 enabled 0
|
||||||
|
[[ "$enabled" = 1 ]] || return 0
|
||||||
|
|
||||||
|
config_get on_temp $1 on_temp
|
||||||
|
config_get off_temp $1 off_temp
|
||||||
|
|
||||||
|
[[ -n "$on_temp" ]] && on_temp=${on_temp}000
|
||||||
|
[[ -n "$off_temp" ]] && off_temp=${off_temp}000
|
||||||
|
|
||||||
|
/usr/libexec/fan-control set "$on_temp" $off_temp
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
config_load luci-fan
|
||||||
|
config_foreach start_instance luci-fan
|
||||||
|
return 0
|
||||||
|
}
|
12
package/lean/luci-app-fan/root/etc/uci-defaults/luci-fan
Normal file
12
package/lean/luci-app-fan/root/etc/uci-defaults/luci-fan
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
/usr/libexec/fan-control init
|
||||||
|
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
delete ucitrack.@luci-fan[-1]
|
||||||
|
add ucitrack luci-fan
|
||||||
|
set ucitrack.@luci-fan[-1].init=luci-fan
|
||||||
|
commit ucitrack
|
||||||
|
EOF
|
||||||
|
|
||||||
|
exit 0
|
145
package/lean/luci-app-fan/root/usr/libexec/fan-control
Executable file
145
package/lean/luci-app-fan/root/usr/libexec/fan-control
Executable file
@ -0,0 +1,145 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# author: jjm2473
|
||||||
|
|
||||||
|
SAVE=/tmp/run/fanTP
|
||||||
|
ACTION=${1}
|
||||||
|
shift
|
||||||
|
|
||||||
|
# print: zone trip_point current_target_temp [max_target_temp]
|
||||||
|
# ex. thermal_zone0 0 50000 60000
|
||||||
|
function getFanTP() {
|
||||||
|
local zone cdev trip temp mintemp mintrip minzone maxtemp
|
||||||
|
[[ -d /sys/class/thermal ]] || return 1
|
||||||
|
cd /sys/class/thermal
|
||||||
|
for zone in thermal_zone* ; do
|
||||||
|
cd "$zone"
|
||||||
|
for cdev in `ls | grep 'cdev[0-9]\+$'`; do
|
||||||
|
[[ -d "$cdev" ]] || continue
|
||||||
|
grep -Fiq fan "$cdev/type" || continue
|
||||||
|
trip=`cat ${cdev}_trip_point`
|
||||||
|
grep -Fwq active trip_point_${trip}_type || continue
|
||||||
|
[[ "`stat -c '%#a' trip_point_${trip}_temp || echo 0444`" = "0644" ]] || continue
|
||||||
|
temp=`cat trip_point_${trip}_temp`
|
||||||
|
if [[ -z "$mintemp" ]] || [[ "$temp" -lt "$mintemp" ]]; then
|
||||||
|
if [[ -n "$mintemp" ]]; then
|
||||||
|
if [[ "$zone" = "$minzone" ]]; then
|
||||||
|
maxtemp=$mintemp
|
||||||
|
else
|
||||||
|
maxtemp=
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
mintemp=$temp
|
||||||
|
mintrip=$trip
|
||||||
|
minzone=$zone
|
||||||
|
elif [[ -z "$maxtemp" ]] || [[ "$temp" -lt "$maxtemp" ]]; then
|
||||||
|
maxtemp=$temp
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
cd /sys/class/thermal
|
||||||
|
done
|
||||||
|
if [[ -n "$mintemp" ]]; then
|
||||||
|
echo "$minzone" "$mintrip" "$mintemp" $maxtemp
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFanTP_C() {
|
||||||
|
if [[ -f "$SAVE" ]]; then
|
||||||
|
if [[ -s "$SAVE" ]]; then
|
||||||
|
cat "$SAVE"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
( getFanTP ) | tee "$SAVE"
|
||||||
|
[[ -s "$SAVE" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFanTP_U() {
|
||||||
|
set $(getFanTP_C)
|
||||||
|
[[ -n "$1" && -n "$2" ]] || return 1
|
||||||
|
local onTemp=`cat "/sys/class/thermal/${1}/trip_point_${2}_temp"`
|
||||||
|
echo "$1" "$2" "$onTemp" $4
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function initFanTP() {
|
||||||
|
[[ -f "$SAVE" ]] || ( getFanTP >"$SAVE" )
|
||||||
|
}
|
||||||
|
|
||||||
|
# param: ON_TEMP [OFF_TEMP]
|
||||||
|
# OFF_TEMP = ON_TEMP - 5000 if not set
|
||||||
|
# ex. 60000 55000
|
||||||
|
function setFanTP() {
|
||||||
|
local ON_TEMP=$1
|
||||||
|
local OFF_TEMP=$2
|
||||||
|
[[ -n "$ON_TEMP" ]] || {
|
||||||
|
echo "ON_TEMP must be present" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if [[ -z "$OFF_TEMP" ]]; then
|
||||||
|
[[ "$ON_TEMP" -gt 5000 ]] || {
|
||||||
|
echo "ON_TEMP must greater than 5000 when OFF_TEMP not present" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
OFF_TEMP=$(( $ON_TEMP - 5000 ))
|
||||||
|
fi
|
||||||
|
[[ "$ON_TEMP" -gt "$OFF_TEMP" ]] || {
|
||||||
|
echo "ON_TEMP must greater than OFF_TEMP" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
local HYST=$(( $ON_TEMP - $OFF_TEMP ))
|
||||||
|
|
||||||
|
set $(getFanTP_C)
|
||||||
|
[[ -n "$1" && -n "$2" ]] || return 1
|
||||||
|
[[ -d "/sys/class/thermal/${1}" ]] || return 1
|
||||||
|
|
||||||
|
[[ -n "$4" ]] && [[ "$ON_TEMP" -ge "$4" ]] && {
|
||||||
|
ON_TEMP=$(( $4 - 5000 ))
|
||||||
|
echo "WARN: ON_TEMP greater than next TP $4, fixed to $ON_TEMP" >&2
|
||||||
|
}
|
||||||
|
echo "$ON_TEMP" > "/sys/class/thermal/${1}/trip_point_${2}_temp"
|
||||||
|
echo "$HYST" > "/sys/class/thermal/${1}/trip_point_${2}_hyst"
|
||||||
|
}
|
||||||
|
|
||||||
|
# print: current thermal sensor value and fan on temp
|
||||||
|
function getTemp() {
|
||||||
|
set $(getFanTP_C)
|
||||||
|
[[ -n "$1" && -n "$2" ]] || return 1
|
||||||
|
[[ -f "/sys/class/thermal/$1/temp" ]] || return 1
|
||||||
|
local temp=`cat "/sys/class/thermal/$1/temp"`
|
||||||
|
local tpt=`cat "/sys/class/thermal/$1/trip_point_${2}_temp"`
|
||||||
|
echo "$temp $tpt"
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "usage: $0 sub-command"
|
||||||
|
echo "where sub-command is one of:"
|
||||||
|
echo " get Get Fan setting"
|
||||||
|
echo " set ON_TEMP [OFF_TEMP] Set Fan setting"
|
||||||
|
echo " temp Get current thermal temp and Fan on temp"
|
||||||
|
echo " init init, internal used"
|
||||||
|
}
|
||||||
|
|
||||||
|
case ${ACTION} in
|
||||||
|
"get")
|
||||||
|
getFanTP_U
|
||||||
|
;;
|
||||||
|
"set")
|
||||||
|
setFanTP "$@"
|
||||||
|
;;
|
||||||
|
"temp")
|
||||||
|
getTemp
|
||||||
|
;;
|
||||||
|
"init")
|
||||||
|
initFanTP
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
@ -13,6 +13,6 @@ KERNEL_PATCHVER:=6.6
|
|||||||
include $(INCLUDE_DIR)/target.mk
|
include $(INCLUDE_DIR)/target.mk
|
||||||
DEFAULT_PACKAGES += \
|
DEFAULT_PACKAGES += \
|
||||||
kmod-leds-gpio kmod-gpio-button-hotplug \
|
kmod-leds-gpio kmod-gpio-button-hotplug \
|
||||||
autocore-arm htop wpad-openssl uboot-envtools
|
autocore-arm htop wpad-openssl uboot-envtools luci-app-fan
|
||||||
|
|
||||||
$(eval $(call BuildTarget))
|
$(eval $(call BuildTarget))
|
||||||
|
@ -112,6 +112,16 @@
|
|||||||
opp-hz = /bits/ 64 <1800000000>;
|
opp-hz = /bits/ 64 <1800000000>;
|
||||||
opp-microvolt = <900000>;
|
opp-microvolt = <900000>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
opp04 {
|
||||||
|
opp-hz = /bits/ 64 <2100000000>;
|
||||||
|
opp-microvolt = <1000000>;
|
||||||
|
};
|
||||||
|
|
||||||
|
opp05 {
|
||||||
|
opp-hz = /bits/ 64 <2300000000>;
|
||||||
|
opp-microvolt = <1150000>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user