the_ledtester_class
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
the_ledtester_class [2018/08/11 00:27] – frchris | the_ledtester_class [2018/08/11 01:00] – frchris | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | hi | + | < |
- | <file LEDTester.java> | + | /** |
+ | * This class tests LED by flashing some morse code. 2014 verion by | ||
+ | * @author Ian Utting | ||
+ | * @author Fabio Heday | ||
+ | * | ||
+ | * Chris Thiel added the finalize() method to aviod GpioPinExistsException | ||
+ | * @version 10 Aug 18 | ||
+ | */ | ||
public class LEDTester | public class LEDTester | ||
{ | { | ||
- | | + | public LED pin1; |
+ | |||
+ | //unit of time, in milliseconds | ||
+ | private final static int UNIT = 200; | ||
+ | |||
+ | public static void main(String [] args) { | ||
+ | LEDTester lt = new LEDTester(); | ||
+ | |||
+ | String s = "SOS SOS SOS"; | ||
+ | // | ||
+ | if (args.length > 0 && args[0] != null && !args[0].equals("" | ||
+ | s = args[0]; | ||
+ | |||
+ | lt.flashMorse(s); | ||
+ | lt.finalize(); | ||
+ | } | ||
+ | /* | ||
+ | * create a new LED instance | ||
+ | */ | ||
+ | public LEDTester() { | ||
+ | this(new LED()); | ||
+ | } | ||
+ | |||
+ | /* | ||
+ | * Creates a LED instance based on a LED object | ||
+ | */ | ||
+ | public LEDTester(LED p) { | ||
+ | pin1 = p; | ||
+ | } | ||
+ | |||
+ | /* | ||
+ | * Flashes the LED 10 times | ||
+ | */ | ||
+ | public void flash10Times() { | ||
+ | | ||
+ | pin1.flash(200); | ||
+ | try { Thread.sleep200; | ||
+ | } | ||
+ | } | ||
+ | /* | ||
+ | * create a new LED instance | ||
+ | */ | ||
+ | public LEDTester() { | ||
+ | this(new LED()); | ||
+ | } | ||
+ | | ||
pin1.finalize(); | pin1.finalize(); | ||
} | } |
the_ledtester_class.txt · Last modified: 2018/08/11 01:10 by frchris