This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Java CI with Maven | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<groupId>nl.lengrand</groupId> | |
<version>1.1</version> | |
<modelVersion>4.0.0</modelVersion> | |
<artifactId>cellar-driver</artifactId> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INCLUDES = -I. -I../java -Iadafruit/Raspberry_Pi_2 -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -I$(JAVA_HOME)/include/darwin | |
HEADERS = ../../../target/headers/nl_lengrand_cellar_Dht11Driver.h adafruit/common_dht_read.h adafruit/Raspberry_Pi_2/pi_2_mmio.h adafruit/Raspberry_Pi_2/pi_2_dht_read.h | |
FILES = adafruit/common_dht_read.c adafruit/Raspberry_Pi_2/pi_2_mmio.c adafruit/Raspberry_Pi_2/pi_2_dht_read.c Dht11Driver.c | |
OUT = libdht11 | |
default: library copy | |
program: Dht11Driver.c | |
arm-linux-gnueabihf-gcc -Wall $(INCLUDES) $(HEADERS) $(FILES) -o $(OUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nl.lengrand.cellar; | |
public class TestLib { | |
public static void main(String[] args) throws InterruptedException { | |
Dht11Driver theDriver = new Dht11Driver(); | |
System.out.println("Hello JNI!"); | |
for (int i = 0; i < 5; i++) { | |
float [] res = theDriver.getTemperatureAndHumidity(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
#include <jni.h> | |
#include "../../../target/headers/nl_lengrand_cellar_Dht11Driver.h" | |
#include "adafruit/Raspberry_Pi_2/pi_2_dht_read.h" | |
JNIEXPORT jfloatArray JNICALL Java_nl_lengrand_cellar_Dht11Driver_getTemperatureAndHumidity(JNIEnv *env, jobject thisObj){ | |
float humidity = 0, temperature = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nl.lengrand.cellar; | |
public class Dht11Driver { | |
static { | |
System.loadLibrary("dht11"); | |
} | |
public native float[] getTemperatureAndHumidity(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float humidity = 0, temperature = 0; | |
int sensor = 11;int pin = 4; | |
pi_2_dht_read(sensor, pin, &humidity, &temperature); | |
printf("Temperature : %f\n", temperature); | |
printf("Humidity : %f\n", humidity); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
#include "adafruit/Raspberry_Pi_2/pi_2_dht_read.h" | |
int main( void ) | |
{ | |
printf( "Raspberry Pi 2 DHT11 test program\n" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.pi4j.wiringpi.Gpio; | |
import com.pi4j.wiringpi.GpioUtil; | |
public class DHT11 { | |
private static final int MAXTIMINGS = 85; | |
private final int[] dht11_dat = { 0, 0, 0, 0, 0 }; | |
public DHT11() { | |
GpioUtil.export(3, GpioUtil.DIRECTION_OUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ java -version | |
openjdk version "14" 2020-03-17 | |
OpenJDK Runtime Environment AdoptOpenJDK (build 14+36) | |
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14+36, mixed mode, sharing) | |
$ jpackage | |
WARNING: Using incubator modules: jdk.incubator.jpackage | |
Usage: jpackage <options> | |
Use jpackage --help (or -h) for a list of possible options |
NewerOlder