26class FollowChannel final :
public Integer {
28 using Integer::Integer;
30 FollowChannel(l10n::String newName, l10n::String
title, MIDIFollowChannelType type)
32 midiInput(midiEngine.midiFollowChannelType[util::to_underlying(type)]) {}
35 void writeCurrentValue()
override { midiInput.channelOrZone = this->getValue(); }
36 [[nodiscard]] int32_t getMaxValue()
const override {
return NUM_CHANNELS; }
39 void drawInteger(int32_t textWidth, int32_t textHeight, int32_t yPixel)
override {
44 char const* differentiationString;
45 if (MIDIDeviceManager::differentiatingInputsByDevice) {
46 differentiationString = l10n::get(l10n::String::STRING_FOR_INPUT_DIFFERENTIATION_ON);
49 differentiationString = l10n::get(l10n::String::STRING_FOR_INPUT_DIFFERENTIATION_OFF);
51 canvas.
drawString(differentiationString, 0, yPixel, kTextSpacingX, kTextSizeYUpdated);
53 yPixel += kTextSpacingY;
55 char const* deviceString = l10n::get(l10n::String::STRING_FOR_FOLLOW_DEVICE_UNASSIGNED);
56 if (midiInput.cable) {
57 deviceString = midiInput.cable->getDisplayName();
59 canvas.
drawString(deviceString, 0, yPixel, kTextSpacingX, kTextSizeYUpdated);
60 deluge::hid::display::OLED::setupSideScroller(0, deviceString, kTextSpacingX, OLED_MAIN_WIDTH_PIXELS, yPixel,
61 yPixel + 8, kTextSpacingX, kTextSpacingY,
false);
63 yPixel += kTextSpacingY;
65 char const* channelText;
66 if (this->getValue() == MIDI_CHANNEL_MPE_LOWER_ZONE) {
67 channelText = l10n::get(l10n::String::STRING_FOR_MPE_LOWER_ZONE);
69 else if (this->getValue() == MIDI_CHANNEL_MPE_UPPER_ZONE) {
70 channelText = l10n::get(l10n::String::STRING_FOR_MPE_UPPER_ZONE);
72 else if (this->getValue() == MIDI_CHANNEL_NONE) {
73 channelText = l10n::get(l10n::String::STRING_FOR_FOLLOW_CHANNEL_UNASSIGNED);
76 channelText = l10n::get(l10n::String::STRING_FOR_CHANNEL);
78 int32_t channelmod = (midiInput.channelOrZone >= IS_A_CC) * IS_A_CC;
79 intToString(midiInput.channelOrZone + 1 - channelmod, buffer, 1);
80 canvas.
drawString(buffer, kTextSpacingX * 8, yPixel, kTextSpacingX, kTextSizeYUpdated);
82 canvas.
drawString(channelText, 0, yPixel, kTextSpacingX, kTextSizeYUpdated);
85 void drawValue()
override {
86 if (this->getValue() == MIDI_CHANNEL_MPE_LOWER_ZONE) {
87 display->setText(l10n::get(l10n::String::STRING_FOR_MPE_LOWER_ZONE));
89 else if (this->getValue() == MIDI_CHANNEL_MPE_UPPER_ZONE) {
90 display->setText(l10n::get(l10n::String::STRING_FOR_MPE_UPPER_ZONE));
92 else if (this->getValue() == MIDI_CHANNEL_NONE) {
93 display->setText(l10n::get(l10n::String::STRING_FOR_NONE));
96 display->setTextAsNumber(this->getValue() + 1);
101 if (this->getValue() == MIDI_CHANNEL_NONE) {
105 else if (offset < 0) {
106 this->setValue(MIDI_CHANNEL_MPE_UPPER_ZONE);
110 this->setValue(this->getValue() + offset);
111 if ((this->getValue() >= NUM_CHANNELS) || (this->getValue() < 0)) {
112 this->setValue(MIDI_CHANNEL_NONE);
122 this->setValue(MIDI_CHANNEL_NONE);
124 if (soundEditor.getCurrentMenuItem() ==
this) {
128 display->displayPopup(l10n::get(l10n::String::STRING_FOR_UNLEARNED));
133 this->setValue(channel);
134 midiInput.cable = &cable;
135 midiInput.channelOrZone = channel;
137 if (soundEditor.getCurrentMenuItem() ==
this) {
141 display->displayPopup(l10n::get(l10n::String::STRING_FOR_LEARNED));
147 void learnCC(
MIDICable& cable, int32_t channel, int32_t ccNumber, int32_t value) {
148 this->setValue(channel);
149 midiInput.cable = &cable;
150 midiInput.channelOrZone = channel;
152 if (soundEditor.getCurrentMenuItem() ==
this) {
156 display->displayPopup(l10n::get(l10n::String::STRING_FOR_LEARNED));
160 void renderDisplay() {
161 if (display->haveOLED()) {
170 MIDIFollowChannelType channelType;
171 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:245