GithubHelp home page GithubHelp logo

wiringtinker_7.1.2's Introduction

wiringPi TinkerBoard

wiringPi for TinkerBoard ported to Android.

To compile the library, execute from the jni folder the command:

"/path/to/your/SDK/ndk-bundle/ndk-build -B"

You will get some binaries and libraries:

[armeabi] Install        : gpio => libs/armeabi/gpio
[armeabi] Install        : led => libs/armeabi/led
[armeabi] Install        : libwiringPi.so => libs/armeabi/libwiringPi.so
[armeabi] Install        : libwiringPiDev.so => libs/armeabi/libwiringPiDev.so
[armeabi] Install        : libwpi_android.so => libs/armeabi/libwpi_android.so

The libraries need to be installed to the /system/lib/ folder on the TinkerBoard and the gpio binary to the folder /system/bin/:

adb push ../libs/armeabi/libwiringPi.so /system/lib/
adb push ../libs/armeabi/libwiringPiDev.so /system/lib/
adb push ../libs/armeabi/gpio /system/bin/

Also with a rooted TinkerBoard, it is not possible to access the /dev/mem from an app. So to use the library from an app, it is needed a custom kernel with a gpiomem driver. Without gpiomem driver, you can access the library only from root shell.

The libwpi_android.so is the library you can load in your java code:
wpiAndroid.java

package com.jw.wiringpi;

public final class wpiAndroid {
    static {
        System.loadLibrary("wpi_android");
    }
    static public native int wiringPiSetup();
    static public native int wiringPiSetupSys();
    static public native int digitalRead(int port);
    static public native void digitalWrite(int port, int onoff);
    static public native void pullUpDnControl(int port, int pud);
    static public native void pinMode(int port, int mode);
    static public native int softPwmCreate(int port, int value, int range);
    static public native void softPwmWrite  (int port, int value) ;
    static public native void softPwmStop   (int port) ;
}

Then you can import the functions to your project:

import static com.jw.wiringpi.wpiAndroid.digitalRead;
import static com.jw.wiringpi.wpiAndroid.digitalWrite;
import static com.jw.wiringpi.wpiAndroid.pinMode;
import static com.jw.wiringpi.wpiAndroid.pullUpDnControl;
import static com.jw.wiringpi.wpiAndroid.wiringPiSetup;
.
.
.
public static final int INPUT = 0;
public static final int OUTPUT = 1;
public static final int PWM_OUTPUT = 2;
public static final int GPIO_CLOCK = 3;
public static final int SOFT_PWM_OUTPUT = 4;
public static final int SOFT_TONE_OUTPUT = 5;
public static final int PWM_TONE_OUTPUT = 6;

public static final int PUD_OFF = 0;
public static final int PUD_DOWN = 1;
public static final int PUD_UP = 2;

public static final int INT_EDGE_SETUP = 0;
public static final int INT_EDGE_FALLING = 1;
public static final int INT_EDGE_RISING = 2;
public static final int INT_EDGE_BOTH = 3;
.
.
.
if (wiringPiSetup() != 0) {
    Log.e(TAG, "Error setting up wiringPi!");
}
        
pinMode(24, INPUT);
pullUpDnControl(24, PUD_DOWN);
int in24 = digitalRead(24);

And in build.gradle need to be adjusted the path to the libraries:

sourceSets {
    main {
        // let gradle pack the shared library into apk
        jniLibs.srcDirs = ['path/to/wiringPi/libs']
}

wiringtinker_7.1.2's People

Contributors

joerg65 avatar

Watchers

 avatar

Forkers

wisecenter

wiringtinker_7.1.2's Issues

Read i2c from an app

After I was able to read from i2c by running a C executable, I try to import the code in an android app.
When I run the android app and try to read from i2c I got the following error:

avc: denied { read write } for name="gpiomem" dev="tmpfs" ino=8590 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
    type=1400 audit(0.0:742): avc: denied { open } for path="/dev/gpiomem" dev="tmpfs" ino=8590 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1

it seems that the app doesn't have the permissions to use gpiomem

How can I fix it?

Read from i2c

How can I read from i2c?
I attached a MLX90614 IR camera to SCL and SDA pin. now How can I read the i2c values with wiringPI library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.