From 27318e0acf67d79d3a43596dec842fc41f69a9f9 Mon Sep 17 00:00:00 2001 From: Tom Aarts Date: Sun, 25 Oct 2026 17:26:01 -0500 Subject: [PATCH 1/8] beging cmd support got fs90r --- .../java/com/pi4j/devices/fs90r/Fs90rApp.java | 337 ++++++++++-------- .../commandhandler/DoubleMappedParameter.java | 36 ++ .../utils/commandhandler/DoubleParameter.java | 30 ++ 3 files changed, 252 insertions(+), 151 deletions(-) create mode 100644 src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java create mode 100644 src/main/java/com/pi4j/examples/utils/commandhandler/DoubleParameter.java diff --git a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java index b0118d4..56a0f75 100644 --- a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java +++ b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java @@ -6,189 +6,224 @@ package com.pi4j.devices.fs90r; - -import com.pi4j.drivers.motor.fs90r.Fs90rDriver; -import com.pi4j.io.pwm.Pwm; -import com.pi4j.io.pwm.PwmConfigBuilder; -import com.pi4j.boardinfo.util.PwmChipUtil; import com.pi4j.Pi4J; +import com.pi4j.boardinfo.util.PwmChipUtil; import com.pi4j.context.Context; +import com.pi4j.drivers.motor.fs90r.Fs90rDriver; +import com.pi4j.examples.utils.commandhandler.DeviceCommandHandler; +import com.pi4j.examples.utils.commandhandler.DoubleParameter; +import com.pi4j.examples.utils.commandhandler.IntegerParameter; +import com.pi4j.examples.utils.commandhandler.DoubleMappedParameter; +import com.pi4j.io.pwm.Pwm; import com.pi4j.io.pwm.PwmConfig; +import com.pi4j.io.pwm.PwmConfigBuilder; import com.pi4j.io.pwm.PwmType; import com.pi4j.util.Console; import com.pi4j.util.Delay; - /** - * Example implementation for a FS90R servo motor. - * The Fs90R defines a specific PWM interface and exactly how the PWN signal - * controls the servo - * - * https://www.pololu.com/product/2820 - * - * See the README.md file for example usage and explanation. - * - * FS90R servo motor control. The driver will use the PWM device created by - * this app. It is assumed the device is a HardWare PWM. Hardware PWM creates - * a more consistent PWM signal. - */ - public class Fs90rApp { +import java.text.DecimalFormat; +import java.text.NumberFormat; + +/** + * Example implementation for a FS90R servo motor. + * The Fs90R defines a specific PWM interface and exactly how the PWN signal + * controls the servo + *

+ * https://www.pololu.com/product/2820 + *

+ * See the README.md file for example usage and explanation. + *

+ * FS90R servo motor control. The driver will use the PWM device created by + * this app. It is assumed the device is a HardWare PWM. Hardware PWM creates + * a more consistent PWM signal. + */ +public class Fs90rApp { - private static final int DEFAULT_PWM_FREQUENCY = 50; - private static final int DEFAULT_CHANNEL_NUMBER = 2; - private static final int SERVO_NUMBER = 1; + private static final int DEFAULT_PWM_FREQUENCY = 50; + private static final int DEFAULT_CHANNEL_NUMBER = 2; + private static final int SERVO_NUMBER = 1; + private static final NumberFormat FORMAT = new DecimalFormat("0.###"); + private static double degree = 90.0; + private static Integer channel = DEFAULT_CHANNEL_NUMBER; + private static Console console; + private static Fs90rDriver fs90R; + private static final Delay delay = new Delay(); + private static java.util.Scanner scanner; + private static double lowPulse = 1000.0; - private static double degree = 90.0; - private static Integer channel = DEFAULT_CHANNEL_NUMBER ; - private static Console console ; - private static Fs90rDriver fs90R ; - private static final Delay delay = new Delay(); - private static java .util.Scanner scanner; - private static double lowPulse = 1000.0; - private static double highPulse = 2000.0; + private static double highPulse = 2000.0; + public Fs90rApp() { + super(); - public Fs90rApp() { - super(); + } - } + /** + *

main.

+ * See the README.md file for example usage. + * + * @param args an array of {@link java.lang.String} objects. + * @throws java.lang.Exception if any. + */ + static void main(String[] args) throws Exception { + System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "INFO"); + int onlyOne = 0; // numerous parms a mutually exclusive - /** - *

main.

- * See the README.md file for example usage. - * @param args an array of {@link java.lang.String} objects. - * @throws java.lang.Exception if any. - */ - static void main(String[] args) throws Exception { - System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "INFO"); - - int onlyOne = 0; // numerous parms a mutually exclusive - - scanner = new java.util.Scanner(System.in); - - console = new Console(); - Context pi4j = Pi4J.newAutoContext(); - console.title("<-- The Pi4J V5 Project Extension -->", "Fs90rApp"); - String helpString = " Parms: -c channel -cw (clockwise) S M F -ccw (counter-clockwise) S M F -h HELP \n" + - " -low microseconds -high microseconds -cw -ccw mutually exclusive -d degree \n" + - " degree must be in the range 0..180. 90 stop, 0..89 CW, 91..180 CCW "; - - - for (int i = 0; i < args.length; i++) { - String o = args[i]; - if (o.contentEquals("-low")) { - String a = args[i + 1]; - lowPulse = Double.parseDouble(a.substring(0)); - i++; - } else if (o.contentEquals("-high")) { - String a = args[i + 1]; - highPulse = Double.parseDouble(a.substring(0)); - i++; - } else if (o.contentEquals("-d")) { - String a = args[i + 1]; - degree = Double.parseDouble(a.substring(0)); - if((!Double.isFinite(degree) || degree < 0) || (degree > 180)){ - console.println("-d degree must be in range 0..180"); - System.exit(40); - } - onlyOne++; - i++; - } else if (o.contentEquals("-c")) { - String a = args[i + 1]; - channel = Integer.parseInt(a.substring(0)); - i++; - } else if (o.contentEquals("-cw")) { /* 0-89 */ - String a = args[i + 1]; - onlyOne++; - i++; - if (a.equalsIgnoreCase("S")) { - degree = 75.0; - } else if (a.equalsIgnoreCase("M")) { - degree = 40.0; - } else if (a.equalsIgnoreCase("F")) { - degree = 0.0; - } else { - console.println(" -cw invalid "); - System.exit(41); - } - } else if (o.contentEquals("-ccw")) { /* 191-180 */ - String a = args[i + 1]; - i++; - onlyOne++; - if (a.equalsIgnoreCase("S")) { - degree = 105.0; - } else if (a.equalsIgnoreCase("M")) { - degree = 140.0; - } else if (a.equalsIgnoreCase("F")) { - degree = 180.0; - } else { - console.println(" -ccw invalid "); - System.exit(42); - } - } else if (o.contentEquals("-q")) { - console.println("Exit"); - System.exit(0); - } else if (o.contentEquals("-h")) { - console.println(helpString); - System.exit(0); - }else { - console.println(" !!! Invalid Parm " + o); - console.println(helpString); - System.exit(43); - } - } + scanner = new java.util.Scanner(System.in); - if (onlyOne > 1 ) { - console.println(" mutually exclusive parms used."); + console = new Console(); + Context pi4j = Pi4J.newAutoContext(); + console.title("<-- The Pi4J V5 Project Extension -->", "Fs90rApp"); + String helpString = " Parms: -c channel -cw (clockwise) S M F -ccw (counter-clockwise) S M F -h HELP \n" + + " -low microseconds -high microseconds -cw -ccw mutually exclusive -d degree \n" + + " degree must be in the range 0..180. 90 stop, 0..89 CW, 91..180 CCW "; + + DeviceCommandHandler commandHandler = new DeviceCommandHandler<>(settings -> + new Fs90rDriver(pi4j.create(Pwm.newConfigBuilder() + .channel((Integer) settings.get("c")) + .id("fs90RNumber" + SERVO_NUMBER) + .name("fs90R number " + SERVO_NUMBER) + .pwmType(PwmType.HARDWARE) + .chip(PwmChipUtil.getPWMChip()) + .frequency(DEFAULT_PWM_FREQUENCY)))); + + + // -cw -ccw -d mutually exclusive + commandHandler.configuration( + "c", + "Set the PWM channel number", + new IntegerParameter(0, 127), + Fs90rDriver.DEFAULT_CHANNEL_NUMBER); + + commandHandler.configuration( + "low", + "Set the PWM low microseconds", + new DoubleParameter(500.0, 1500.0), + 1000.0); + + commandHandler.configuration( + "high", + "Set the PWM high microseconds", + new DoubleParameter(1500.0, 2500.00), + 2000.0); + + + + + commandHandler.configuration( + "d", + "Set the PWM rotation by degree", + new DoubleParameter(0.0, 180.0), + 90.0); + + DoubleMappedParameter.Rotation ranges[] = new DoubleMappedParameter.Rotation[]{ + new DoubleMappedParameter.Rotation("S", 75.0), + new DoubleMappedParameter.Rotation("M", 48.0), + new DoubleMappedParameter.Rotation("F", 0.0) + }; + + commandHandler.configuration( + "cw", + "Set the PWM rotation by range S M F", + DoubleMappedParameter(ranges), + 90.0); + + + + for (int i = 0; i < args.length; i++) { + String o = args[i]; + if (o.contentEquals("-cw")) { /* 0-89 */ + String a = args[i + 1]; + onlyOne++; + i++; + if (a.equalsIgnoreCase("S")) { + degree = 75.0; + } else if (a.equalsIgnoreCase("M")) { + degree = 40.0; + } else if (a.equalsIgnoreCase("F")) { + degree = 0.0; + } else { + console.println(" -cw invalid "); + System.exit(41); + } + } else if (o.contentEquals("-ccw")) { /* 191-180 */ + String a = args[i + 1]; + i++; + onlyOne++; + if (a.equalsIgnoreCase("S")) { + degree = 105.0; + } else if (a.equalsIgnoreCase("M")) { + degree = 140.0; + } else if (a.equalsIgnoreCase("F")) { + degree = 180.0; + } else { + console.println(" -ccw invalid "); + System.exit(42); + } + } else if (o.contentEquals("-q")) { + console.println("Exit"); + System.exit(0); + } else if (o.contentEquals("-h")) { + console.println(helpString); + System.exit(0); + } else { + console.println(" !!! Invalid Parm " + o); console.println(helpString); - System.exit(44); + System.exit(43); } - Pwm pwm = createPwm(SERVO_NUMBER, channel, pi4j); + } - fs90R = new Fs90rDriver(pwm, lowPulse, highPulse); + if (onlyOne > 1) { + console.println(" mutually exclusive parms used."); + console.println(helpString); + System.exit(44); + } + Pwm pwm = createPwm(SERVO_NUMBER, channel, pi4j); - // if user did not provide a -cw -ccw or -d default sets stop - fs90R.setServoRotation(degree); + fs90R = new Fs90rDriver(pwm, lowPulse, highPulse); - waitChange( 10l); + // if user did not provide a -cw -ccw or -d default sets stop + fs90R.setServoRotation(degree); - pi4j.shutdown(pwm); + waitChange(10L); - } + pi4j.shutdown(pwm); + } - static Pwm createPwm(int servoNumber, Integer channel, Context pi4j) { + static Pwm createPwm(int servoNumber, Integer channel, Context pi4j) { - final PwmConfig config = PwmConfigBuilder.newInstance (pi4j) - .id ("fs90RNumber" + servoNumber) - .name ("fs90R number " + servoNumber) - .pwmType(PwmType.HARDWARE) - .channel(channel) - .chip(PwmChipUtil.getPWMChip()) - .frequency(DEFAULT_PWM_FREQUENCY) - .build (); + final PwmConfig config = PwmConfigBuilder.newInstance(pi4j) + .id("fs90RNumber" + servoNumber) + .name("fs90R number " + servoNumber) + .pwmType(PwmType.HARDWARE) + .channel(channel) + .chip(PwmChipUtil.getPWMChip()) + .frequency(DEFAULT_PWM_FREQUENCY) + .build(); - return pi4j.create (config); - } + return pi4j.create(config); + } - static void waitChange(long c){ - while(true){ - delay.setMillis(c).materialize(); - console.println("Enter q - quit, or degree value "); - if (scanner.hasNextInt() ) { - double nextDegree = scanner.nextDouble(); - if((!Double.isFinite(nextDegree) || nextDegree < 0) || (nextDegree > 180)){ - console.println(" degree must be in the range 0..180. 90 stop, 0..89 CW, 91..180 CCW"); - }else { - fs90R.setServoRotation(nextDegree); - } - } else{ - break; + static void waitChange(long c) { + while (true) { + delay.setMillis(c).materialize(); + console.println("Enter q - quit, or degree value "); + if (scanner.hasNextInt()) { + double nextDegree = scanner.nextDouble(); + if ((!Double.isFinite(nextDegree) || nextDegree < 0) || (nextDegree > 180)) { + console.println(" degree must be in the range 0..180. 90 stop, 0..89 CW, 91..180 CCW"); + } else { + fs90R.setServoRotation(nextDegree); } + } else { + break; } } } +} diff --git a/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java b/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java new file mode 100644 index 0000000..c14ac55 --- /dev/null +++ b/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java @@ -0,0 +1,36 @@ +package com.pi4j.examples.utils.commandhandler; + +public class DoubleMappedParameter extends ParameterSpecification{}{} { + + + // Define the data structure + public record Rotation(String name, double rpm) {} + + Rotation[] ranges; + + + public DoubleMappedParameter(Rotation[] input) { + ranges = input; + } + + @Override + Double process(String text) { + double rotation = 90.0; + for(Rotation ranges : ranges){ + if (text.equalsIgnoreCase(ranges.name)){ + return ranges.rpm; + } + } + throw new IllegalArgumentException("Value " + text); + } + +@Override +public String toString() { + String options = ""; + for(Rotation ranges : ranges){ + options+= ranges.name; + } + + return "Permissible options [" + options + "] "; + } +} diff --git a/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleParameter.java b/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleParameter.java new file mode 100644 index 0000000..4fc5d1f --- /dev/null +++ b/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleParameter.java @@ -0,0 +1,30 @@ +package com.pi4j.examples.utils.commandhandler; + +public class DoubleParameter extends ParameterSpecification { + private final double min; + private final double max; + + public DoubleParameter(double min, double max) { + if( !Double.isFinite(min) ) { + throw new IllegalArgumentException("Value " + min); + } + if( !Double.isFinite(max) ) { + throw new IllegalArgumentException("Value " + max); + } + this.min = min; + this.max = max; + } + + @Override + Double process(String text) { + double parsed = Double.parseDouble(text); + if (parsed < min || parsed > max) { + throw new IllegalArgumentException("Value " + text); + } + return parsed; + } + + public String toString() { + return "[" + min + ".." + max + "] / [0x" + Double.toHexString(min) + "..0x" + Double.toHexString(max) + "]"; + } +} From 4a1ac404f291178e87b9b62af56c2798146aaa6f Mon Sep 17 00:00:00 2001 From: Tom Aarts Date: Mon, 26 Oct 2026 13:15:31 -0500 Subject: [PATCH 2/8] updates to Fs90r to use new command structure. At present there are 3 places marked by TODO. They are questions --- .../pi4j/devices/bmp280/BMP280I2cExample.java | 2 + .../java/com/pi4j/devices/fs90r/Fs90rApp.java | 117 +++++------------- .../java/com/pi4j/devices/fs90r/README.md | 2 +- .../commandhandler/DoubleMappedParameter.java | 4 +- 4 files changed, 39 insertions(+), 86 deletions(-) diff --git a/src/main/java/com/pi4j/devices/bmp280/BMP280I2cExample.java b/src/main/java/com/pi4j/devices/bmp280/BMP280I2cExample.java index c27907d..0a45268 100644 --- a/src/main/java/com/pi4j/devices/bmp280/BMP280I2cExample.java +++ b/src/main/java/com/pi4j/devices/bmp280/BMP280I2cExample.java @@ -55,6 +55,8 @@ static void main(String[] args) { System.out.println("Humidity: " + FORMAT.format(measurement.getHumidity()) + " %"); }); + + commandHandler.setDefault("r"); commandHandler.process(args); diff --git a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java index 56a0f75..43f0d9a 100644 --- a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java +++ b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java @@ -15,15 +15,10 @@ import com.pi4j.examples.utils.commandhandler.IntegerParameter; import com.pi4j.examples.utils.commandhandler.DoubleMappedParameter; import com.pi4j.io.pwm.Pwm; -import com.pi4j.io.pwm.PwmConfig; -import com.pi4j.io.pwm.PwmConfigBuilder; import com.pi4j.io.pwm.PwmType; import com.pi4j.util.Console; import com.pi4j.util.Delay; -import java.text.DecimalFormat; -import java.text.NumberFormat; - /** * Example implementation for a FS90R servo motor. * The Fs90R defines a specific PWM interface and exactly how the PWN signal @@ -38,21 +33,10 @@ * a more consistent PWM signal. */ public class Fs90rApp { - - private static final int DEFAULT_PWM_FREQUENCY = 50; - private static final int DEFAULT_CHANNEL_NUMBER = 2; private static final int SERVO_NUMBER = 1; - private static final NumberFormat FORMAT = new DecimalFormat("0.###"); - - private static double degree = 90.0; - private static Integer channel = DEFAULT_CHANNEL_NUMBER; private static Console console; - private static Fs90rDriver fs90R; private static final Delay delay = new Delay(); private static java.util.Scanner scanner; - private static double lowPulse = 1000.0; - - private static double highPulse = 2000.0; public Fs90rApp() { super(); @@ -87,7 +71,7 @@ static void main(String[] args) throws Exception { .name("fs90R number " + SERVO_NUMBER) .pwmType(PwmType.HARDWARE) .chip(PwmChipUtil.getPWMChip()) - .frequency(DEFAULT_PWM_FREQUENCY)))); + .frequency(Fs90rDriver.DEFAULT_PWM_FREQUENCY)))); // -cw -ccw -d mutually exclusive @@ -109,16 +93,13 @@ static void main(String[] args) throws Exception { new DoubleParameter(1500.0, 2500.00), 2000.0); - - - commandHandler.configuration( "d", "Set the PWM rotation by degree", new DoubleParameter(0.0, 180.0), 90.0); - DoubleMappedParameter.Rotation ranges[] = new DoubleMappedParameter.Rotation[]{ + DoubleMappedParameter.Rotation rangesCw[] = new DoubleMappedParameter.Rotation[]{ new DoubleMappedParameter.Rotation("S", 75.0), new DoubleMappedParameter.Rotation("M", 48.0), new DoubleMappedParameter.Rotation("F", 0.0) @@ -126,97 +107,65 @@ static void main(String[] args) throws Exception { commandHandler.configuration( "cw", - "Set the PWM rotation by range S M F", - DoubleMappedParameter(ranges), + "Set the PWM rotation cw by range S M F", + new DoubleMappedParameter(rangesCw), 90.0); + DoubleMappedParameter.Rotation rangesCcw[] = new DoubleMappedParameter.Rotation[]{ + new DoubleMappedParameter.Rotation("S", 105.0), + new DoubleMappedParameter.Rotation("M", 148.0), + new DoubleMappedParameter.Rotation("F", 180.0) + }; + commandHandler.configuration( + "ccw", + "Set the PWM rotation ccw by range S M F", + new DoubleMappedParameter(rangesCcw), + 90.0); + + // TODO I couldn't see how to get the -d -cw or -ccw argument value + commandHandler.action("degree", "Set servo motor to this degree (default)", device -> { + device.setServoRotation((double) 180.0); // set to allow testing + System.out.println("Servo degree set to : " + "???"); + }); - for (int i = 0; i < args.length; i++) { - String o = args[i]; - if (o.contentEquals("-cw")) { /* 0-89 */ - String a = args[i + 1]; - onlyOne++; - i++; - if (a.equalsIgnoreCase("S")) { - degree = 75.0; - } else if (a.equalsIgnoreCase("M")) { - degree = 40.0; - } else if (a.equalsIgnoreCase("F")) { - degree = 0.0; - } else { - console.println(" -cw invalid "); - System.exit(41); - } - } else if (o.contentEquals("-ccw")) { /* 191-180 */ - String a = args[i + 1]; - i++; - onlyOne++; - if (a.equalsIgnoreCase("S")) { - degree = 105.0; - } else if (a.equalsIgnoreCase("M")) { - degree = 140.0; - } else if (a.equalsIgnoreCase("F")) { - degree = 180.0; - } else { - console.println(" -ccw invalid "); - System.exit(42); - } - } else if (o.contentEquals("-q")) { - console.println("Exit"); - System.exit(0); - } else if (o.contentEquals("-h")) { - console.println(helpString); - System.exit(0); - } else { - console.println(" !!! Invalid Parm " + o); - console.println(helpString); - System.exit(43); - } - } + // I prefer to handle this in code rather than only documentation. low prioroty I can worry about ;ater if (onlyOne > 1) { console.println(" mutually exclusive parms used."); console.println(helpString); System.exit(44); } - Pwm pwm = createPwm(SERVO_NUMBER, channel, pi4j); - fs90R = new Fs90rDriver(pwm, lowPulse, highPulse); + commandHandler.setDefault("degree"); - // if user did not provide a -cw -ccw or -d default sets stop - fs90R.setServoRotation(degree); + commandHandler.process(args); - waitChange(10L); - pi4j.shutdown(pwm); + // TODO how to force the action "degree" + // commandHandler.configu..process("degree"); - } - static Pwm createPwm(int servoNumber, Integer channel, Context pi4j) { + waitChange(10L); - final PwmConfig config = PwmConfigBuilder.newInstance(pi4j) - .id("fs90RNumber" + servoNumber) - .name("fs90R number " + servoNumber) - .pwmType(PwmType.HARDWARE) - .channel(channel) - .chip(PwmChipUtil.getPWMChip()) - .frequency(DEFAULT_PWM_FREQUENCY) - .build(); - return pi4j.create(config); + // Shutdown Pi4J + pi4j.shutdown(); + } + static void waitChange(long c) { while (true) { delay.setMillis(c).materialize(); - console.println("Enter q - quit, or degree value "); + console.println("Enter - to quit, or degree value "); if (scanner.hasNextInt()) { double nextDegree = scanner.nextDouble(); if ((!Double.isFinite(nextDegree) || nextDegree < 0) || (nextDegree > 180)) { console.println(" degree must be in the range 0..180. 90 stop, 0..89 CW, 91..180 CCW"); } else { - fs90R.setServoRotation(nextDegree); + // TODO this will require on the fly changing an action value + // this no longer used, left as a Note fs90R.setServoRotation(nextDegree); } } else { break; diff --git a/src/main/java/com/pi4j/devices/fs90r/README.md b/src/main/java/com/pi4j/devices/fs90r/README.md index b266a57..9d157b8 100644 --- a/src/main/java/com/pi4j/devices/fs90r/README.md +++ b/src/main/java/com/pi4j/devices/fs90r/README.md @@ -50,7 +50,7 @@ Yellow GPIO18 config.sys contains dtoverlay=pwm-2chan -ccw counter-clockwise S M F -low double pulse width for 0 degree microseconds -high double pulse width for 180 degree microseconds --q quit servo will stop +-x quit servo will stop Application running, awaiting input of 0-180 degree diff --git a/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java b/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java index c14ac55..94c7d09 100644 --- a/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java +++ b/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java @@ -1,6 +1,8 @@ package com.pi4j.examples.utils.commandhandler; -public class DoubleMappedParameter extends ParameterSpecification{}{} { +public class DoubleMappedParameter extends ParameterSpecification{ + + // Define the data structure From 67c8e0928e9596f8c47b3fd22a7eae434343679c Mon Sep 17 00:00:00 2001 From: Tom Aarts Date: Mon, 26 Oct 2026 13:15:31 -0500 Subject: [PATCH 3/8] Updates trying parameterizedAction updates to Fs90r to use new command structure. At present there are 3 places marked by TODO. They are questions # Conflicts: # src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java --- .../java/com/pi4j/devices/fs90r/Fs90rApp.java | 30 +++++++++++++------ .../utils/commandhandler/DoubleParameter.java | 7 +++-- .../ParameterSpecificationSetDegree.java | 14 +++++++++ 3 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/pi4j/examples/utils/commandhandler/ParameterSpecificationSetDegree.java diff --git a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java index 43f0d9a..c7c10c2 100644 --- a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java +++ b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java @@ -34,6 +34,7 @@ */ public class Fs90rApp { private static final int SERVO_NUMBER = 1; + private static final int PWM_CHANNEL = 2; private static Console console; private static final Delay delay = new Delay(); private static java.util.Scanner scanner; @@ -71,7 +72,7 @@ static void main(String[] args) throws Exception { .name("fs90R number " + SERVO_NUMBER) .pwmType(PwmType.HARDWARE) .chip(PwmChipUtil.getPWMChip()) - .frequency(Fs90rDriver.DEFAULT_PWM_FREQUENCY)))); + .frequency(Fs90rDriver.PWM_FREQUENCY)))); // -cw -ccw -d mutually exclusive @@ -79,7 +80,7 @@ static void main(String[] args) throws Exception { "c", "Set the PWM channel number", new IntegerParameter(0, 127), - Fs90rDriver.DEFAULT_CHANNEL_NUMBER); + PWM_CHANNEL); commandHandler.configuration( "low", @@ -123,28 +124,38 @@ static void main(String[] args) throws Exception { new DoubleMappedParameter(rangesCcw), 90.0); - // TODO I couldn't see how to get the -d -cw or -ccw argument value + + // TODO compiles. + // 1. How to pull the value from settings I want the value from say -cw to be used. I could obtain the value + // first and call something similar to this passing in the double. + // 2. How to call directly, from interactive data passing the new double value + // appears setting this label as default it is not invoked + commandHandler.parameterizedAction("setDegree", "Set servo degree", new DoubleParameter(0.0, 180), (device, pt) -> { + device.setServoRotation(pt); // set to allow testing + System.out.println("Servo degree set to : " + pt); + }); + + + + commandHandler.action("degree", "Set servo motor to this degree (default)", device -> { device.setServoRotation((double) 180.0); // set to allow testing System.out.println("Servo degree set to : " + "???"); }); - // I prefer to handle this in code rather than only documentation. low prioroty I can worry about ;ater + // I prefer to handle this in code rather than only documentation. low priority I can worry about later if (onlyOne > 1) { console.println(" mutually exclusive parms used."); console.println(helpString); System.exit(44); } - commandHandler.setDefault("degree"); + commandHandler.setDefault("setDegree"); commandHandler.process(args); - // TODO how to force the action "degree" - // commandHandler.configu..process("degree"); - waitChange(10L); @@ -164,7 +175,8 @@ static void waitChange(long c) { if ((!Double.isFinite(nextDegree) || nextDegree < 0) || (nextDegree > 180)) { console.println(" degree must be in the range 0..180. 90 stop, 0..89 CW, 91..180 CCW"); } else { - // TODO this will require on the fly changing an action value + // TODO this will require on the fly changing an action value . This was + // mentioned in the earlier TODO // this no longer used, left as a Note fs90R.setServoRotation(nextDegree); } } else { diff --git a/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleParameter.java b/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleParameter.java index 4fc5d1f..0c983c7 100644 --- a/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleParameter.java +++ b/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleParameter.java @@ -11,6 +11,9 @@ public DoubleParameter(double min, double max) { if( !Double.isFinite(max) ) { throw new IllegalArgumentException("Value " + max); } + if( min >= max ) { + throw new IllegalArgumentException("min is NOT less than max"); + } this.min = min; this.max = max; } @@ -19,12 +22,12 @@ public DoubleParameter(double min, double max) { Double process(String text) { double parsed = Double.parseDouble(text); if (parsed < min || parsed > max) { - throw new IllegalArgumentException("Value " + text); + throw new IllegalArgumentException("Value " + text + " Valid range " + Double.toString(min) + " ... " + Double.toString(max) ); } return parsed; } public String toString() { - return "[" + min + ".." + max + "] / [0x" + Double.toHexString(min) + "..0x" + Double.toHexString(max) + "]"; + return "[" + min + ".." + max + "] / [" + Double.toString(min) + ".." + Double.toString(max) + "]"; } } diff --git a/src/main/java/com/pi4j/examples/utils/commandhandler/ParameterSpecificationSetDegree.java b/src/main/java/com/pi4j/examples/utils/commandhandler/ParameterSpecificationSetDegree.java new file mode 100644 index 0000000..f826c4a --- /dev/null +++ b/src/main/java/com/pi4j/examples/utils/commandhandler/ParameterSpecificationSetDegree.java @@ -0,0 +1,14 @@ +/* + * /* + * * + * + */ + +package com.pi4j.examples.utils.commandhandler; + +public class ParameterSpecificationSetDegree extends ParameterSpecification { + @Override + Double process(String value) { + return 0.0; + } +} From f8b6fa7dd559a12372b6d0d2190d7d5b195605bd Mon Sep 17 00:00:00 2001 From: Tom Aarts Date: Mon, 26 Oct 2026 13:15:31 -0500 Subject: [PATCH 4/8] update for provider change in core. Updates trying parameterizedAction updates to Fs90r to use new command structure. At present there are 3 places marked by TODO. They are questions --- .../com/pi4j/devices/is31Fl37Matrix/MonitorInterrupt.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/pi4j/devices/is31Fl37Matrix/MonitorInterrupt.java b/src/main/java/com/pi4j/devices/is31Fl37Matrix/MonitorInterrupt.java index ca927cb..793b6a8 100644 --- a/src/main/java/com/pi4j/devices/is31Fl37Matrix/MonitorInterrupt.java +++ b/src/main/java/com/pi4j/devices/is31Fl37Matrix/MonitorInterrupt.java @@ -100,7 +100,10 @@ static void main(String[] args) throws Exception { // create a digital input instance using the default digital input provider // we will use the PULL_DOWN argument to set the pin pull-down resistance on this GPIO pin var config = DigitalInput.newConfigBuilder(pi4j) - .load(properties) + .id("GPIO monitor") + .bcm(monitorPinNum) + .pull(pd) + .name("GPIO-MONITOR") .build(); monitorPin = pi4j.create(config); From c6957894ba2158be3803262f2610292d8e2a5b39 Mon Sep 17 00:00:00 2001 From: Tom Aarts Date: Mon, 26 Oct 2026 13:15:31 -0500 Subject: [PATCH 5/8] readme examples unit test updates capture working code before next changes update for provider change in core. Updates trying parameterizedAction updates to Fs90r to use new command structure. At present there are 3 places marked by TODO. They are questions --- .../java/com/pi4j/devices/fs90r/Fs90rApp.java | 116 +++--------------- .../java/com/pi4j/devices/fs90r/README.md | 75 +++++++---- .../commandhandler/DoubleMappedParameter.java | 38 ------ .../ParameterSpecificationSetDegree.java | 14 --- .../utils/commandhandler/StringParameter.java | 37 ++++++ 5 files changed, 105 insertions(+), 175 deletions(-) delete mode 100644 src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java delete mode 100644 src/main/java/com/pi4j/examples/utils/commandhandler/ParameterSpecificationSetDegree.java create mode 100644 src/main/java/com/pi4j/examples/utils/commandhandler/StringParameter.java diff --git a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java index c7c10c2..b104911 100644 --- a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java +++ b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java @@ -10,10 +10,7 @@ import com.pi4j.boardinfo.util.PwmChipUtil; import com.pi4j.context.Context; import com.pi4j.drivers.motor.fs90r.Fs90rDriver; -import com.pi4j.examples.utils.commandhandler.DeviceCommandHandler; -import com.pi4j.examples.utils.commandhandler.DoubleParameter; -import com.pi4j.examples.utils.commandhandler.IntegerParameter; -import com.pi4j.examples.utils.commandhandler.DoubleMappedParameter; +import com.pi4j.examples.utils.commandhandler.*; import com.pi4j.io.pwm.Pwm; import com.pi4j.io.pwm.PwmType; import com.pi4j.util.Console; @@ -53,17 +50,9 @@ public Fs90rApp() { */ static void main(String[] args) throws Exception { System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "INFO"); - - int onlyOne = 0; // numerous parms a mutually exclusive - - scanner = new java.util.Scanner(System.in); - console = new Console(); Context pi4j = Pi4J.newAutoContext(); console.title("<-- The Pi4J V5 Project Extension -->", "Fs90rApp"); - String helpString = " Parms: -c channel -cw (clockwise) S M F -ccw (counter-clockwise) S M F -h HELP \n" + - " -low microseconds -high microseconds -cw -ccw mutually exclusive -d degree \n" + - " degree must be in the range 0..180. 90 stop, 0..89 CW, 91..180 CCW "; DeviceCommandHandler commandHandler = new DeviceCommandHandler<>(settings -> new Fs90rDriver(pi4j.create(Pwm.newConfigBuilder() @@ -75,115 +64,48 @@ static void main(String[] args) throws Exception { .frequency(Fs90rDriver.PWM_FREQUENCY)))); - // -cw -ccw -d mutually exclusive + // -cw -ccw -degree mutually exclusive commandHandler.configuration( "c", "Set the PWM channel number", new IntegerParameter(0, 127), PWM_CHANNEL); - commandHandler.configuration( - "low", - "Set the PWM low microseconds", - new DoubleParameter(500.0, 1500.0), - 1000.0); - - commandHandler.configuration( - "high", - "Set the PWM high microseconds", - new DoubleParameter(1500.0, 2500.00), - 2000.0); - - commandHandler.configuration( - "d", - "Set the PWM rotation by degree", - new DoubleParameter(0.0, 180.0), - 90.0); - - DoubleMappedParameter.Rotation rangesCw[] = new DoubleMappedParameter.Rotation[]{ - new DoubleMappedParameter.Rotation("S", 75.0), - new DoubleMappedParameter.Rotation("M", 48.0), - new DoubleMappedParameter.Rotation("F", 0.0) - }; - - commandHandler.configuration( - "cw", - "Set the PWM rotation cw by range S M F", - new DoubleMappedParameter(rangesCw), - 90.0); + // Following qctions can be used as arguments when first invoking this program (-low value) , or + // after instantiation used on the command line (low value). - DoubleMappedParameter.Rotation rangesCcw[] = new DoubleMappedParameter.Rotation[]{ - new DoubleMappedParameter.Rotation("S", 105.0), - new DoubleMappedParameter.Rotation("M", 148.0), - new DoubleMappedParameter.Rotation("F", 180.0) - }; - commandHandler.configuration( - "ccw", - "Set the PWM rotation ccw by range S M F", - new DoubleMappedParameter(rangesCcw), - 90.0); - - - // TODO compiles. - // 1. How to pull the value from settings I want the value from say -cw to be used. I could obtain the value - // first and call something similar to this passing in the double. - // 2. How to call directly, from interactive data passing the new double value - // appears setting this label as default it is not invoked - commandHandler.parameterizedAction("setDegree", "Set servo degree", new DoubleParameter(0.0, 180), (device, pt) -> { - device.setServoRotation(pt); // set to allow testing - System.out.println("Servo degree set to : " + pt); + commandHandler.parameterizedAction("low", "Minimal pulse width", new DoubleParameter(500.0, 1500.0), (device, param) -> { + device.setPwCwMin(param); }); + commandHandler.parameterizedAction("high", "Maximum pulse width", new DoubleParameter(1500.0, 2500.0), (device, param) -> { + device.setPwCcwMax(param); + }); - - - commandHandler.action("degree", "Set servo motor to this degree (default)", device -> { - device.setServoRotation((double) 180.0); // set to allow testing - System.out.println("Servo degree set to : " + "???"); + commandHandler.parameterizedAction("cw", "clockwise rotation percentage", new DoubleParameter(0.0, 100.0), (device, param) -> { + device.setServoRotationCwByPercent(param); }); + commandHandler.parameterizedAction("ccw", "counter clockwise rotation percentage", new DoubleParameter(0.0, 100.0), (device, param) -> { + device.setServoRotationCCwByPercent(param); + }); - // I prefer to handle this in code rather than only documentation. low priority I can worry about later - if (onlyOne > 1) { - console.println(" mutually exclusive parms used."); - console.println(helpString); - System.exit(44); - } + commandHandler.parameterizedAction("degree", "rotation degree", new DoubleParameter(0.0, 180.0), (device, param) -> { + device.setServoRotationByDegree(param); + }); - commandHandler.setDefault("setDegree"); + commandHandler.parameterizedAction("", "-cw -ccw -degree mutually exclusive", new StringParameter("",""), (device, param) -> { + }); commandHandler.process(args); - - - waitChange(10L); - - // Shutdown Pi4J pi4j.shutdown(); } - static void waitChange(long c) { - while (true) { - delay.setMillis(c).materialize(); - console.println("Enter - to quit, or degree value "); - if (scanner.hasNextInt()) { - double nextDegree = scanner.nextDouble(); - if ((!Double.isFinite(nextDegree) || nextDegree < 0) || (nextDegree > 180)) { - console.println(" degree must be in the range 0..180. 90 stop, 0..89 CW, 91..180 CCW"); - } else { - // TODO this will require on the fly changing an action value . This was - // mentioned in the earlier TODO - // this no longer used, left as a Note fs90R.setServoRotation(nextDegree); - } - } else { - break; - } - } - } } diff --git a/src/main/java/com/pi4j/devices/fs90r/README.md b/src/main/java/com/pi4j/devices/fs90r/README.md index 9d157b8..c0444b5 100644 --- a/src/main/java/com/pi4j/devices/fs90r/README.md +++ b/src/main/java/com/pi4j/devices/fs90r/README.md @@ -18,16 +18,19 @@ The PWM signal sent to the servo device set the direction and RPM of rotation. The FS90 R 360 defines a specific PWM interface and exactly how the PWN signal controls the servo. There are many different manufacturers of the FS90 servo. The pulse width required for setting the servo at 0 degrees MAX Clockwise (CW) or 180 degrees - MAX CounterClockWise (CCW) varies by manufacturer. The driver by default uses the pulse width timing as - (low)1000 - (high)2000 microseconds. The user of this example application can change these defaults - when first invoking the program. + MAX CounterClockWise (CCW) varies by manufacturer (Note 1). This implementation use SE determination. + The driver by default uses the pulse width timing as (low)1000 - (high)2000 microseconds. The user of + this example application can change these values If the servo does not rotate to the expected RPM,Example to rotate faster CW reduce the -low - argument, to rotate CCW faster increase the -high argument. The -low -high change should be balanced or 90 degree will not properly align. - Meaning if you reduce the -low by 200, you should increase the -high by 200, or visa-versa. - - + argument, to rotate CCW faster increase the -high argument. The low high commands change should be balanced + or 90 degree will not properly align. Meaning if you reduce the -low by 200, you should increase the -high by 200, + or visa-versa. +Note 1 :Direction of rotation, the definition of CW and CCW has two distinct versions. These define your +perspective of observation. +- Shaft End (SE / Drive End): The end where the motor shaft and load (like a fan blade or pulley) attach. Industry convention usually assumes you are looking straight at the shaft end. +- Lead End (LE / Bell End / Opposite Drive End - ODE): The back side of the motor where the electrical wires or leads exit. https://www.pololu.com/product/2820 @@ -44,31 +47,51 @@ Yellow GPIO18 config.sys contains dtoverlay=pwm-2chan 2. cd target/distribution 3. ./runFs90r.sh args --h help --c channel (default 2) set the channel, depending on config.txt 1 2 3 4 --cw clockwise S M F --ccw counter-clockwise S M F --low double pulse width for 0 degree microseconds --high double pulse width for 180 degree microseconds --x quit servo will stop + -c channel (default 2) set the channel, depending on config.txt 1 2 3 4 + - Program will contunue to run, the following commands are possible + + + + + + +cw percent clockwise rotation at this percentage of maximum +ccw percent counterclockwise rotation at this percentage of maximum +degree double degree to set the servo +low double pulse width for 0 degree microseconds +high double pulse width for 180 degree microseconds +x quit servo will stop, program exist +h help Print commands and their range of input values + +./runFs90r.sh - application running, awaiting command input +./run*Fs90r.sh -c 1 PWM device will use channel 1 -Application running, awaiting input of 0-180 degree -./runFs90r.sh +./runFs90r.sh -c 1 - PWM device will use channel 1, application running, awaiting command input -Application running CCW, then awaiting input of 0-180 degree -./runFs90r.sh 160 +Commands +degree 180 servo will be updated to this degree value effecting direction and rotation speed +cw 50 servo will rotate clockwise at 50% rotation speed +ccw 75 servo will rotate counterclockwise at 75% rotation speed +low 550 0 degree pulse width 550 ms +high 2450 180 degree pulse width 2450 ms +x servo stops, program exist -Set output shaft Fast ClockWise, then enter 90 for stop -./runFs90r.sh -cw F - 90 +My Fs90r appears faster rotation wih these values for the low and high limmits +low 550 high 2450 +Follow +start app +1. set low and high pulse widths +2. clockwise 100% +3. clockwise 40% +4. exit -Set output shaft Slow CounterClockWise, then enter 0 for MAX soeed -./runFs90r.sh -ccw S - 0 +./runFs90r.sh - + low 550 high 2450 + cw 100 + cw 40 + x -My Fs90r appears faster rotation wih these values for the -low and -high limmits -./runFs90r.sh -low 550 -high 2450 diff --git a/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java b/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java deleted file mode 100644 index 94c7d09..0000000 --- a/src/main/java/com/pi4j/examples/utils/commandhandler/DoubleMappedParameter.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.pi4j.examples.utils.commandhandler; - -public class DoubleMappedParameter extends ParameterSpecification{ - - - - - // Define the data structure - public record Rotation(String name, double rpm) {} - - Rotation[] ranges; - - - public DoubleMappedParameter(Rotation[] input) { - ranges = input; - } - - @Override - Double process(String text) { - double rotation = 90.0; - for(Rotation ranges : ranges){ - if (text.equalsIgnoreCase(ranges.name)){ - return ranges.rpm; - } - } - throw new IllegalArgumentException("Value " + text); - } - -@Override -public String toString() { - String options = ""; - for(Rotation ranges : ranges){ - options+= ranges.name; - } - - return "Permissible options [" + options + "] "; - } -} diff --git a/src/main/java/com/pi4j/examples/utils/commandhandler/ParameterSpecificationSetDegree.java b/src/main/java/com/pi4j/examples/utils/commandhandler/ParameterSpecificationSetDegree.java deleted file mode 100644 index f826c4a..0000000 --- a/src/main/java/com/pi4j/examples/utils/commandhandler/ParameterSpecificationSetDegree.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * /* - * * - * - */ - -package com.pi4j.examples.utils.commandhandler; - -public class ParameterSpecificationSetDegree extends ParameterSpecification { - @Override - Double process(String value) { - return 0.0; - } -} diff --git a/src/main/java/com/pi4j/examples/utils/commandhandler/StringParameter.java b/src/main/java/com/pi4j/examples/utils/commandhandler/StringParameter.java new file mode 100644 index 0000000..83b7a35 --- /dev/null +++ b/src/main/java/com/pi4j/examples/utils/commandhandler/StringParameter.java @@ -0,0 +1,37 @@ +/* + * /* + * * + * + */ + +package com.pi4j.examples.utils.commandhandler; + +import java.util.Arrays; + +public class StringParameter extends ParameterSpecification { + + String[] allowedValues = {"s", "m", "f"}; + + /** If empty, we accept any string */ + public StringParameter(String... allowedValues) { + this.allowedValues = allowedValues; + } + + @Override + String process(String value) { + if (Arrays.asList(allowedValues).contains(value)) { + return value; + } else { + throw new IllegalArgumentException("Value " + value); + } + } + + @Override + public String toString() { + String options = ""; + for(String allowedValues : allowedValues){ + options+= allowedValues; + } + return "Permissible options [" + options + "] "; + } +} \ No newline at end of file From a38738aa25c930f82c7d93bf8e7ea047272fa998 Mon Sep 17 00:00:00 2001 From: Tom Aarts Date: Mon, 26 Oct 2026 13:15:31 -0500 Subject: [PATCH 6/8] readme examples unit test updates capture working code before next changes update for provider change in core. Updates trying parameterizedAction updates to Fs90r to use new command structure. At present there are 3 places marked by TODO. They are questions --- src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java index b104911..509d8a0 100644 --- a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java +++ b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java @@ -68,7 +68,7 @@ static void main(String[] args) throws Exception { commandHandler.configuration( "c", "Set the PWM channel number", - new IntegerParameter(0, 127), + new IntegerParameter(1, 4), PWM_CHANNEL); @@ -76,11 +76,12 @@ static void main(String[] args) throws Exception { // after instantiation used on the command line (low value). commandHandler.parameterizedAction("low", "Minimal pulse width", new DoubleParameter(500.0, 1500.0), (device, param) -> { - device.setPwCwMin(param); + device.setPwMin(param); }); + commandHandler.parameterizedAction("high", "Maximum pulse width", new DoubleParameter(1500.0, 2500.0), (device, param) -> { - device.setPwCcwMax(param); + device.setPwMax(param); }); commandHandler.parameterizedAction("cw", "clockwise rotation percentage", new DoubleParameter(0.0, 100.0), (device, param) -> { From eb587e41a8affbaf9a90233cb701a0801b621dfd Mon Sep 17 00:00:00 2001 From: Tom Aarts Date: Mon, 26 Oct 2026 13:15:31 -0500 Subject: [PATCH 7/8] complete percent testing and documentation readme examples unit test updates capture working code before next changes update for provider change in core. Updates trying parameterizedAction updates to Fs90r to use new command structure. At present there are 3 places marked by TODO. They are questions --- .../java/com/pi4j/devices/fs90r/Fs90rApp.java | 27 ++-- .../java/com/pi4j/devices/fs90r/README.md | 123 ++++++++---------- 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java index 509d8a0..6706875 100644 --- a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java +++ b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java @@ -10,7 +10,10 @@ import com.pi4j.boardinfo.util.PwmChipUtil; import com.pi4j.context.Context; import com.pi4j.drivers.motor.fs90r.Fs90rDriver; -import com.pi4j.examples.utils.commandhandler.*; +import com.pi4j.examples.utils.commandhandler.DeviceCommandHandler; +import com.pi4j.examples.utils.commandhandler.DoubleParameter; +import com.pi4j.examples.utils.commandhandler.IntegerParameter; +import com.pi4j.examples.utils.commandhandler.StringParameter; import com.pi4j.io.pwm.Pwm; import com.pi4j.io.pwm.PwmType; import com.pi4j.util.Console; @@ -63,7 +66,6 @@ static void main(String[] args) throws Exception { .chip(PwmChipUtil.getPWMChip()) .frequency(Fs90rDriver.PWM_FREQUENCY)))); - // -cw -ccw -degree mutually exclusive commandHandler.configuration( "c", @@ -71,7 +73,6 @@ static void main(String[] args) throws Exception { new IntegerParameter(1, 4), PWM_CHANNEL); - // Following qctions can be used as arguments when first invoking this program (-low value) , or // after instantiation used on the command line (low value). @@ -84,19 +85,28 @@ static void main(String[] args) throws Exception { device.setPwMax(param); }); - commandHandler.parameterizedAction("cw", "clockwise rotation percentage", new DoubleParameter(0.0, 100.0), (device, param) -> { - device.setServoRotationCwByPercent(param); + commandHandler.parameterizedAction("percent", "set rotation by percentage of max", new DoubleParameter(0.0, 100.0), (device, param) -> { + device.setServoRotationByPercent(param); }); - commandHandler.parameterizedAction("ccw", "counter clockwise rotation percentage", new DoubleParameter(0.0, 100.0), (device, param) -> { - device.setServoRotationCCwByPercent(param); + commandHandler.parameterizedAction("direction", "set rotation direction", new StringParameter("cw", "ccw"), (device, param) -> { + if (param.equals("cw")) { + device.setRotationDirection(Fs90rDriver.ServoDirection.CW); + } else { + device.setRotationDirection(Fs90rDriver.ServoDirection.CCW); + } }); + + /* Setting rotation direction by degree assumes the user understands the spec + * as it does NOT test the servo being stopped nor that the degree range + * coincides with the present direction of rotation. + */ commandHandler.parameterizedAction("degree", "rotation degree", new DoubleParameter(0.0, 180.0), (device, param) -> { device.setServoRotationByDegree(param); }); - commandHandler.parameterizedAction("", "-cw -ccw -degree mutually exclusive", new StringParameter("",""), (device, param) -> { + commandHandler.parameterizedAction("", "-cw -ccw -degree mutually exclusive", new StringParameter("", ""), (device, param) -> { }); commandHandler.process(args); @@ -106,7 +116,6 @@ static void main(String[] args) throws Exception { } - } diff --git a/src/main/java/com/pi4j/devices/fs90r/README.md b/src/main/java/com/pi4j/devices/fs90r/README.md index c0444b5..3afcfc0 100644 --- a/src/main/java/com/pi4j/devices/fs90r/README.md +++ b/src/main/java/com/pi4j/devices/fs90r/README.md @@ -1,97 +1,88 @@ - - -##Device application to operate a Fs90r stepping servo. This servo can rotate 360 degree continuously. +##Device application to operate a Fs90r stepping servo. This servo can rotate 360 degree continuously. The PWM signal sent to the servo device set the direction and RPM of rotation. +Driver for a Fs90r servo motor. +The Fs90r defines a specific PWM interface and exactly how the PWN signal +controls the servo +https://www.pololu.com/product/2820 - Driver for a Fs90r servo motor. - The Fs90r defines a specific PWM interface and exactly how the PWN signal - controls the servo - - https://www.pololu.com/product/2820 - +These devices do not have a customary DataSheet. Most servo devices provide limited specifications +for required pulse width, they just say 1 - 2 millisecond. - These devices do not have a customary DataSheet. Most servo devices provide limited specifications - for required pulse width, they just say 1 - 2 millisecond. +The FS90 R 360 defines a specific PWM interface and exactly how the PWN signal +controls the servo. There are many different manufacturers of the FS90 servo. +The pulse width required for setting the servo at 0 degrees MAX Clockwise (CW) or 180 degrees +MAX CounterClockWise (CCW) varies by manufacturer (Note 1). This implementation use SE determination. +The driver by default uses the pulse width timing as (low)1000 - (high)2000 microseconds. The user of +this example application can change these values - The FS90 R 360 defines a specific PWM interface and exactly how the PWN signal - controls the servo. There are many different manufacturers of the FS90 servo. - The pulse width required for setting the servo at 0 degrees MAX Clockwise (CW) or 180 degrees - MAX CounterClockWise (CCW) varies by manufacturer (Note 1). This implementation use SE determination. - The driver by default uses the pulse width timing as (low)1000 - (high)2000 microseconds. The user of - this example application can change these values - - If the servo does not rotate to the expected RPM,Example to rotate faster CW reduce the -low - argument, to rotate CCW faster increase the -high argument. The low high commands change should be balanced - or 90 degree will not properly align. Meaning if you reduce the -low by 200, you should increase the -high by 200, - or visa-versa. +If the servo does not rotate to the expected RPM,Example to rotate faster CW reduce the -low +argument, to rotate CCW faster increase the -high argument. The low high commands change should be balanced +or 90 degree will not properly align. Meaning if you reduce the low by 200, you should increase the high by 200, +or visa-versa. Note 1 :Direction of rotation, the definition of CW and CCW has two distinct versions. These define your perspective of observation. -- Shaft End (SE / Drive End): The end where the motor shaft and load (like a fan blade or pulley) attach. Industry convention usually assumes you are looking straight at the shaft end. -- Lead End (LE / Bell End / Opposite Drive End - ODE): The back side of the motor where the electrical wires or leads exit. - - https://www.pololu.com/product/2820 - +- Shaft End (SE / Drive End): The end where the motor shaft and load (like a fan blade or pulley) attach. Industry + convention usually assumes you are looking straight at the shaft end. +- Lead End (LE / Bell End / Opposite Drive End - ODE): The back side of the motor where the electrical wires or leads + exit. -Fs90r Pi -Grey/Brown Ground -Red 5V -Yellow GPIO18 config.sys contains dtoverlay=pwm-2chan - +https://www.pololu.com/product/2820 +Fs90r Pi +Grey/Brown Ground +Red 5V +Yellow GPIO18 config.sys contains dtoverlay=pwm-2chan 1. ./mvnw clean package 2. cd target/distribution -3. ./runFs90r.sh args - - -c channel (default 2) set the channel, depending on config.txt 1 2 3 4 - - Program will contunue to run, the following commands are possible - - - +3. ./runFs90r.sh args +-c channel (default 2) set the channel, depending on config.txt 1 2 3 4 +- Program will contunue to run, the following commands are possible -cw percent clockwise rotation at this percentage of maximum -ccw percent counterclockwise rotation at this percentage of maximum -degree double degree to set the servo -low double pulse width for 0 degree microseconds -high double pulse width for 180 degree microseconds -x quit servo will stop, program exist -h help Print commands and their range of input values +Commands -./runFs90r.sh - application running, awaiting command input +direction cw/ccw set servo direction of rotation +percent double Set to this percentage of max rotation +degree double degree to set the servo +low double pulse width for 0 degree microseconds +high double pulse width for 180 degree microseconds +x quit servo will stop, program exist +h help Print commands and their range of input values -./run*Fs90r.sh -c 1 PWM device will use channel 1 +./runFs90r.sh - application running, awaiting command input -./runFs90r.sh -c 1 - PWM device will use channel 1, application running, awaiting command input +./run*Fs90r.sh -c 1 PWM device will use channel 1 +./runFs90r.sh -c 1 - PWM device will use channel 1, application running, awaiting command input -Commands +Command direction validates the servo is stopped before permitting changing direction -degree 180 servo will be updated to this degree value effecting direction and rotation speed -cw 50 servo will rotate clockwise at 50% rotation speed -ccw 75 servo will rotate counterclockwise at 75% rotation speed -low 550 0 degree pulse width 550 ms -high 2450 180 degree pulse width 2450 ms -x servo stops, program exist +Command degree +Setting rotation by degree assumes the user understands the spec +and does NOT test the servo being stopped nor that the degree range +coincides with the present direction of rotation. My Fs90r appears faster rotation wih these values for the low and high limmits low 550 high 2450 Follow start app -1. set low and high pulse widths -2. clockwise 100% -3. clockwise 40% -4. exit - -./runFs90r.sh - - low 550 high 2450 - cw 100 - cw 40 - x + +./runFs90r.sh - Start app in mode to accept commands +low 550 Provided best performance in my test setup +high 2450 Provided best performance in my test setup +direction cw clockwise +percent 75 75% cw rotation speed +direction ccw exception as servo is rotating cw +percent 0 stop rotation +direction ccw counterclockwise +percent 50 50% ccw rotation speed +degree 145 automatic change ccw speed of rotation based on degree +x exit From e493ecc4ea5637e1f5ecade1c896e30c2b1dd179 Mon Sep 17 00:00:00 2001 From: Tom Aarts Date: Mon, 26 Oct 2026 13:15:31 -0500 Subject: [PATCH 8/8] complete percent testing and documentation readme examples unit test updates capture working code before next changes update for provider change in core. Updates trying parameterizedAction updates to Fs90r to use new command structure. At present there are 3 places marked by TODO. They are questions # Conflicts: # src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java # src/main/java/com/pi4j/devices/fs90r/README.md --- .../java/com/pi4j/devices/fs90r/Fs90rApp.java | 37 ++--- .../java/com/pi4j/devices/fs90r/README.md | 126 +++++++++--------- src/main/java/com/pi4j/devices/sg90/README.md | 110 +++++++++------ 3 files changed, 143 insertions(+), 130 deletions(-) diff --git a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java index 6706875..a2e9e35 100644 --- a/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java +++ b/src/main/java/com/pi4j/devices/fs90r/Fs90rApp.java @@ -24,20 +24,24 @@ * The Fs90R defines a specific PWM interface and exactly how the PWN signal * controls the servo *

- * https://www.pololu.com/product/2820 + * Servo details *

* See the README.md file for example usage and explanation. *

* FS90R servo motor control. The driver will use the PWM device created by - * this app. It is assumed the device is a HardWare PWM. Hardware PWM creates + * this app. It is assumed the device is a HardWare PWM. Hardware PWM supports * a more consistent PWM signal. + * The user controls the direction of rotation via setDirection(), where cw denotes clockwise and + * ccw counterclockwise. The direction must be set prior to use of setSpeed(). + * SetSpeed() is a percentage of the maximum RPM. + * + * */ public class Fs90rApp { private static final int SERVO_NUMBER = 1; private static final int PWM_CHANNEL = 2; private static Console console; private static final Delay delay = new Delay(); - private static java.util.Scanner scanner; public Fs90rApp() { super(); @@ -66,47 +70,34 @@ static void main(String[] args) throws Exception { .chip(PwmChipUtil.getPWMChip()) .frequency(Fs90rDriver.PWM_FREQUENCY)))); - // -cw -ccw -degree mutually exclusive commandHandler.configuration( "c", "Set the PWM channel number", new IntegerParameter(1, 4), PWM_CHANNEL); - // Following qctions can be used as arguments when first invoking this program (-low value) , or - // after instantiation used on the command line (low value). + // Following actions can be used as command arguments after instantiation of this program via './runSg90.sh - '. commandHandler.parameterizedAction("low", "Minimal pulse width", new DoubleParameter(500.0, 1500.0), (device, param) -> { - device.setPwMin(param); + device.setPulseWidthMin(param); }); commandHandler.parameterizedAction("high", "Maximum pulse width", new DoubleParameter(1500.0, 2500.0), (device, param) -> { - device.setPwMax(param); + device.setPulseWidthMax(param); }); - commandHandler.parameterizedAction("percent", "set rotation by percentage of max", new DoubleParameter(0.0, 100.0), (device, param) -> { - device.setServoRotationByPercent(param); + commandHandler.parameterizedAction("percent", "set rotation by percentage of max possible", new DoubleParameter(0.0, 100.0), (device, param) -> { + device.setSpeed(param); }); commandHandler.parameterizedAction("direction", "set rotation direction", new StringParameter("cw", "ccw"), (device, param) -> { if (param.equals("cw")) { - device.setRotationDirection(Fs90rDriver.ServoDirection.CW); + device.setDirection(Fs90rDriver.ServoDirection.CLOCKWISE); } else { - device.setRotationDirection(Fs90rDriver.ServoDirection.CCW); + device.setDirection(Fs90rDriver.ServoDirection.COUNTERCLOCKWISE); } - }); - - - /* Setting rotation direction by degree assumes the user understands the spec - * as it does NOT test the servo being stopped nor that the degree range - * coincides with the present direction of rotation. - */ - commandHandler.parameterizedAction("degree", "rotation degree", new DoubleParameter(0.0, 180.0), (device, param) -> { - device.setServoRotationByDegree(param); - }); - commandHandler.parameterizedAction("", "-cw -ccw -degree mutually exclusive", new StringParameter("", ""), (device, param) -> { }); commandHandler.process(args); diff --git a/src/main/java/com/pi4j/devices/fs90r/README.md b/src/main/java/com/pi4j/devices/fs90r/README.md index 3afcfc0..80b3ab8 100644 --- a/src/main/java/com/pi4j/devices/fs90r/README.md +++ b/src/main/java/com/pi4j/devices/fs90r/README.md @@ -1,88 +1,86 @@ -##Device application to operate a Fs90r stepping servo. This servo can rotate 360 degree continuously. -The PWM signal sent to the servo device set the direction and RPM of rotation. +##Device application to operate a Fs90r servo -Driver for a Fs90r servo motor. -The Fs90r defines a specific PWM interface and exactly how the PWN signal -controls the servo +This servo can rotate 360 degree continuously. The PWM signals +pulse width being sent to the servo device determines the direction and RPM of rotation. https://www.pololu.com/product/2820 -These devices do not have a customary DataSheet. Most servo devices provide limited specifications -for required pulse width, they just say 1 - 2 millisecond. +These devices do not have a customary DataSheet. Most servo devices provide limited specifications for required pulse widths, +they just say 1 - 2 millisecond. -The FS90 R 360 defines a specific PWM interface and exactly how the PWN signal -controls the servo. There are many different manufacturers of the FS90 servo. -The pulse width required for setting the servo at 0 degrees MAX Clockwise (CW) or 180 degrees -MAX CounterClockWise (CCW) varies by manufacturer (Note 1). This implementation use SE determination. -The driver by default uses the pulse width timing as (low)1000 - (high)2000 microseconds. The user of -this example application can change these values +The FS90 R 360 defines a specific PWM interface and exactly how the PWN signal controls the servo. There are many +different manufacturers of the FS90 servo. The pulse width required for setting the servo at MAX Clockwise (CW) +or MAX CounterClockWise (CCW) varies by manufacturer This implementation use SE determination for the +direction of rotation (Note1). -If the servo does not rotate to the expected RPM,Example to rotate faster CW reduce the -low -argument, to rotate CCW faster increase the -high argument. The low high commands change should be balanced -or 90 degree will not properly align. Meaning if you reduce the low by 200, you should increase the high by 200, -or visa-versa. +The driver by default uses the pulse width timing as (low)1000 - (high)2000 microseconds. The user of this example +application can change these values. If the servo does not rotate to the expected RPM, to rotate faster clockwise +reduce the low argument, to rotate CCW faster increase the high argument. The low high commands change should be balanced +or else when the servo is stopped will not be correct. Meaning if you reduce the low by 200, you should increase +the high by 200, or visa-versa. -Note 1 :Direction of rotation, the definition of CW and CCW has two distinct versions. These define your -perspective of observation. - -- Shaft End (SE / Drive End): The end where the motor shaft and load (like a fan blade or pulley) attach. Industry - convention usually assumes you are looking straight at the shaft end. -- Lead End (LE / Bell End / Opposite Drive End - ODE): The back side of the motor where the electrical wires or leads - exit. +Note 1 :Direction of rotation, the definition of clockwise and counterclockwise have two distinct versions. These define +your perspective of observation. +1. Shaft End (SE / Drive End): The end where the motor shaft and load (like a fan blade or pulley) attach. Industry +convention usually assumes you are looking straight at the shaft end. +2. Lead End (LE / Bell End / Opposite Drive End - ODE): The back side of the motor where the electrical wires or leads exit. https://www.pololu.com/product/2820 -Fs90r Pi -Grey/Brown Ground -Red 5V -Yellow GPIO18 config.sys contains dtoverlay=pwm-2chan +Typical wiring when config.sys contains dtoverlay=pwm-2chan +FS90R connections to a Raspberry Pi + +| FS90_R | Raspberry Pi | +|------------|--------------| +| Grey/Brown | Ground | +| Red | 5V | +| Yellow | GPIO18 PWM | + -1. ./mvnw clean package -2. cd target/distribution -3. ./runFs90r.sh args --c channel (default 2) set the channel, depending on config.txt 1 2 3 4 +Building the Example application +./mvnw clean package +cd target/distribution +./runFs90r.sh args +-c channel (application default is 2) set the channel, depending on config.txt 1 2 3 4 -- Program will contunue to run, the following commands are possible +If **-** is included when starting this program, it will continue to run and the following commands are possible + +| Command | options | Note | +|------------|--------------------|--------------------------------------| +| direction | cw/ccw | set servo direction of rotation | +| percent | double 0 ... 100 | set RPM | +| low | double 500 ...1499 | pulse width for max clockwise | +| high | double 1501..2500 | pulse width for max counterclockwise | +| x | | servo will stop, program exist | +| h | | print help | -Commands -direction cw/ccw set servo direction of rotation -percent double Set to this percentage of max rotation -degree double degree to set the servo -low double pulse width for 0 degree microseconds -high double pulse width for 180 degree microseconds -x quit servo will stop, program exist -h help Print commands and their range of input values -./runFs90r.sh - application running, awaiting command input -./run*Fs90r.sh -c 1 PWM device will use channel 1 -./runFs90r.sh -c 1 - PWM device will use channel 1, application running, awaiting command input +./runFs90r.sh - application running, awaiting command input -Command direction validates the servo is stopped before permitting changing direction +./run*Fs90r.sh -c 1 PWM device will use channel 1 -Command degree -Setting rotation by degree assumes the user understands the spec -and does NOT test the servo being stopped nor that the degree range -coincides with the present direction of rotation. +./runFs90r.sh -c 1 - PWM device will use channel 1, application running, awaiting command input -My Fs90r appears faster rotation wih these values for the low and high limmits -low 550 high 2450 +Command examples -Follow -start app +My Fs90r appears faster rotation wih these values for the low and high values low 550 high 2450 -./runFs90r.sh - Start app in mode to accept commands -low 550 Provided best performance in my test setup -high 2450 Provided best performance in my test setup -direction cw clockwise -percent 75 75% cw rotation speed -direction ccw exception as servo is rotating cw -percent 0 stop rotation -direction ccw counterclockwise -percent 50 50% ccw rotation speed -degree 145 automatic change ccw speed of rotation based on degree -x exit +**./runFs90r.sh -** Start app in mode to accept commands + + +| command | Note | +|----------------|---------------------------------------------------------------| +| low 550 | Provided best performance in my test setup | +| high 2450 | Provided best performance in my test setup | +| direction cw | clockwise | +| percent 75 | 75% clockwise rotation speed | +| direction ccw | exception as servo is currently rotating clockwise | +| percent 0 | stop rotation | +| direction ccw | change to counterclockwise permitted as servo is not rotating | +| percent 50 | 50% counterclockwise rotation speed | +| x | exit | diff --git a/src/main/java/com/pi4j/devices/sg90/README.md b/src/main/java/com/pi4j/devices/sg90/README.md index 21b2208..52671b7 100644 --- a/src/main/java/com/pi4j/devices/sg90/README.md +++ b/src/main/java/com/pi4j/devices/sg90/README.md @@ -1,60 +1,84 @@ -# SG90 servo motor +##Device application to operate a Fs90r servo. This servo can rotate 360 degree continuously. The PWM signals +pulse width being sent to the servo device determines the direction and RPM of rotation. -https://www.scribd.com/document/420327552/Servo -https://www.friendlywire.com/projects/ne555-servo-safe/SG90-datasheet.pdf +https://www.pololu.com/product/2820 -These devices do not have a customary DataSheet. Most servo devices provide limited specifications -for required pulse width, they just say 1 - 2 millisecond. +These devices do not have a customary DataSheet. Most servo devices provide limited specifications for required pulse widths, +they just say 1 - 2 millisecond. -The SG90 defines a specific PWM interface and exactly how the PWN signal -controls the servo. There are many different manufacturers of the SG90 servo. -The pulse width required for setting the servo at 0 degrees or 180 degrees varies by -manufacturer. The driver by default uses the pulse width timing as -(low)1000 - (high)2000 microseconds. The user of this example application can change these defaults when first -invoking the program. +The FS90 R 360 defines a specific PWM interface and exactly how the PWN signal controls the servo. There are many +different manufacturers of the FS90 servo. The pulse width required for setting the servo at MAX Clockwise (CW) +or MAX CounterClockWise (CCW) varies by manufacturer This implementation use SE determination for the +direction of rotation (Note1). -If the servo does not rotate to the desired position, Example: to rotate closer to the 0 degree -point reduce the -low argument, to rotate closer to the 180 degree point increase the --high argument. The -low -high change should be balanced or 90 degree will not properly align. -Meaning if you reduce the -low by 200, you should increase the -high by 200, or visa-versa. +The driver by default uses the pulse width timing as (low)1000 - (high)2000 microseconds. The user of this example +application can change these values. If the servo does not rotate to the expected RPM, to rotate faster clockwise +reduce the low argument, to rotate CCW faster increase the high argument. The low high commands change should be balanced +or else when the servo is stopped will not be correct. Meaning if you reduce the low by 200, you should increase +the high by 200, or visa-versa. +Note 1 :Direction of rotation, the definition of clockwise and counterclockwise have two distinct versions. These define +your perspective of observation. +1. Shaft End (SE / Drive End): The end where the motor shaft and load (like a fan blade or pulley) attach. Industry +convention usually assumes you are looking straight at the shaft end. +2. Lead End (LE / Bell End / Opposite Drive End - ODE): The back side of the motor where the electrical wires or leads exit. +https://www.pololu.com/product/2820 - Connections between the SG90 servo and the Raspberry Pi - SG90 Pi -Grey/Brown Ground -Red 5V -Yellow GPIO18 config.sys contains dtoverlay=pwm-2chan +Typical wiring when config.sys contains dtoverlay=pwm-2chan +FS90R connections to a Raspberry Pi +| FS90_R | Raspberry Pi | +|------------|--------------| +| Grey/Brown | Ground | +| Red | 5V | +| Yellow | GPIO18 PWM | -1. ./mvnw clean package -2. cd target/distribution -3. ./runSg90.sh args --c channel (default 2) set the channel, depending on config.txt 1 2 3 4 --low double pulse width for 0 degree microseconds --high double pulse width for 180 degree microseconds --q quit --h help +Building the Example application +./mvnw clean package +cd target/distribution +./runFs90r.sh args +-c channel (application default is 2) set the channel, depending on config.txt 1 2 3 4 -./runSg90.sh begins execution of the application, you then enter the desired servo degree of rotation. -Then continue entering the requested degree value, or any key will exist the program. +If **-** is included when starting this program, it will continue to run and the following commands are possible + +| Command | options | Note | +|------------|--------------------|--------------------------------------| +| direction | cw/ccw | set servo direction of rotation | +| percent | double 0 ... 100 | set RPM | +| low | double 500 ...1499 | pulse width for max clockwise | +| high | double 1501..2500 | pulse width for max counterclockwise | +| x | | servo will stop, program exist | +| h | | print help | -Set ouput shaft at 120 degree -./runSg90.sh - 120 -Driver defaults to 0 degree requires a 1000 micro second pulse, 180 degree requires a 2000 microsecond pulse -If your servo requires different pulse widths -Set low high pulse widths, then set output shaft at 120 degree -./runSg90.sh -low 600 -high 2400 - 120 -My Sg90 aligns correctly with these values -./runSg90.sh -low 550 -high 2450 -If your configuration uses a channel other than 2 -./runSg90.sh -c 1 - 120 +./runFs90r.sh - application running, awaiting command input + +./run*Fs90r.sh -c 1 PWM device will use channel 1 + +./runFs90r.sh -c 1 - PWM device will use channel 1, application running, awaiting command input + +Command examples + +My Fs90r appears faster rotation wih these values for the low and high values low 550 high 2450 + +**./runFs90r.sh -** Start app in mode to accept commands + + +| command | Note | +|----------------|---------------------------------------------------------------| +| low 550 | Provided best performance in my test setup | +| high 2450 | Provided best performance in my test setup | +| direction cw | clockwise | +| percent 75 | 75% clockwise rotation speed | +| direction ccw | exception as servo is currently rotating clockwise | +| percent 0 | stop rotation | +| direction ccw | change to counterclockwise permitted as servo is not rotating | +| percent 50 | 50% counterclockwise rotation speed | +| x | exit | +