mirror of
https://github.com/processing/processing4.git
synced 2026-04-23 20:54:24 +02:00
I/O: Rename LED.setBrightness() to LED.brightness()
Suggested by Ben. Note: still needs to be updated in processing-docs.
This commit is contained in:
@@ -95,6 +95,23 @@ public class LED {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the brightness
|
||||
* @param bright 0.0 (off) to 1.0 (maximum)
|
||||
*/
|
||||
public void brightness(float bright) {
|
||||
String fn = "/sys/class/leds/" + dev + "/brightness";
|
||||
if (bright < 0.0 || 1.0 < bright) {
|
||||
System.err.println("Brightness must be between 0.0 and 1.0.");
|
||||
throw new IllegalArgumentException("Illegal argument");
|
||||
}
|
||||
int ret = NativeInterface.writeFile(fn, Integer.toString((int)(bright * maxBrightness)));
|
||||
if (ret < 0) {
|
||||
throw new RuntimeException(fn + ": " + NativeInterface.getError(ret));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restores the previous state
|
||||
*
|
||||
@@ -135,21 +152,4 @@ public class LED {
|
||||
Arrays.sort(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the brightness
|
||||
* @param bright 0.0 (off) to 1.0 (maximum)
|
||||
*/
|
||||
public void setBrightness(float bright) {
|
||||
String fn = "/sys/class/leds/" + dev + "/brightness";
|
||||
if (bright < 0.0 || 1.0 < bright) {
|
||||
System.err.println("Brightness must be between 0.0 and 1.0.");
|
||||
throw new IllegalArgumentException("Illegal argument");
|
||||
}
|
||||
int ret = NativeInterface.writeFile(fn, Integer.toString((int)(bright * maxBrightness)));
|
||||
if (ret < 0) {
|
||||
throw new RuntimeException(fn + ": " + NativeInterface.getError(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user