bunti/src/main/java/de/ctdo/bunti/dmx/DMX.java

42 lines
1.0 KiB
Java

package de.ctdo.bunti.dmx;
public final class DMX {
public static final int DMX_CHANNEL_INDEX_MAX = 512;
public static final int DMX_CHANNEL_INDEX_MIN = 1;
public static final int DMX_CHANNEL_VALUE_MAX = 255;
public static final int DMX_CHANNEL_VALUE_MIN = 0;
private DMX() {
}
/**
* Checks the DMX Value boundaries
*
* @param value the DMX channel value to sanitize
* @return A valid DMX512 channel value
*/
public static int sanitizeDMXValue(int value) {
if (value < DMX_CHANNEL_VALUE_MIN) {
return DMX_CHANNEL_VALUE_MIN;
}
if (value > DMX_CHANNEL_VALUE_MAX) {
return DMX_CHANNEL_VALUE_MAX;
}
return value;
}
/**
* Checks the DMX Channel boundaries
*
* @param channel The channel to check
* @return True if channel is valid. Otherwise false.
*/
public static boolean checkChannelBoundaries(int channel) {
return (channel >= DMX_CHANNEL_INDEX_MIN && channel <= DMX_CHANNEL_INDEX_MAX);
}
}