Skip to content

Commit 8b8f6b8

Browse files
committed
I/O: Rename LED.setBrightness() to LED.brightness()
Suggested by Ben. Note: still needs to be updated in processing-docs.
1 parent a749f7c commit 8b8f6b8

File tree

1 file changed

+17
-17
lines changed
  • java/libraries/io/src/processing/io

1 file changed

+17
-17
lines changed

java/libraries/io/src/processing/io/LED.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)