Skip to content

Commit 08d0269

Browse files
committed
I/O: Fix PWM filenames
1 parent 1811de6 commit 08d0269

File tree

1 file changed

+4
-4
lines changed
  • java/libraries/io/src/processing/io

1 file changed

+4
-4
lines changed

java/libraries/io/src/processing/io/PWM.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public PWM(String channel) {
8989
* @webref
9090
*/
9191
public void clear() {
92-
String fn = String.format("/sys/class/pwm/%s/gpio%d/enable", chip, channel);
92+
String fn = String.format("/sys/class/pwm/%s/pwm%d/enable", chip, channel);
9393
int ret = NativeInterface.writeFile(fn, "0");
9494
if (ret < 0) {
9595
throw new RuntimeException(NativeInterface.getError(ret));
@@ -156,14 +156,14 @@ public static String[] list() {
156156
*/
157157
public void set(int period, float duty) {
158158
// set period
159-
String fn = fn = String.format("/sys/class/pwm/%s/gpio%d/period", chip, channel);
159+
String fn = fn = String.format("/sys/class/pwm/%s/pwm%d/period", chip, channel);
160160
int ret = NativeInterface.writeFile(fn, String.format("%d", (int)(1000000000 / period)));
161161
if (ret < 0) {
162162
throw new RuntimeException(fn + ": " + NativeInterface.getError(ret));
163163
}
164164

165165
// set duty cycle
166-
fn = fn = String.format("/sys/class/pwm/%s/gpio%d/duty", chip, channel);
166+
fn = fn = String.format("/sys/class/pwm/%s/pwm%d/duty", chip, channel);
167167
if (duty < 0.0 || 1.0 < duty) {
168168
System.err.println("Duty cycle must be between 0.0 and 1.0.");
169169
throw new IllegalArgumentException("Illegal argument");
@@ -174,7 +174,7 @@ public void set(int period, float duty) {
174174
}
175175

176176
// enable output
177-
fn = String.format("/sys/class/pwm/%s/gpio%d/enable", chip, channel);
177+
fn = String.format("/sys/class/pwm/%s/pwm%d/enable", chip, channel);
178178
ret = NativeInterface.writeFile(fn, "1");
179179
if (ret < 0) {
180180
throw new RuntimeException(fn + ": " + NativeInterface.getError(ret));

0 commit comments

Comments
 (0)