1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
--[[
Debian configuration file for qcontrol (LUA syntax)
Supports both QNAP TS-109 and TS-209.
--]]
register("ts209")
-- Requires CONFIG_KEYBOARD_GPIO enabled in the kernel and
-- the kernel module gpio_keys to be loaded.
-- Different kernel versions use platform-gpio_keys-event or
-- platform-gpio-keys-event, find the right one.
function find_device( options )
for index,option in ipairs(options) do
local f=io.open(option)
if f then
f:close()
return option
end
end
return nil
end
evdev = find_device ( { "/dev/input/by-path/platform-gpio_keys-event",
"/dev/input/by-path/platform-gpio-keys-event" } )
if evdev then
logprint("Register evdev on "..evdev)
register("evdev", evdev,
408, "restart_button",
133, "media_button")
else
logprint("No evdev device found")
end
register("system-status")
-- Set to "false" to suppress the sounding of the buzzer
buzzer = true
-- Set to "false" if your device doesn't have a fan (TS-109 and TS-109 II)
has_fan = true
-- Turn off fan if there is no fan to avoid fan_error() being called
if not has_fan then
piccmd("fanspeed", "stop")
end
function system_status( status )
logprint("System status: "..status)
if status == "start" then
piccmd("statusled", "greenon")
piccmd("powerled", "on")
if buzzer then piccmd("buzzer", "short") end
elseif status == "stop" then
piccmd("statusled", "redon")
piccmd("powerled", "1hz")
if buzzer then piccmd("buzzer", "short") end
else
logprint("Unknown system status")
end
end
function power_button( time )
os.execute("poweroff")
end
function restart_button( time )
os.execute("reboot")
end
function media_button( time )
piccmd("usbled", "8hz")
end
fanfail = 0
function fan_error( )
fanfail = fanfail + 1
if fanfail == 3 then
logprint("ts209: fan error")
piccmd("statusled", "red2hz")
piccmd("buzzer", "long")
else
if fanfail == 10 then
fanfail = 0
end
end
end
function fan_normal( )
piccmd("statusled", "greenon")
fanfail = 0
end
last_fan_setting = nil
function setfan( speed )
-- Do nothing if there's no fan
if not has_fan then
return
end
if ( ( not last_fan_setting ) or
( last_fan_setting ~= speed ) ) then
logprint(string.format("ts209: setting fan to \"%s\"", speed))
end
piccmd("fanspeed", speed)
last_fan_setting = speed
end
function temp_low( )
setfan("silence")
end
function temp_high( )
setfan("full")
end
confdir("/etc/qcontrol.d")
--
-- Local variables:
-- mode: lua
-- indent-level: 8
-- End:
|