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

48 lines
1.1 KiB
Java

package de.ctdo.bunti.dmx;
public final class DMX {
public static final int DMX_CHANNELS_MAX = 511;
public static final int DMX_CHANNELS_MIN = 0;
public static final int DMX_CHANNEL_VALUE_MAX = 255;
public static final int DMX_CHANNEL_VALUE_MIN = 0;
/**
* Offset by which startaddress differs from DMX512 Data Array location
*/
public static final int DMX_STARTADDRESS_OFFSET = -1;
private DMX() {
}
/**
* Checks the DMX Value boundaries
*
* @param value
* @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_CHANNELS_MIN && channel <= DMX_CHANNELS_MAX);
}
}