Skip to content

Commit

Permalink
encoders: enable setting lower and upper limit for certain message types
Browse files Browse the repository at this point in the history
  • Loading branch information
paradajz committed Feb 20, 2024
1 parent 65b98b9 commit 65faed0
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/firmware/application/database/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ namespace database
PULSES_PER_STEP,
ACCELERATION,
REMOTE_SYNC,
LOWER_LIMIT,
UPPER_LIMIT,
AMOUNT
};

Expand Down
18 changes: 18 additions & 0 deletions src/firmware/application/database/Layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@ namespace database
LESSDB::autoIncrementSetting_t::DISABLE,
0,
},

// lower value limit
{
io::Encoders::Collection::SIZE(),
LESSDB::sectionParameterType_t::WORD,
LESSDB::preserveSetting_t::DISABLE,
LESSDB::autoIncrementSetting_t::DISABLE,
0,
},

// upper value limit
{
io::Encoders::Collection::SIZE(),
LESSDB::sectionParameterType_t::WORD,
LESSDB::preserveSetting_t::DISABLE,
LESSDB::autoIncrementSetting_t::DISABLE,
16383,
},
};

std::vector<LESSDB::Section> _analogSections = {
Expand Down
4 changes: 4 additions & 0 deletions src/firmware/application/io/encoders/Encoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ void Encoders::sendMessage(size_t index, position_t encoderState, encoderDescrip
}
}

_value[index] = core::util::CONSTRAIN(static_cast<uint16_t>(_value[index]),
static_cast<uint16_t>(_database.read(database::Config::Section::encoder_t::LOWER_LIMIT, index)),
static_cast<uint16_t>(_database.read(database::Config::Section::encoder_t::UPPER_LIMIT, index)));

if (descriptor.type == type_t::CONTROL_CHANGE_14BIT)
{
if (descriptor.event.index >= 96)
Expand Down
2 changes: 2 additions & 0 deletions src/firmware/application/system/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ namespace sys
ACCELERATION,
MIDI_ID_MSB,
REMOTE_SYNC,
LOWER_LIMIT,
UPPER_LIMIT,
AMOUNT
};

Expand Down
14 changes: 14 additions & 0 deletions src/firmware/application/system/Layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ namespace sys
0,
1,
},

// lower value limit
{
io::Encoders::Collection::SIZE(),
0,
16383,
},

// upper value limit
{
io::Encoders::Collection::SIZE(),
0,
16383,
},
};

std::vector<SysExConf::Section> _analogSections = {
Expand Down
4 changes: 3 additions & 1 deletion src/firmware/application/util/conversion/Conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ namespace util
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::REMOTE_SYNC
database::Config::Section::encoder_t::REMOTE_SYNC,
database::Config::Section::encoder_t::LOWER_LIMIT,
database::Config::Section::encoder_t::UPPER_LIMIT,
};

static constexpr database::Config::Section::analog_t SYS_EX2_DB_ANALOG[static_cast<uint8_t>(sys::Config::Section::analog_t::AMOUNT)] = {
Expand Down

0 comments on commit 65faed0

Please sign in to comment.