com.pi4j.library.pigpio.test.Init Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pi4j-library-pigpio Show documentation
Show all versions of pi4j-library-pigpio Show documentation
Pi4J wrapper for the PIGPIO library
package com.pi4j.library.pigpio.test;
/*-
* #%L
* **********************************************************************
* ORGANIZATION : Pi4J
* PROJECT : Pi4J :: LIBRARY :: JNI Wrapper for PIGPIO Library
* FILENAME : Init.java
*
* This file is part of the Pi4J project. More information about
* this project can be found here: https://pi4j.com/
* **********************************************************************
*
* 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
* .
* #L%
*/
import com.pi4j.library.pigpio.PiGpio;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
/**
* Main class.
*
* @author Robert Savage (http://www.savagehomeautomation.com)
* @version $Id: $Id
*/
public class Init {
private static final Logger logger = LoggerFactory.getLogger(Init.class);
/**
* main.
*
* @param args an array of {@link String} objects.
*/
public static void main(String[] args) {
String loglevel = "INFO";
if(args != null && args.length > 0){
Level lvl = Level.valueOf(args[0].toUpperCase());
loglevel = lvl.name();
}
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", loglevel);
// create native PiGpio instance
PiGpio piGpio = PiGpio.newNativeInstance();
logger.info("");
logger.info("");
logger.info("-----------------------------------------------------");
logger.info("-----------------------------------------------------");
logger.info("Pi4J Library :: PIGPIO (Native) JNI Wrapper Library");
logger.info("-----------------------------------------------------");
logger.info("-----------------------------------------------------");
int init = piGpio.gpioInitialise();
if(init < 0){
logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: {}", init);
} else {
logger.info("PIGPIO INITIALIZED SUCCESSFULLY");
}
logger.info("PIGPIO VERSION : {}", piGpio.gpioVersion());
logger.info("PIGPIO HARDWARE : {}", Long.toHexString(piGpio.gpioHardwareRevision()));
piGpio.gpioTerminate();
logger.info("PIGPIO TERMINATED");
logger.info("-----------------------------------------------------");
logger.info("");
logger.info("");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy