Skip to content

Commit

Permalink
encoders: add the option to configure 2nd midi id
Browse files Browse the repository at this point in the history
  • Loading branch information
paradajz committed Apr 16, 2024
1 parent 518df7e commit 5d15819
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 20 deletions.
57 changes: 37 additions & 20 deletions src/definitions/block/encoder/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ShowEncoderRemoteSyncOnTypes,
ShowEncoderLimitsOnTypes,
ShowEncoderRepeatedValueOnTypes,
ShowEncoder2ndIdOnTypes,
HideEncoderMidiIdOnTypes,
HideEncoderMidiChannelOnTypes,
} from "../../interface";
Expand Down Expand Up @@ -55,16 +56,19 @@ const sections: Dictionary<ISectionDefinition> = {
{ value: EncodingMode.Controlchange41, text: "Control change - 41h01h" },
{
value: EncodingMode.SingleNoteWithVariableValue,
text: "Single note with variable value",
text: "Single note / variable value",
},
{
value: EncodingMode.SingleNoteWithFixedValueBothDirections,
text: "Single note with fixed value in both directions",
text: "Single note / fixed value both directions",
},
{
value: EncodingMode.SingleNoteWithFixedValueOneDirection0OtherDirection,
text:
"Single note with fixed value in one direction and 0 value in other",
text: "Single note / fixed value one direction, 0 value other",
},
{
value: EncodingMode.TwoNoteWithFixedValueBothDirections,
text: "Two note / fixed value both directions",
},
{
value: EncodingMode.CC7bit,
Expand Down Expand Up @@ -118,6 +122,20 @@ const sections: Dictionary<ISectionDefinition> = {
label: "MIDI ID (LSB)",
helpText: "",
},
MidiId2: {
showIf: (formState: FormState): boolean =>
ShowEncoder2ndIdOnTypes.includes(formState.encodingMode) &&
!!formState.enabled,
block: Block.Encoder,
key: "midiId2",
type: SectionType.Value,
section: 12,
component: FormInputComponent.Input,
min: 0,
max: 16383,
label: "2nd MIDI ID",
helpText: "",
},
MidiIdMSB: {
showIf: (formState: FormState): boolean =>
!HideEncoderMidiIdOnTypes.includes(formState.encodingMode) &&
Expand All @@ -133,22 +151,6 @@ const sections: Dictionary<ISectionDefinition> = {
label: "MIDI ID (MSB)",
helpText: "",
},
PulsesPerStep: {
showIf: (formState: FormState): boolean => formState.enabled,
block: Block.Encoder,
key: "pulsesPerStep",
type: SectionType.Value,
section: 5,
colspan: 2,
component: FormInputComponent.Select,
options: [
{ value: 2, text: "2" },
{ value: 3, text: "3" },
{ value: 4, text: "4" },
],
label: "Pulses per step",
helpText: `Amount of pulses encoder must generate in order for firmware to register it as single step. Usually 4.`,
},
Acceleration: {
showIf: (formState: FormState): boolean =>
ShowEncoderAccelerationOnTypes.includes(formState.encodingMode) &&
Expand Down Expand Up @@ -196,6 +198,21 @@ const sections: Dictionary<ISectionDefinition> = {
label: "Repeated value",
helpText: `Specifies the constant note value to be sent when encoder is moved.`,
},
PulsesPerStep: {
showIf: (formState: FormState): boolean => formState.enabled,
block: Block.Encoder,
key: "pulsesPerStep",
type: SectionType.Value,
section: 5,
component: FormInputComponent.Select,
options: [
{ value: 2, text: "2" },
{ value: 3, text: "3" },
{ value: 4, text: "4" },
],
label: "Pulses per step",
helpText: `Amount of pulses encoder must generate in order for firmware to register it as single step. Usually 4.`,
},
LowerLimit: {
showIf: (formState: FormState): boolean =>
ShowEncoderLimitsOnTypes.includes(formState.encodingMode) &&
Expand Down
6 changes: 6 additions & 0 deletions src/definitions/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export enum EncodingMode {
SingleNoteWithVariableValue = 11,
SingleNoteWithFixedValueBothDirections = 12,
SingleNoteWithFixedValueOneDirection0OtherDirection = 13,
TwoNoteWithFixedValueBothDirections = 14,
}

export enum LedControlMode {
Expand Down Expand Up @@ -215,6 +216,11 @@ export const ShowEncoderLimitsOnTypes = [
export const ShowEncoderRepeatedValueOnTypes = [
EncodingMode.SingleNoteWithFixedValueBothDirections,
EncodingMode.SingleNoteWithFixedValueOneDirection0OtherDirection,
EncodingMode.TwoNoteWithFixedValueBothDirections,
];

export const ShowEncoder2ndIdOnTypes = [
EncodingMode.TwoNoteWithFixedValueBothDirections,
];

export const HideLedActivationValueOnControlTypes = [
Expand Down

0 comments on commit 5d15819

Please sign in to comment.