GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — I/O: Another filename fix for PWM · dimr/processing@46185d7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • java/libraries/io/src/processing/io
    • PWM.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: java/libraries/io/src/processing/io/PWM.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,19 @@ public static String[] list() {
157157
public void set(int period, float duty) {
158158
// set period
159159
String fn = fn = String.format("/sys/class/pwm/%s/pwm%d/period", chip, channel);
160+
// convert to nanoseconds
160161
int ret = NativeInterface.writeFile(fn, String.format("%d", (int)(1000000000 / period)));
161162
if (ret < 0) {
162163
throw new RuntimeException(fn + ": " + NativeInterface.getError(ret));
163164
}
164165

165166
// set duty cycle
166-
fn = fn = String.format("/sys/class/pwm/%s/pwm%d/duty", chip, channel);
167+
fn = fn = String.format("/sys/class/pwm/%s/pwm%d/duty_cycle", chip, channel);
167168
if (duty < 0.0 || 1.0 < duty) {
168169
System.err.println("Duty cycle must be between 0.0 and 1.0.");
169170
throw new IllegalArgumentException("Illegal argument");
170171
}
172+
// convert to nanoseconds
171173
ret = NativeInterface.writeFile(fn, String.format("%d", (int)((1000000000 * duty) / period)));
172174
if (ret < 0) {
173175
throw new RuntimeException(fn + ": " + NativeInterface.getError(ret));

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.