use of de.mossgrabers.framework.controller.hardware.IHwLight in project DrivenByMoss by git-moss.
the class LaunchkeyMk3ControllerSetup method createViewButton.
private void createViewButton(final ButtonID buttonID, final OutputID outputID, final String label, final Views view, final int viewIndex) {
final LaunchkeyMk3ControlSurface surface = this.getSurface();
final ViewMultiSelectCommand<LaunchkeyMk3ControlSurface, LaunchkeyMk3Configuration> viewSelectCommand = new ViewMultiSelectCommand<>(this.model, surface, true, view);
this.addButton(surface, buttonID, label, (event, velocity) -> {
viewSelectCommand.executeNormal(event);
if (event == ButtonEvent.DOWN)
surface.getPadGrid().setView(view);
}, 15, LaunchkeyMk3ControlSurface.LAUNCHKEY_VIEW_SELECT, viewIndex, false, null);
final IHwLight light = surface.createLight(outputID, () -> surface.getViewManager().isActive(view) ? ColorEx.ORANGE : ColorEx.DARK_ORANGE, color -> {
// Intentionally empty
});
surface.getButton(buttonID).addLight(light);
}
use of de.mossgrabers.framework.controller.hardware.IHwLight in project DrivenByMoss by git-moss.
the class HwSurfaceFactoryImpl method createLight.
/**
* {@inheritDoc}
*/
@Override
public IHwLight createLight(final int surfaceID, final OutputID outputID, final IntSupplier supplier, final IntConsumer sendValueConsumer, final IntFunction<ColorEx> stateToColorFunction, final IHwButton button) {
this.lightCounter++;
final String id = createID(surfaceID, outputID == null ? "LIGHT" + this.lightCounter : outputID.name());
final MultiStateHardwareLight hardwareLight = this.hardwareSurface.createMultiStateHardwareLight(id);
final Supplier<InternalHardwareLightState> valueSupplier = () -> new EncodedColorLightState(supplier.getAsInt(), stateToColorFunction);
final Consumer<InternalHardwareLightState> hardwareUpdater = state -> {
final HardwareLightVisualState visualState = state == null ? null : state.getVisualState();
final int encodedColorState = visualState == null ? 0 : supplier.getAsInt();
sendValueConsumer.accept(encodedColorState);
};
final HwLightImpl lightImpl = new HwLightImpl(this.host, hardwareLight, valueSupplier, hardwareUpdater);
if (button != null)
button.addLight(lightImpl);
return lightImpl;
}
Aggregations