Skip to content

Commit

Permalink
Merge pull request #69 from taartspi/TestPwm_11_17
Browse files Browse the repository at this point in the history
validate testPwm java 11 and 17
  • Loading branch information
taartspi authored Sep 1, 2023
2 parents 3fcb66f + 66a4814 commit 150b60a
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- JAVA COMPILER VERSIONS -->
<java.version>11</java.version>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
Expand Down Expand Up @@ -121,6 +121,11 @@
<artifactId>pi4j-core</artifactId>
<version>${pi4j.version}</version>
</dependency>
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-plugin-pigpio</artifactId>
<version>${pi4j.version}</version>
</dependency>
<!--- log4j version 2 -->
<!--dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down
81 changes: 81 additions & 0 deletions src/main/java/com/pi4j/devices/neopixel94v/TestPwm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
*
*
* *
* * -
* * #%L
* * **********************************************************************
* * ORGANIZATION : Pi4J
* * PROJECT : Pi4J :: EXTENSION
* * FILENAME : TestPwm.java
* *
* * This file is part of the Pi4J project. More information about
* * this project can be found here: https://pi4j.com/
* * **********************************************************************
* * %%
* * * Copyright (C) 2012 - 2022 Pi4J
* * %%
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
* * #L%
* *
*
*
*
*/

package com.pi4j.devices.neopixel94v;
import com.pi4j.*;
import com.pi4j.io.pwm.*;
import com.pi4j.context.Context;
import com.pi4j.io.gpio.digital.*;
import com.pi4j.library.pigpio.PiGpio;

public class TestPwm {
private static Pwm pwm = null;
private static Context pi4j;

public static void main(String[] args) throws Exception
{
pi4j = Pi4J.newAutoContext();
initPiGpio();
initGPIOCM4();
pwm.on(50,1);
while (true){
// Timeout here?
}
}

private static void initPiGpio()
{
var pigpio = PiGpio.newNativeInstance();
pigpio.gpioCfgClock(2, 1, 0);
pigpio.initialize();
}

private static void initGPIOCM4()
{
var configPwm = Pwm.newConfigBuilder(pi4j)
.address(13)
.pwmType(PwmType.HARDWARE)
.provider("pigpio-pwm")
.initial(0)
.shutdown(0)
.build();
try {
pwm = pi4j.create(configPwm);
} catch (Exception e) {
}
}

}
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Pi4J MODULES
requires com.pi4j;
requires com.pi4j.plugin.pigpio;
requires com.pi4j.library.pigpio;

// SLF4J MODULES LOG4J
requires org.slf4j;
Expand Down

0 comments on commit 150b60a

Please sign in to comment.