File tree Expand file tree Collapse file tree 1 file changed +17
-17
lines changed
java/libraries/io/src/processing/io Expand file tree Collapse file tree 1 file changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,23 @@ public LED(String dev) {
9595 }
9696
9797
98+ /**
99+ * Sets the brightness
100+ * @param bright 0.0 (off) to 1.0 (maximum)
101+ */
102+ public void brightness (float bright ) {
103+ String fn = "/sys/class/leds/" + dev + "/brightness" ;
104+ if (bright < 0.0 || 1.0 < bright ) {
105+ System .err .println ("Brightness must be between 0.0 and 1.0." );
106+ throw new IllegalArgumentException ("Illegal argument" );
107+ }
108+ int ret = NativeInterface .writeFile (fn , Integer .toString ((int )(bright * maxBrightness )));
109+ if (ret < 0 ) {
110+ throw new RuntimeException (fn + ": " + NativeInterface .getError (ret ));
111+ }
112+ }
113+
114+
98115 /**
99116 * Restores the previous state
100117 *
@@ -135,21 +152,4 @@ public static String[] list() {
135152 Arrays .sort (tmp );
136153 return tmp ;
137154 }
138-
139-
140- /**
141- * Sets the brightness
142- * @param bright 0.0 (off) to 1.0 (maximum)
143- */
144- public void setBrightness (float bright ) {
145- String fn = "/sys/class/leds/" + dev + "/brightness" ;
146- if (bright < 0.0 || 1.0 < bright ) {
147- System .err .println ("Brightness must be between 0.0 and 1.0." );
148- throw new IllegalArgumentException ("Illegal argument" );
149- }
150- int ret = NativeInterface .writeFile (fn , Integer .toString ((int )(bright * maxBrightness )));
151- if (ret < 0 ) {
152- throw new RuntimeException (fn + ": " + NativeInterface .getError (ret ));
153- }
154- }
155155}
You can’t perform that action at this time.
0 commit comments