Permalink
Browse files

added experimental OrangePi support

  • Loading branch information...
1 parent 14a6568 commit 291808c3a2b723667a0835c282b6a78c9a3cfd13 @savageautomate savageautomate committed Dec 5, 2016
View
@@ -70,6 +70,7 @@ Copyright (C) 2012-2016 Pi4J
* Updated to Java 8 (enhancement #203)
* Updated build dependencies/plugins to latest versions.
* Removed unsupported sub-projects (pi4j-temp, pi4j-service).
+ * Added experimental support for OrangePi platform.
* Fixed #278: wiringPiSetup*: You must only call this once per program run.
* Fixed #294; added java runtime and compiler check to pi4j helper script
* Fixed #291; W1Device name contains "\n"
View
@@ -209,6 +209,28 @@
<destFileName>libpi4j.so</destFileName>
</artifactItem>
+ <!-- LIBPI4J for the OrangePi platform -->
+ <artifactItem>
+ <groupId>com.pi4j</groupId>
+ <artifactId>pi4j-native</artifactId>
+ <version>${project.version}</version>
+ <classifier>orangepi-static</classifier>
+ <type>so</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/lib/orangepi/static</outputDirectory>
+ <destFileName>libpi4j.so</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.pi4j</groupId>
+ <artifactId>pi4j-native</artifactId>
+ <version>${project.version}</version>
+ <classifier>orangepi-dynamic</classifier>
+ <type>so</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/lib/orangepi/dynamic</outputDirectory>
+ <destFileName>libpi4j.so</destFileName>
+ </artifactItem>
+
</artifactItems>
</configuration>
</execution>
@@ -0,0 +1,63 @@
+package com.pi4j.io.gpio;
+
+/*
+ * #%L
+ * **********************************************************************
+ * ORGANIZATION : Pi4J
+ * PROJECT : Pi4J :: Java Library (Core)
+ * FILENAME : OrangePiGpioProvider.java
+ *
+ * This file is part of the Pi4J project. More information about
+ * this project can be found here: http://www.pi4j.com/
+ * **********************************************************************
+ * %%
+ * Copyright (C) 2012 - 2016 Pi4J
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import com.pi4j.platform.Platform;
+import com.pi4j.wiringpi.GpioInterruptListener;
+
+/**
+ * OrangePi {@link GpioProvider} implementation.
+ *
+ * @author Robert Savage (<a
+ * href="http://www.savagehomeautomation.com">http://www.savagehomeautomation.com</a>)
+ */
+@SuppressWarnings("unused")
+public class OrangePiGpioProvider extends WiringPiGpioProviderBase implements GpioProvider, GpioInterruptListener {
+
+ public static final String NAME = "OrangePi GPIO Provider";
+
+ /**
+ * Default Constructor
+ */
+ public OrangePiGpioProvider() {
+
+ // configure the Pi4J platform to use the "bananapro" implementation
+ System.setProperty("pi4j.platform", Platform.ORANGEPI.id());
+
+ // set wiringPi interface for internal use
+ // we will use the WiringPi pin number scheme with the wiringPi library
+ com.pi4j.wiringpi.Gpio.wiringPiSetup();
+ }
+
+ @Override
+ public String getName() {
+ return NAME;
+ }
+}
@@ -0,0 +1,121 @@
+package com.pi4j.io.gpio;
+
+/*
+ * #%L
+ * **********************************************************************
+ * ORGANIZATION : Pi4J
+ * PROJECT : Pi4J :: Java Library (Core)
+ * FILENAME : OrangePiPin.java
+ *
+ * This file is part of the Pi4J project. More information about
+ * this project can be found here: http://www.pi4j.com/
+ * **********************************************************************
+ * %%
+ * Copyright (C) 2012 - 2016 Pi4J
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+
+import java.util.EnumSet;
+
+/**
+ * OrangePi pin definitions for (default) WiringPi pin numbering scheme.
+ *
+ * @author Robert Savage (<a
+ * href="http://www.savagehomeautomation.com">http://www.savagehomeautomation.com</a>)
+ */
+public class OrangePiPin extends PinProvider {
+
+ public static final Pin GPIO_00 = createDigitalPin(0, "GPIO 0");
+ public static final Pin GPIO_01 = createDigitalPin(1, "GPIO 1");
+ public static final Pin GPIO_02 = createDigitalPin(2, "GPIO 2");
+ public static final Pin GPIO_03 = createDigitalPin(3, "GPIO 3");
+ public static final Pin GPIO_04 = createDigitalPin(4, "GPIO 4");
+ public static final Pin GPIO_05 = createDigitalPin(5, "GPIO 5");
+ public static final Pin GPIO_06 = createDigitalPin(6, "GPIO 6");
+ public static final Pin GPIO_07 = createDigitalPin(7, "GPIO 7");
+ public static final Pin GPIO_08 = createDigitalPinNoEdge(8, "GPIO 8",
+ EnumSet.of(PinPullResistance.OFF, PinPullResistance.PULL_UP)); // this pin is permanently pulled up
+ public static final Pin GPIO_09 = createDigitalPinNoEdge(9, "GPIO 9",
+ EnumSet.of(PinPullResistance.OFF, PinPullResistance.PULL_UP)); // this pin is permanently pulled up
+
+ public static final Pin GPIO_10 = createDigitalPin(10, "GPIO 10");
+ public static final Pin GPIO_11 = createDigitalPin(11, "GPIO 11");
+ public static final Pin GPIO_12 = createDigitalPin(12, "GPIO 12");
+ public static final Pin GPIO_13 = createDigitalPin(13, "GPIO 13");
+ public static final Pin GPIO_14 = createDigitalPin(14, "GPIO 14");
+ public static final Pin GPIO_15 = createDigitalPin(15, "GPIO 15");
+ public static final Pin GPIO_16 = createDigitalPin(16, "GPIO 16");
+
+ public static final Pin GPIO_21 = createDigitalPinNoEdge(21, "GPIO 21");
+ public static final Pin GPIO_22 = createDigitalPinNoEdge(22, "GPIO 22");
+ public static final Pin GPIO_23 = createDigitalPinNoEdge(23, "GPIO 23");
+ public static final Pin GPIO_24 = createDigitalPinNoEdge(24, "GPIO 24");
+ public static final Pin GPIO_25 = createDigitalPinNoEdge(25, "GPIO 25");
+ public static final Pin GPIO_26 = createDigitalPinNoEdge(26, "GPIO 26");
+ public static final Pin GPIO_27 = createDigitalPinNoEdge(27, "GPIO 27");
+ public static final Pin GPIO_28 = createDigitalPinNoEdge(28, "GPIO 28");
+ public static final Pin GPIO_29 = createDigitalPinNoEdge(29, "GPIO 29");
+ public static final Pin GPIO_30 = createDigitalPinNoEdge(30, "GPIO 30",
+ EnumSet.noneOf(PinPullResistance.class)); // this pin is permanently pulled up; pin pull settings do not work
+ public static final Pin GPIO_31 = createDigitalPinNoEdge(31, "GPIO 31",
+ EnumSet.noneOf(PinPullResistance.class)); // this pin is permanently pulled up; pin pull settings do not work
+
+ protected static Pin createDigitalPin(int address, String name) {
+ return createDigitalPin(OrangePiGpioProvider.NAME, address, name);
+ }
+
+ protected static Pin createDigitalPinNoEdge(int address, String name, EnumSet<PinPullResistance> resistance) {
+ return createDigitalPin(OrangePiGpioProvider.NAME, address, name, resistance, EnumSet.noneOf(PinEdge.class));
+ }
+
+ protected static Pin createDigitalPinNoEdge(int address, String name) {
+ return createDigitalPin(OrangePiGpioProvider.NAME, address, name, EnumSet.noneOf(PinEdge.class));
+ }
+
+ protected static Pin createDigitalAndPwmPin(int address, String name) {
+ return createDigitalAndPwmPin(OrangePiGpioProvider.NAME, address, name);
+ }
+
+ protected static Pin createDigitalAndPwmPinNoEdge(int address, String name) {
+ return createDigitalAndPwmPin(OrangePiGpioProvider.NAME, address, name, EnumSet.noneOf(PinEdge.class));
+ }
+
+ // *override* static method from subclass
+ // (overriding a static method is not supported in Java
+ // so this method definition will hide the subclass static method)
+ public static Pin getPinByName(String name) {
+ return PinProvider.getPinByName(name);
+ }
+
+ // *override* static method from subclass
+ // (overriding a static method is not supported in Java
+ // so this method definition will hide the subclass static method)
+ public static Pin getPinByAddress(int address) {
+ return PinProvider.getPinByAddress(address);
+ }
+
+ // *override* static method from subclass
+ // (overriding a static method is not supported in Java
+ // so this method definition will hide the subclass static method)
+ public static Pin[] allPins() { return PinProvider.allPins(); }
+
+ // *override* static method from subclass
+ // (overriding a static method is not supported in Java
+ // so this method definition will hide the subclass static method)
+ public static Pin[] allPins(PinMode ... mode) { return PinProvider.allPins(mode); }
+}
@@ -0,0 +1,43 @@
+package com.pi4j.io.i2c.impl;
+
+/*
+ * #%L
+ * **********************************************************************
+ * ORGANIZATION : Pi4J
+ * PROJECT : Pi4J :: Java Library (Core)
+ * FILENAME : I2CFactoryProviderBananaPi.java
+ *
+ * This file is part of the Pi4J project. More information about
+ * this project can be found here: http://www.pi4j.com/
+ * **********************************************************************
+ * %%
+ * Copyright (C) 2012 - 2016 Pi4J
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import com.pi4j.io.i2c.I2CFactory.UnsupportedBusNumberException;
+
+public class I2CFactoryProviderOrangePi extends I2CProviderImpl {
+
+ @Override
+ protected String getFilenameForBusnumber(int busNumber) throws UnsupportedBusNumberException {
+ if ((busNumber == 0) || (busNumber == 1)) {
+ return "/dev/i2c-" + busNumber;
+ }
+ throw new UnsupportedBusNumberException();
+ }
+}
@@ -0,0 +1,51 @@
+package com.pi4j.io.serial;
+
+/*
+ * #%L
+ * **********************************************************************
+ * ORGANIZATION : Pi4J
+ * PROJECT : Pi4J :: Java Library (Core)
+ * FILENAME : BananaProSerial.java
+ *
+ * This file is part of the Pi4J project. More information about
+ * this project can be found here: http://www.pi4j.com/
+ * **********************************************************************
+ * %%
+ * Copyright (C) 2012 - 2016 Pi4J
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * This class simply exposed the available UART/serial port
+ * address (device file paths) that are exposed on the BananaPro.
+ */
+public class OrangePiSerial {
+
+ // (UART0)
+ public static final String UART0_COM_PORT = "/dev/ttyS0";
+
+ // (UART2)
+ public static final String UART2_COM_PORT = "/dev/ttyS2";
+
+ // (UART3)
+ public static final String UART3_COM_PORT = "/dev/ttyS3";
+
+ // (UART7)
+ public static final String UART7_COM_PORT = "/dev/ttyS3";
+
+ public static final String DEFAULT_COM_PORT = UART3_COM_PORT;
+}
@@ -29,20 +29,14 @@
* #L%
*/
-import com.pi4j.io.gpio.BananaPiGpioProvider;
-import com.pi4j.io.gpio.BananaProGpioProvider;
-import com.pi4j.io.gpio.GpioProvider;
-import com.pi4j.io.gpio.OdroidGpioProvider;
-import com.pi4j.io.gpio.RaspiGpioProvider;
+import com.pi4j.io.gpio.*;
import com.pi4j.io.i2c.I2CFactoryProvider;
import com.pi4j.io.i2c.impl.I2CFactoryProviderBananaPi;
import com.pi4j.io.i2c.impl.I2CFactoryProviderOdroid;
+import com.pi4j.io.i2c.impl.I2CFactoryProviderOrangePi;
import com.pi4j.io.i2c.impl.I2CFactoryProviderRaspberryPi;
import com.pi4j.system.SystemInfoProvider;
-import com.pi4j.system.impl.BananaPiSystemInfoProvider;
-import com.pi4j.system.impl.BananaProSystemInfoProvider;
-import com.pi4j.system.impl.OdroidSystemInfoProvider;
-import com.pi4j.system.impl.RaspiSystemInfoProvider;
+import com.pi4j.system.impl.*;
/**
* <p>
@@ -58,7 +52,8 @@
RASPBERRYPI("raspberrypi", "Raspberry Pi"),
BANANAPI("bananapi", "BananaPi"),
BANANAPRO("bananapro", "BananaPro"),
- ODROID("odroid", "Odroid");
+ ODROID("odroid", "Odroid"),
+ ORANGEPI("orangepi", "OrangePi");
// private variables
protected String platformId = null;
@@ -138,6 +133,9 @@ public static GpioProvider getGpioProvider(Platform platform) {
case ODROID: {
return new OdroidGpioProvider();
}
+ case ORANGEPI: {
+ return new OrangePiGpioProvider();
+ }
default: {
// if a platform cannot be determine, then assume it's the default RaspberryPi
return new RaspiGpioProvider();
@@ -164,6 +162,9 @@ public static I2CFactoryProvider getI2CFactoryProvider(Platform platform) {
case ODROID: {
return new I2CFactoryProviderOdroid();
}
+ case ORANGEPI: {
+ return new I2CFactoryProviderOrangePi();
+ }
default: {
// if a platform cannot be determine, then assume it's the default RaspberryPi
return new I2CFactoryProviderRaspberryPi();
@@ -190,6 +191,9 @@ public static SystemInfoProvider getSystemInfoProvider(Platform platform) {
case ODROID: {
return new OdroidSystemInfoProvider();
}
+ case ORANGEPI: {
+ return new OrangePiSystemInfoProvider();
+ }
default: {
// if a platform cannot be determine, then assume it's the default RaspberryPi
return new RaspiSystemInfoProvider();
@@ -58,7 +58,9 @@ private SystemInfo() {
BananaPi,
BananaPro,
//------------------------
- Odroid
+ Odroid,
+ //------------------------
+ OrangePi
}
public static String getProcessor() throws IOException, InterruptedException, UnsupportedOperationException {
Oops, something went wrong.

0 comments on commit 291808c

Please sign in to comment.