{{{#!html
In order to provide users with easy access to the ventana family's low level linux functionality, Gateworks has composed a java library that exposes some simple methods for interacting with LEDs, GPIOs, PWMs, and hardware monitors that have been exported and registered in the android property system.
The source for the library is available on Github at Gateworks/android_packatges_apps_gateworksutil and the javadoc created api documentation can be found here.
In order for the library to function as intended, all low level controllers must be both exported and registered prior to runtime.
Note that this is done by the Gateworks Android init script /device/gateworks/ventana/init.sh which is installed to /system/bin/init.sh and run as root on bootup for the standard resources on the various Ventana boards.
Since the GateworksUtil library depends on access to the controller's associated sysfs structure, all GPIOs, PWMs, and LEDs must first be exported to userspace before they can be used. For further information on exporting see the following pages:
In addition, the low level controllers being used must also be registered in the Android System Property list. This can be done a number of ways:
*Note: the android.os.SystemProperties class is only accessible to the internal android source SDK.
For further information on registering see the Android Properties section of the Android OS Development page.
While the full source for the library is available on Github at Gateworks/android_packatges_apps_gateworksutil and the javadoc created api documentation can be found here sometimes a few simple examples can be extremely helpful.
Code snippets and notes:
import com.gateworks.gateworksutil.*;
adb shell getprop | grep hw.hwmon [hw.hwmon.gsc_3p3]: [/sys/class/hwmon/hwmon1/device/in1_input] [hw.hwmon.gsc_5p0]: [/sys/class/hwmon/hwmon1/device/in3_input] [hw.hwmon.gsc_bat]: [/sys/class/hwmon/hwmon1/device/in2_input] [hw.hwmon.gsc_core]: [/sys/class/hwmon/hwmon1/device/in4_input] [hw.hwmon.gsc_cpu1]: [/sys/class/hwmon/hwmon1/device/in5_input] [hw.hwmon.gsc_cpu2]: [/sys/class/hwmon/hwmon1/device/in6_input] [hw.hwmon.gsc_current]: [/sys/class/hwmon/hwmon1/device/in12_input] [hw.hwmon.gsc_dram]: [/sys/class/hwmon/hwmon1/device/in7_input] [hw.hwmon.gsc_ext_bat]: [/sys/class/hwmon/hwmon1/device/in8_input] [hw.hwmon.gsc_io1]: [/sys/class/hwmon/hwmon1/device/in9_input] [hw.hwmon.gsc_io2]: [/sys/class/hwmon/hwmon1/device/in10_input] [hw.hwmon.gsc_pci2]: [/sys/class/hwmon/hwmon1/device/in11_input] [hw.hwmon.gsc_temp]: [/sys/class/hwmon/hwmon1/device/temp0_input] [hw.hwmon.gsc_vin]: [/sys/class/hwmon/hwmon1/device/in0_input] [hw.hwmon.imx_cpu_crit_temp]: [/sys/class/hwmon/hwmon2/temp1_crit] [hw.hwmon.imx_cpu_temp]: [/sys/class/hwmon/hwmon2/temp1_input]
int vin = HardwareMonitor.getHwmonValue("gsc_vin"));
int vin = HardwareMonitor.getHwmonValue("imx_cpu_temp"));
adb shell getprop | grep hw.gpio [hw.gpio.can_stby]: [/sys/class/gpio/gpio2/] [hw.gpio.dio0]: [/sys/class/gpio/gpio9/] [hw.gpio.dio1]: [/sys/class/gpio/gpio19/] [hw.gpio.dio2]: [/sys/class/gpio/gpio41/]
setGpioDirection("dio0", IN); int getGpioValue("dio0");
setGpioDirection("dio1", OUT); setGpioValue("dio1", 1);
adb shell getprop | grep hw.led [hw.led.frontgreen]: [/sys/class/leds/user1/] [hw.led.frontred]: [/sys/class/leds/user2/] [hw.led.local]: [/sys/class/leds/user3/]
setLedtrigger("none", 0); setLedValue("frontgreen", 0);
setLedTrigger("frontgreen", "heartbeat");
adb shell getprop | grep hw.pwm [hw.pwm.pwm2]: [/sys/class/pwm/pwmchip0/pwm0/]
setPeriod("pwm2", 1000); setDutyCycle("pwm2", 50); setPolarity("pwm2", NORMAL); setEnabled("pwm2", 1);
The file links below include the following: