Note : please use BPI-M3 android V3 image.
reg-81x-cs-gpio0ldo/max_microvolts : Blue Led
reg-81x-cs-gpio1ldo/max_microvolts : Green Led
adb remount
adb shell
chmod /system/bin/su
package com.bpim3.leddemo;
import android.app.Activity;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.util.Log;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class TestLED extends Thread {
private String TAG = "Test-LED";
TestLED() {
}
@Override
public void run() {
// TODO Auto-generated method stub
try {
Runtime command = Runtime.getRuntime();
Process proc;
DataOutputStream opt;
proc = command.exec("su");
opt = new DataOutputStream(proc.getOutputStream());
Log.d(TAG, "LED Testing start.");
while (true) {
LEDRun(opt);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void LEDRun(DataOutputStream opt) {
try {
opt.writeBytes("echo 3000 > /sys/bus/platform/devices/reg-81x-cs-gpio0ldo/max_microvolts\n");
opt.writeBytes("echo 3000 > /sys/bus/platform/devices/reg-81x-cs-gpio1ldo/max_microvolts\n");
// Log.d(TAG, "LED ON.");
Thread.sleep(500);
opt.writeBytes("echo 0 > /sys/bus/platform/devices/reg-81x-cs-gpio0ldo/max_microvolts\n");
opt.writeBytes("echo 0 > /sys/bus/platform/devices/reg-81x-cs-gpio1ldo/max_microvolts\n");
// Log.d(TAG, "LED OFF.");
Thread.sleep(500);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}