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

43 lines
1.0 KiB
Java
Raw Normal View History

2012-03-02 21:09:43 +00:00
package de.ctdo.bunti.dmx;
public class DMX {
2012-03-04 00:21:00 +00:00
public static final int DMX_CHANNELS_MAX = (byte) 511;
public static final int DMX_CHANNELS_MIN = 0;
public static final int DMX_CHANNEL_VALUE_MAX = (byte) 255;
public static final int DMX_CHANNEL_VALUE_MIN = 0;
2012-03-02 21:09:43 +00:00
/**
* Offset by which startaddress differs from DMX512 Data Array location
*/
2012-03-04 00:21:00 +00:00
public static final int DMX_STARTADDRESS_OFFSET = -1;
private DMX(){
}
/**
* Checks the DMX Value boundaries
* @param value
* @return A valid DMX512 channel value
*/
2012-03-02 21:09:43 +00:00
public static int sanitizeDMXValue(int value) {
if(value < DMX_CHANNEL_VALUE_MIN) value = DMX_CHANNEL_VALUE_MIN;
if(value > DMX_CHANNEL_VALUE_MAX) value = 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.
*/
2012-03-02 21:09:43 +00:00
public static boolean checkChannelBoundaries(int channel) {
return (channel >= DMX_CHANNELS_MIN && channel <= DMX_CHANNELS_MAX);
}
2012-03-02 21:09:43 +00:00
}