From 55ab56668d4a89b8f87560fc57f5954f2b626e7c Mon Sep 17 00:00:00 2001 From: paradajz <2544094+paradajz@users.noreply.github.com> Date: Tue, 16 Apr 2024 13:19:20 +0200 Subject: [PATCH] encoders: add the option to configure two midi ids --- src/firmware/application/database/Config.h | 3 ++- src/firmware/application/database/Layout.h | 11 ++++++++++- src/firmware/application/io/encoders/Encoders.cpp | 4 ++-- src/firmware/application/system/Config.h | 3 ++- src/firmware/application/system/Layout.h | 9 ++++++++- src/firmware/application/util/conversion/Conversion.h | 5 +++-- tests/src/database/test.cpp | 11 +++++++++-- tests/src/hw/test.cpp | 10 ++++++++-- 8 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/firmware/application/database/Config.h b/src/firmware/application/database/Config.h index 347193bcb..ebe40c926 100644 --- a/src/firmware/application/database/Config.h +++ b/src/firmware/application/database/Config.h @@ -75,7 +75,7 @@ namespace database ENABLE, INVERT, MODE, - MIDI_ID, + MIDI_ID_1, CHANNEL, PULSES_PER_STEP, ACCELERATION, @@ -83,6 +83,7 @@ namespace database LOWER_LIMIT, UPPER_LIMIT, REPEATED_VALUE, + MIDI_ID_2, AMOUNT }; diff --git a/src/firmware/application/database/Layout.h b/src/firmware/application/database/Layout.h index d6045c58a..0dee3e83a 100644 --- a/src/firmware/application/database/Layout.h +++ b/src/firmware/application/database/Layout.h @@ -144,7 +144,7 @@ namespace database 0, }, - // midi id section + // midi id 1 section { io::Encoders::Collection::SIZE(), LESSDB::sectionParameterType_t::WORD, @@ -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 _analogSections = { diff --git a/src/firmware/application/io/encoders/Encoders.cpp b/src/firmware/application/io/encoders/Encoders.cpp index fcd401e08..5827a96a4 100644 --- a/src/firmware/application/io/encoders/Encoders.cpp +++ b/src/firmware/application/io/encoders/Encoders.cpp @@ -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; } @@ -451,7 +451,7 @@ void Encoders::fillEncoderDescriptor(size_t index, encoderDescriptor_t& descript descriptor.type = static_cast(_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(descriptor.type)]; } diff --git a/src/firmware/application/system/Config.h b/src/firmware/application/system/Config.h index 132f9fd10..19644fd96 100644 --- a/src/firmware/application/system/Config.h +++ b/src/firmware/application/system/Config.h @@ -76,7 +76,7 @@ namespace sys ENABLE, INVERT, MODE, - MIDI_ID, + MIDI_ID_1, CHANNEL, PULSES_PER_STEP, ACCELERATION, @@ -85,6 +85,7 @@ namespace sys LOWER_LIMIT, UPPER_LIMIT, REPEATED_VALUE, + MIDI_ID_2, AMOUNT }; diff --git a/src/firmware/application/system/Layout.h b/src/firmware/application/system/Layout.h index d7d999b4e..13eb5c8ea 100644 --- a/src/firmware/application/system/Layout.h +++ b/src/firmware/application/system/Layout.h @@ -115,7 +115,7 @@ namespace sys static_cast(io::Encoders::type_t::AMOUNT) - 1, }, - // midi id section + // midi id 1 section { io::Encoders::Collection::SIZE(), 0, @@ -177,6 +177,13 @@ namespace sys 0, 16383, }, + + // midi id 2 section + { + io::Encoders::Collection::SIZE(), + 0, + 16383, + }, }; std::vector _analogSections = { diff --git a/src/firmware/application/util/conversion/Conversion.h b/src/firmware/application/util/conversion/Conversion.h index dea4b9608..b75f10e47 100644 --- a/src/firmware/application/util/conversion/Conversion.h +++ b/src/firmware/application/util/conversion/Conversion.h @@ -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(sys::Config::Section::analog_t::AMOUNT)] = { diff --git a/tests/src/database/test.cpp b/tests/src/database/test.cpp index ac8ac4d4f..8d02531bd 100644 --- a/tests/src/database/test.cpp +++ b/tests/src/database/test.cpp @@ -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 @@ -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 diff --git a/tests/src/hw/test.cpp b/tests/src/hw/test.cpp index 42434d581..606bdb6f8 100644 --- a/tests/src/hw/test.cpp +++ b/tests/src/hw/test.cpp @@ -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 @@ -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