My next attempt is to get Blinky to work as part of an Android app. I found some relevant code but my device fell over so I can’t test it yet. Here is the code thus far.
I found some code on a post but it did not have any configuration settings so I’ve extended it. I’ve created a function that can be called from an Android button handler.
public void GPIO() { String command1 = "echo 938 > /sys/class/gpio/export"; String command2 = "echo out > /sys/class/gpio/gpio938/value/direction"; String command3 = "echo 1 > /sys/class/gpio/gpio938/value"; String command4 = "echo 0 > /sys/class/gpio/gpio938/value"; String command5 = "echo 938 > /sys/class/gpio/unexport"; TextView textView = (TextView) findViewById(R.id.textView5); try { Process su = Runtime.getRuntime().exec("su -c " + command1); textView.setText(command1); su.waitFor(); su = Runtime.getRuntime().exec("su -c " + command2); textView.setText(command2); su.waitFor(); su = Runtime.getRuntime().exec("su -c " + command3); textView.setText(command3); su.waitFor(); su = Runtime.getRuntime().exec("su -c " + command4); textView.setText(command4); su.waitFor(); wait(1000); su = Runtime.getRuntime().exec("su -c " + command5); textView.setText(command5); su.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
I would welcome any comments on the viability of this code, whilst I await an ability to test it, thanks