File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
java/libraries/io/src/processing/io Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff 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 ));
You can’t perform that action at this time.
0 commit comments