Controlling LEDs
All LED controls are in /sys/class/leds. The relevant ones are:
$this->bbcode_second_pass_code('', '
/sys/class/leds/iconnect:red:power
/sys/class/leds/iconnect:blue:power
/sys/class/leds/iconnect:blue:otb
/sys/class/leds/iconnect:blue:usb1
/sys/class/leds/iconnect:blue:usb2
/sys/class/leds/iconnect:blue:usb3
/sys/class/leds/iconnect:blue:usb4
/sys/class/leds/iconnect:led_level
')
Their functions are fairly obvious from the above directory names. The structure of all LED direcotires is identical, e.g.,
$this->bbcode_second_pass_code('', '
$ ls /sys/class/leds/iconnect:blue:usb1
brightness device max_brightness power subsystem trigger uevent
')
Two files there are of interest, "brightness" and "trigger". Write a non-0 value into "brightness" to turn on the corresponding LED, e.g., do the following (as root) to turn on USB LED 1:
$this->bbcode_second_pass_code('', '
echo 255 > /sys/class/leds/iconnect:blue:usb1/brightness
')
Write 0 to turn LED off, e.g. the following will turn off USB LED 1:
$this->bbcode_second_pass_code('', '
echo 0 > /sys/class/leds/iconnect:blue:usb1/brightness
')
"trigger" allows you to trigger turning on of the corresponding LED based on some events:
$this->bbcode_second_pass_code('', '
$ cat /sys/class/leds/iconnect:blue:usb1/trigger
[none] nand-disk timer heartbeat default-on rfkill0 phy0rx phy0tx phy0assoc phy0radio
')
The current trigger is in square brackets. To change the trigger, write one of the above values into the "trigger" file under corresponding LED, e.g., the following will blink USB LED 1:
$this->bbcode_second_pass_code('', '
echo timer > /sys/class/leds/iconnect:blue:usb1/trigger
')
"timer" and "heartbeat" are both pseudo triggers that blink the LED with different patterns. "nand-disk" blinks when there is NAND activity. rfkill0 and phy* trigger blinking on the corresponding wireless card activity; e.g., the following will cause the OTB LED to blink whenever a transmission happens on the wireless interface:
$this->bbcode_second_pass_code('', '
echo phy0tx > /sys/class/leds/iconnect:blue:otb/trigger
')
/sys/class/leds/iconnect:led_level is special - it controls the brightness of all LEDs, just as the name suggests. Write 0 to /sys/class/leds/iconnect:led_level to dim the LEDs:
$this->bbcode_second_pass_code('', '
echo 0 > /sys/class/leds/iconnect:led_level/brightness
')
Write any non-0 value to "undim". You can also use led_level triggers to change the LED brightness based on trigger events if that suites your fancy.
Temperature sensor
Install lm_sensors package:
$this->bbcode_second_pass_code('', '
pacman -S lm_sensors
')
Load the modules needed to detect the temperature sensor:
$this->bbcode_second_pass_code('', '
modprobe -a lm63 i2c_mv64xxx hwmon i2c_core
')
Run sensors-detect; answer "yes" to all questions. This should create "/etc/conf.d/lm_sensors" file with the needed configuration. Add "sensors" to the DAEMONS line in your /etc/rc.conf; it will automatically load the needed modules on reboot.
You can now run "sensors" command to check iConnect temperature:
$this->bbcode_second_pass_code('', '
$ sensors
lm63-i2c-0-4c
Adapter: mv64xxx_i2c adapter
temp1: +40.0°C (high = +70.0°C)
temp2: +39.4°C (low = +0.0°C, high = +70.0°C)
(crit = +85.0°C, hyst = +75.0°C)
')
OTB (front) and reset (back) buttons
See this post for some ideas on how to trigger actions when you press the OTB or reset buttons. If you'd like to perform different actions depending on which of the buttons was pressed, here is what you need to know about the data you read from /dev/input/event0:
$this->bbcode_second_pass_code('', '
inputEventFormat = 'iiHHi'
time1, time2, ev_type, code, value = struct.unpack(inputEventFormat, event)
')
- time1 - time in seconds since Jan 1, 1970 UTC (aka Unix time)
- time2 - useconds after time1. That is, time1.time2 is the time when the event occurred.
- ev_type - event type. "5" corresponds to button events so that's the only value you need to pay attention to.
- code - event code. 0 corresponds to reset button (the one on the back), 1 corresponds to OTB button on the front of iConnect.
- value - 1 when a button is pressed, 0 when it's released.