@@ -20,7 +20,8 @@ MinatonUI::MinatonUI()
2020 , fSwitchNoLightImage_OFF(Art::switch_off_nolightData, Art::switch_off_nolightWidth, Art::switch_off_nolightHeight, kImageFormatBGRA )
2121 , fImgLabelMixMode(Art::mix_mode_labelData, Art::mix_mode_labelWidth, Art::mix_mode_labelHeight, kImageFormatBGRA )
2222 , fImgLabelMonoStereo(Art::mono_stereo_labelData, Art::mono_stereo_labelWidth, Art::mono_stereo_labelHeight, kImageFormatBGRA )
23-
23+ , fImgPanicButton(Art::panic_buttonData, Art::panic_buttonWidth, Art::panic_buttonHeight)
24+ , fImgPanicButton_Pressed(Art::panic_button_pressedData, Art::panic_button_pressedWidth, Art::panic_button_pressedHeight)
2425{
2526 // Knob initial angles
2627 constexpr int KNOB_ANGLE = 287 ;
@@ -100,6 +101,9 @@ MinatonUI::MinatonUI()
100101 // Equalizer params
101102 _createKnob (fCutOffFrequency , PARAM_FREQUENCY, 377 , 368 , KNOB_ANGLE);
102103 _createKnob (fResonance , PARAM_RESONANCE, 377 , 422 , KNOB_ANGLE);
104+
105+ // Panic button
106+ _createButton (fPanic , BTN_PANIC, fImgPanicButton , fImgPanicButton_Pressed , 452 , 505 );
103107}
104108
105109void MinatonUI::parameterChanged (uint32_t index, float value)
@@ -279,6 +283,12 @@ void MinatonUI::parameterChanged(uint32_t index, float value)
279283
280284void MinatonUI::imageButtonClicked (ImageButton* button, int )
281285{
286+ switch (button->getId ()) {
287+ case BTN_PANIC: {
288+ panic ();
289+ break ;
290+ }
291+ }
282292}
283293
284294void MinatonUI::imageSwitchClicked (ImageSwitch* button, bool down)
@@ -365,6 +375,27 @@ void MinatonUI::onDisplay()
365375
366376void MinatonUI::idleCallback () { }
367377
378+ void MinatonUI::panic ()
379+ {
380+ /* *
381+ There is no API to send MIDI data to DSP side. Instead, DPF provides UI::sendNote().
382+ But we can still send any MIDI data via this method, simply doing a hack.
383+
384+ In method UI::sendNote(uint8_t channel, uint8_t note, uint8_t velocity):
385+
386+ `channel` will be converted into MIDI data 0 by:
387+ `midi_data[0] = (velocity != 0 ? 0x90 : 0x80) | channel;`
388+
389+ To send MIDI controller data, we need to transform midi_data[0] into MIDI_STATUS_CONTROLLER (0xB0)
390+ by simply applying a proper `channel` value. It would be easy to calculate:
391+ 0x80 | channel = 0xB0
392+ => 0b10000000 | channel = 0b10110000
393+ => channel = 0b00110000
394+ => channel = 0x30
395+ */
396+ sendNote (0x30 , 0x7B , 0 ); // MIDI_CC_ALL_NOTES_OFF = 0x7B
397+ }
398+
368399// -----------------------------------------------------------------------
369400
370401UI* createUI ()
0 commit comments