From 20ed835e20a3e2ab42681a1c5b1a3c037c91fd9d Mon Sep 17 00:00:00 2001 From: paradajz <2544094+paradajz@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:45:04 +0100 Subject: [PATCH] encoders: allow setting lower and upper value range --- src/definitions/block/encoder/encoder.ts | 34 ++++++++++++++++++++++++ src/definitions/interface.ts | 9 +++++++ 2 files changed, 43 insertions(+) diff --git a/src/definitions/block/encoder/encoder.ts b/src/definitions/block/encoder/encoder.ts index 84e0101..225fef1 100644 --- a/src/definitions/block/encoder/encoder.ts +++ b/src/definitions/block/encoder/encoder.ts @@ -7,6 +7,7 @@ import { EncodingMode, ShowEncoderAccelerationOnTypes, ShowEncoderRemoteSyncOnTypes, + ShowEncoderLimitsOnTypes, HideEncoderMidiIdOnTypes, HideEncoderMidiChannelOnTypes, } from "../../interface"; @@ -168,6 +169,39 @@ const sections: Dictionary = { If enabled, CC/pitch bend value received via MIDI IN will be applied internally to the encoder with same MIDI ID and MIDI channel, so that next encoder turn increments or decrements received value instead of the last value it sent.`, }, + LowerLimit: { + showIf: (formState: FormState): boolean => + ShowEncoderLimitsOnTypes.includes(formState.encodingMode) && + formState.enabled, + block: Block.Encoder, + key: "lowerLimit", + type: SectionType.Value, + section: 9, + component: FormInputComponent.Input, + min: 0, + max: 16383, + label: "Lower limit", + helpText: `Specifies the minimum value which is sent by the encoder input. Limit is + type-dependent. For most types, total range is 0-127. For pitch bend, 14-bit NRPN and + 14-bit CC, total range is 0-16383.`, + }, + UpperLimit: { + showIf: (formState: FormState): boolean => + ShowEncoderLimitsOnTypes.includes(formState.encodingMode) && + formState.enabled, + block: Block.Encoder, + key: "upperLimit", + type: SectionType.Value, + section: 10, + component: FormInputComponent.Input, + min: 0, + max: 16383, + label: "Upper limit", + helpText: `Specifies the minimum value which is sent by the analog input. Scaling is used + here, so this value will be sent when the analog input is at its lowest position. Limit is + type-dependent. For most types, total range is 0-127. For pitch bend, 14-bit NRPN and + 14-bit CC, total range is 0-16383.`, + }, }; export const EncoderBlock: IBlockDefinition = { diff --git a/src/definitions/interface.ts b/src/definitions/interface.ts index d7fe712..77b18fc 100644 --- a/src/definitions/interface.ts +++ b/src/definitions/interface.ts @@ -200,6 +200,15 @@ export const ShowEncoderRemoteSyncOnTypes = [ EncodingMode.NRPN14bit, ]; +export const ShowEncoderLimitsOnTypes = [ + EncodingMode.PitchBend, + EncodingMode.CC7bit, + EncodingMode.CC14bit, + EncodingMode.NRPN7bit, + EncodingMode.NRPN14bit, + EncodingMode.Note, +]; + export const HideLedActivationValueOnControlTypes = [ LedControlMode.PresetChange, LedControlMode.ProgramChange,