Skip to content

Commit

Permalink
encoders: allow setting lower and upper value range
Browse files Browse the repository at this point in the history
  • Loading branch information
paradajz committed Feb 20, 2024
1 parent 277b89b commit 20ed835
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/definitions/block/encoder/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
EncodingMode,
ShowEncoderAccelerationOnTypes,
ShowEncoderRemoteSyncOnTypes,
ShowEncoderLimitsOnTypes,
HideEncoderMidiIdOnTypes,
HideEncoderMidiChannelOnTypes,
} from "../../interface";
Expand Down Expand Up @@ -168,6 +169,39 @@ const sections: Dictionary<ISectionDefinition> = {
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 = {
Expand Down
9 changes: 9 additions & 0 deletions src/definitions/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 20ed835

Please sign in to comment.