Skip to content

Commit

Permalink
encoders: add the option to configure two midi ids
Browse files Browse the repository at this point in the history
  • Loading branch information
paradajz committed Apr 16, 2024
1 parent 9ad2c54 commit 55ab566
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/firmware/application/database/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ namespace database
ENABLE,
INVERT,
MODE,
MIDI_ID,
MIDI_ID_1,
CHANNEL,
PULSES_PER_STEP,
ACCELERATION,
REMOTE_SYNC,
LOWER_LIMIT,
UPPER_LIMIT,
REPEATED_VALUE,
MIDI_ID_2,
AMOUNT
};

Expand Down
11 changes: 10 additions & 1 deletion src/firmware/application/database/Layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace database
0,
},

// midi id section
// midi id 1 section
{
io::Encoders::Collection::SIZE(),
LESSDB::sectionParameterType_t::WORD,
Expand Down Expand Up @@ -215,6 +215,15 @@ namespace database
LESSDB::autoIncrementSetting_t::DISABLE,
127,
},

// midi id 2 section
{
io::Encoders::Collection::SIZE(),
LESSDB::sectionParameterType_t::WORD,
LESSDB::preserveSetting_t::DISABLE,
LESSDB::autoIncrementSetting_t::ENABLE,
0,
},
};

std::vector<LESSDB::Section> _analogSections = {
Expand Down
4 changes: 2 additions & 2 deletions src/firmware/application/io/encoders/Encoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Encoders::Encoders(HWA& hwa,
}
}

if (_database.read(database::Config::Section::encoder_t::MIDI_ID, i) != event.index)
if (_database.read(database::Config::Section::encoder_t::MIDI_ID_1, i) != event.index)
{
continue;
}
Expand Down Expand Up @@ -451,7 +451,7 @@ void Encoders::fillEncoderDescriptor(size_t index, encoderDescriptor_t& descript
descriptor.type = static_cast<type_t>(_database.read(database::Config::Section::encoder_t::MODE, index));
descriptor.event.componentIndex = index;
descriptor.event.channel = _database.read(database::Config::Section::encoder_t::CHANNEL, index);
descriptor.event.index = _database.read(database::Config::Section::encoder_t::MIDI_ID, index);
descriptor.event.index = _database.read(database::Config::Section::encoder_t::MIDI_ID_1, index);
descriptor.event.message = INTERNAL_MSG_TO_MIDI_TYPE[static_cast<uint8_t>(descriptor.type)];
}

Expand Down
3 changes: 2 additions & 1 deletion src/firmware/application/system/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace sys
ENABLE,
INVERT,
MODE,
MIDI_ID,
MIDI_ID_1,
CHANNEL,
PULSES_PER_STEP,
ACCELERATION,
Expand All @@ -85,6 +85,7 @@ namespace sys
LOWER_LIMIT,
UPPER_LIMIT,
REPEATED_VALUE,
MIDI_ID_2,
AMOUNT
};

Expand Down
9 changes: 8 additions & 1 deletion src/firmware/application/system/Layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace sys
static_cast<uint16_t>(io::Encoders::type_t::AMOUNT) - 1,
},

// midi id section
// midi id 1 section
{
io::Encoders::Collection::SIZE(),
0,
Expand Down Expand Up @@ -177,6 +177,13 @@ namespace sys
0,
16383,
},

// midi id 2 section
{
io::Encoders::Collection::SIZE(),
0,
16383,
},
};

std::vector<SysExConf::Section> _analogSections = {
Expand Down
5 changes: 3 additions & 2 deletions src/firmware/application/util/conversion/Conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,16 @@ namespace util
database::Config::Section::encoder_t::ENABLE,
database::Config::Section::encoder_t::INVERT,
database::Config::Section::encoder_t::MODE,
database::Config::Section::encoder_t::MIDI_ID,
database::Config::Section::encoder_t::MIDI_ID_1,
database::Config::Section::encoder_t::CHANNEL,
database::Config::Section::encoder_t::PULSES_PER_STEP,
database::Config::Section::encoder_t::ACCELERATION,
database::Config::Section::encoder_t::MIDI_ID,
database::Config::Section::encoder_t::MIDI_ID_1,
database::Config::Section::encoder_t::REMOTE_SYNC,
database::Config::Section::encoder_t::LOWER_LIMIT,
database::Config::Section::encoder_t::UPPER_LIMIT,
database::Config::Section::encoder_t::REPEATED_VALUE,
database::Config::Section::encoder_t::MIDI_ID_2,
};

static constexpr database::Config::Section::analog_t SYS_EX2_DB_ANALOG[static_cast<uint8_t>(sys::Config::Section::analog_t::AMOUNT)] = {
Expand Down
11 changes: 9 additions & 2 deletions tests/src/database/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ TEST_F(DatabaseTest, ReadInitialValues)
DB_READ_VERIFY(0, database::Config::Section::encoder_t::MODE, i);
}

// midi id section
// midi id 1 section
// incremental values - first value should be 0, each successive value should be incremented by 1 for each group
for (size_t i = 0; i < io::Encoders::Collection::SIZE(); i++)
{
DB_READ_VERIFY(i, database::Config::Section::encoder_t::MIDI_ID, i);
DB_READ_VERIFY(i, database::Config::Section::encoder_t::MIDI_ID_1, i);
}

// midi channel section
Expand Down Expand Up @@ -188,6 +188,13 @@ TEST_F(DatabaseTest, ReadInitialValues)
DB_READ_VERIFY(127, database::Config::Section::encoder_t::REPEATED_VALUE, i);
}

// midi id 2 section
// incremental values - first value should be 0, each successive value should be incremented by 1 for each group
for (size_t i = 0; i < io::Encoders::Collection::SIZE(); i++)
{
DB_READ_VERIFY(i, database::Config::Section::encoder_t::MIDI_ID_2, i);
}

// analog block
//----------------------------------
// enable section
Expand Down
10 changes: 8 additions & 2 deletions tests/src/hw/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,10 @@ TEST_F(HWTest, DatabaseInitialValues)
ASSERT_EQ(0, _helper.databaseReadFromSystemViaSysEx(sys::Config::Section::encoder_t::MODE, i));
}

// midi id section
// midi id 1 section
for (size_t i = 0; i < io::Encoders::Collection::SIZE(); i += PARAM_SKIP)
{
ASSERT_EQ(i, _helper.databaseReadFromSystemViaSysEx(sys::Config::Section::encoder_t::MIDI_ID, i));
ASSERT_EQ(i, _helper.databaseReadFromSystemViaSysEx(sys::Config::Section::encoder_t::MIDI_ID_1, i));
}

// midi channel section
Expand Down Expand Up @@ -588,6 +588,12 @@ TEST_F(HWTest, DatabaseInitialValues)
ASSERT_EQ(127, _helper.databaseReadFromSystemViaSysEx(sys::Config::Section::encoder_t::REPEATED_VALUE, i));
}

// midi id 2 section
for (size_t i = 0; i < io::Encoders::Collection::SIZE(); i += PARAM_SKIP)
{
ASSERT_EQ(i, _helper.databaseReadFromSystemViaSysEx(sys::Config::Section::encoder_t::MIDI_ID_2, i));
}

// analog block
//----------------------------------
// enable section
Expand Down

0 comments on commit 55ab566

Please sign in to comment.