27class FollowChannel final :
public Integer {
29 using Integer::Integer;
31 FollowChannel(l10n::String newName, l10n::String
title, MIDIFollowChannelType type)
33 midiInput(midiEngine.midiFollowChannelType[util::to_underlying(type)]) {}
36 void writeCurrentValue()
override { midiInput.channelOrZone = this->getValue(); }
37 [[nodiscard]] int32_t getMaxValue()
const override {
return NUM_CHANNELS; }
40 void drawInteger(int32_t textWidth, int32_t textHeight, int32_t yPixel)
override {
45 char const* differentiationString;
46 if (MIDIDeviceManager::differentiatingInputsByDevice) {
47 differentiationString = l10n::get(l10n::String::STRING_FOR_INPUT_DIFFERENTIATION_ON);
50 differentiationString = l10n::get(l10n::String::STRING_FOR_INPUT_DIFFERENTIATION_OFF);
52 canvas.
drawString(differentiationString, 0, yPixel, kTextSpacingX, kTextSizeYUpdated);
54 yPixel += kTextSpacingY;
56 char const* deviceString = l10n::get(l10n::String::STRING_FOR_FOLLOW_DEVICE_UNASSIGNED);
57 if (midiInput.cable) {
58 deviceString = midiInput.cable->getDisplayName();
60 canvas.
drawString(deviceString, 0, yPixel, kTextSpacingX, kTextSizeYUpdated);
61 deluge::hid::display::OLED::setupSideScroller(0, deviceString, kTextSpacingX, OLED_MAIN_WIDTH_PIXELS, yPixel,
62 yPixel + 8, kTextSpacingX, kTextSpacingY,
false);
64 yPixel += kTextSpacingY;
66 char const* channelText;
67 if (this->getValue() == MIDI_CHANNEL_MPE_LOWER_ZONE) {
68 channelText = l10n::get(l10n::String::STRING_FOR_MPE_LOWER_ZONE);
70 else if (this->getValue() == MIDI_CHANNEL_MPE_UPPER_ZONE) {
71 channelText = l10n::get(l10n::String::STRING_FOR_MPE_UPPER_ZONE);
73 else if (this->getValue() == MIDI_CHANNEL_NONE) {
74 channelText = l10n::get(l10n::String::STRING_FOR_FOLLOW_CHANNEL_UNASSIGNED);
77 channelText = l10n::get(l10n::String::STRING_FOR_CHANNEL);
79 int32_t channelmod = (midiInput.channelOrZone >= IS_A_CC) * IS_A_CC;
80 intToString(midiInput.channelOrZone + 1 - channelmod, buffer, 1);
81 canvas.
drawString(buffer, kTextSpacingX * 8, yPixel, kTextSpacingX, kTextSizeYUpdated);
83 canvas.
drawString(channelText, 0, yPixel, kTextSpacingX, kTextSizeYUpdated);
86 void drawValue()
override {
87 if (this->getValue() == MIDI_CHANNEL_MPE_LOWER_ZONE) {
88 display->setText(l10n::get(l10n::String::STRING_FOR_MPE_LOWER_ZONE));
90 else if (this->getValue() == MIDI_CHANNEL_MPE_UPPER_ZONE) {
91 display->setText(l10n::get(l10n::String::STRING_FOR_MPE_UPPER_ZONE));
93 else if (this->getValue() == MIDI_CHANNEL_NONE) {
94 display->setText(l10n::get(l10n::String::STRING_FOR_NONE));
97 display->setTextAsNumber(this->getValue() + 1);
102 if (this->getValue() == MIDI_CHANNEL_NONE) {
106 else if (offset < 0) {
107 this->setValue(MIDI_CHANNEL_MPE_UPPER_ZONE);
111 this->setValue(this->getValue() + offset);
112 if ((this->getValue() >= NUM_CHANNELS) || (this->getValue() < 0)) {
113 this->setValue(MIDI_CHANNEL_NONE);
123 this->setValue(MIDI_CHANNEL_NONE);
125 if (soundEditor.getCurrentMenuItem() ==
this) {
129 display->displayPopup(l10n::get(l10n::String::STRING_FOR_UNLEARNED));
134 this->setValue(channel);
135 midiInput.cable = &cable;
136 midiInput.channelOrZone = channel;
138 if (soundEditor.getCurrentMenuItem() ==
this) {
142 display->displayPopup(l10n::get(l10n::String::STRING_FOR_LEARNED));
148 void learnCC(
MIDICable& cable, int32_t channel, int32_t ccNumber, int32_t value) {
149 this->setValue(channel);
150 midiInput.cable = &cable;
151 midiInput.channelOrZone = channel;
153 if (soundEditor.getCurrentMenuItem() ==
this) {
157 display->displayPopup(l10n::get(l10n::String::STRING_FOR_LEARNED));
161 void renderDisplay() {
162 if (display->haveOLED()) {
171 MIDIFollowChannelType channelType;
172 LearnedMIDI& midiInput;
void drawString(std::string_view str, int32_t pixelX, int32_t pixelY, int32_t textWidth, int32_t textHeight, int32_t scrollPos=0, int32_t endX=OLED_MAIN_WIDTH_PIXELS, bool useTextWidth=false)
Definition canvas.cpp:123