Skip to content

Commit

Permalink
display: show preset number
Browse files Browse the repository at this point in the history
  • Loading branch information
paradajz committed Mar 13, 2024
1 parent 1c9daf6 commit 1091bb1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/firmware/application/io/i2c/peripherals/display/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ Display::Display(I2C::Peripheral::HWA& hwa,
}
});

MIDIDispatcher.listen(messaging::eventType_t::SYSTEM,
[this](const messaging::event_t& event)
{
if (event.systemMessage == messaging::systemMessage_t::PRESET_CHANGED)
{
displayPreset(event.index + 1);
}
});

ConfigHandler.registerConfig(
sys::Config::block_t::I2C,
// read
Expand Down Expand Up @@ -126,6 +135,7 @@ bool Display::init()

clearEvent(eventType_t::IN);
clearEvent(eventType_t::OUT);
displayPreset(_database.getPreset() + 1);
}
else
{
Expand Down Expand Up @@ -404,6 +414,21 @@ void Display::displayWelcomeMessage()
core::mcu::timing::waitMs(2000);
}

void Display::displayPreset(int preset)
{
if (!_initialized)
{
return;
}

_lcdRowText.at(ROW_START_PRESET).at(COLUMN_START_PRESET) = '\0';
_stringBuilder.overwrite(_lcdRowText[ROW_START_PRESET].data());
_stringBuilder.append("P%d", preset);
_stringBuilder.fillUntil(MAX_COLUMNS);

updateText(ROW_START_PRESET);
}

void Display::displayEvent(eventType_t type, const messaging::event_t& event)
{
if (!_initialized)
Expand Down
2 changes: 2 additions & 0 deletions src/firmware/application/io/i2c/peripherals/display/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace io
bool deInit();
void setAlternateNoteDisplay(bool state);
void setRetentionTime(uint32_t retentionTime);
void displayPreset(int preset);
void displayEvent(eventType_t type, const messaging::event_t& event);
void displayWelcomeMessage();
void updateText(uint8_t row);
Expand Down Expand Up @@ -113,6 +114,7 @@ namespace io
static constexpr auto MAX_COLUMNS_OUT_MESSAGE = COLUMN_START_PRESET;
static constexpr uint8_t ROW_START_IN_MESSAGE = 0;
static constexpr uint8_t ROW_START_OUT_MESSAGE = 2;
static constexpr uint8_t ROW_START_PRESET = ROW_START_IN_MESSAGE;
static constexpr size_t U8X8_BUFFER_SIZE = 32;

uint8_t _u8x8Buffer[U8X8_BUFFER_SIZE] = {};
Expand Down

0 comments on commit 1091bb1

Please sign in to comment.