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:
gohai
2015-10-14 19:32:02 +02:00
parent 4d583abbb5
commit cd03e69f1a

View File

@@ -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));
}
}
}