Skip to content

Commit 509a354

Browse files
committed
luci-mod-system: support for RGB LEDs
added support for setting LED brightness and colours channels and max_brightness are pulled dynamically from sysfs Signed-off-by: Tomáš Macholda <tomas.macholda@nic.cz>
1 parent 07b54ac commit 509a354

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

  • modules/luci-mod-system/htdocs/luci-static/resources/view/system

modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ return view.extend({
9797
for (let plugin of plugins) {
9898
plugin.form.addFormOptions(s);
9999
}
100+
const led_names = Object.keys(leds);
101+
for (let i = 0; i < led_names.length; i++) {
102+
let led = leds[led_names[i]];
103+
o = s.option(form.Value, `${led_names[i]}_brightness`, _('Brightness'));
104+
o.depends('sysfs', led_names[i]);
105+
o.ucioption = 'brightness';
106+
o.datatype = `range(0,${led.max_brightness})`;
107+
o.placeholder = led.max_brightness;
108+
o.modalonly = true;
109+
if (led.multi_channel) {
110+
for (let channel in led.channels) {
111+
o = s.option(form.Value, `${led_names[i]}_color_${channel}`, channel);
112+
o.ucioption = `color_${channel}`;
113+
o.depends('sysfs', led_names[i]);
114+
o.datatype = `range(0,${led.max_brightness})`;
115+
o.placeholder = led.channels[channel];
116+
o.modalonly = true;
117+
}
118+
}
119+
}
100120

101121
const opts = s.getOption();
102122

0 commit comments

Comments
 (0)