Subversion Repositories svn.mios32

Rev

Rev 2168 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2168 Rev 2532
Line 1... Line 1...
1
// $Id: seq_ui_trgsel.c 2168 2015-04-27 18:45:02Z tk $
1
// $Id: seq_ui_trgsel.c 2532 2017-10-12 21:50:45Z tk $
2
/*
2
/*
3
 * Trigger selection page (entered with Trigger Layer C button)
3
 * Trigger selection page (entered with Trigger Layer C button)
4
 *
4
 *
5
 * ==========================================================================
5
 * ==========================================================================
6
 *
6
 *
Line 32... Line 32...
32
  if( ui_cursor_flash ) // if flashing flag active: no LED flag set
32
  if( ui_cursor_flash ) // if flashing flag active: no LED flag set
33
    return 0;
33
    return 0;
34
34
35
  u8 visible_track = SEQ_UI_VisibleTrackGet();
35
  u8 visible_track = SEQ_UI_VisibleTrackGet();
36
  u8 event_mode = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_EVENT_MODE);
36
  u8 event_mode = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_EVENT_MODE);
-
 
37
  u8 selbuttons_available = seq_hwcfg_blm8x8.dout_gp_mapping == 3;
37
38
38
  if( event_mode == SEQ_EVENT_MODE_Drum )
39
  if( event_mode == SEQ_EVENT_MODE_Drum && !selbuttons_available )
39
    *gp_leds = 1 << ui_selected_instrument;
40
    *gp_leds = 1 << ui_selected_instrument;
40
  else
41
  else
41
    *gp_leds = 1 << ui_selected_trg_layer;
42
    *gp_leds = 1 << ui_selected_trg_layer;
42
43
43
  return 0; // no error
44
  return 0; // no error
Line 53... Line 54...
53
/////////////////////////////////////////////////////////////////////////////
54
/////////////////////////////////////////////////////////////////////////////
54
static s32 Encoder_Handler(seq_ui_encoder_t encoder, s32 incrementer)
55
static s32 Encoder_Handler(seq_ui_encoder_t encoder, s32 incrementer)
55
{
56
{
56
  u8 visible_track = SEQ_UI_VisibleTrackGet();
57
  u8 visible_track = SEQ_UI_VisibleTrackGet();
57
  u8 event_mode = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_EVENT_MODE);
58
  u8 event_mode = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_EVENT_MODE);
-
 
59
  u8 selbuttons_available = seq_hwcfg_blm8x8.dout_gp_mapping == 3;
58
60
59
  if( encoder <= SEQ_UI_ENCODER_GP16 ) {
61
  if( encoder <= SEQ_UI_ENCODER_GP16 ) {
60
    // select new layer/instrument
62
    // select new layer/instrument
61
63
62
    if( event_mode == SEQ_EVENT_MODE_Drum ) {
64
    if( event_mode == SEQ_EVENT_MODE_Drum && !selbuttons_available ) {
63
      if( encoder >= SEQ_TRG_NumInstrumentsGet(visible_track) )
65
      if( encoder >= SEQ_TRG_NumInstrumentsGet(visible_track) )
64
    return -1;
66
    return -1;
65
      ui_selected_instrument = encoder;
67
      ui_selected_instrument = encoder;
66
    } else {
68
    } else {
67
      if( encoder >= SEQ_TRG_NumLayersGet(visible_track) )
69
      if( encoder >= SEQ_TRG_NumLayersGet(visible_track) )
68
    return -1;
70
    return -1;
69
      ui_selected_trg_layer = encoder;
71
      ui_selected_trg_layer = encoder;
70
    }
72
    }
71
73
72
    if( seq_hwcfg_button_beh.par_layer ) {
74
    if( seq_hwcfg_button_beh.trg_layer ) {
73
      // if toggle function active: jump back to previous menu
75
      // if toggle function active: jump back to previous menu
74
      // this is especially useful for the emulated MBSEQ, where we can only click on a single button
76
      // this is especially useful for the emulated MBSEQ, where we can only click on a single button
75
      // (trigger gets deactivated when clicking on GP button or moving encoder)
77
      // (trigger gets deactivated when clicking on GP button or moving encoder)
76
      seq_ui_button_state.TRG_LAYER_SEL = 0;
78
      seq_ui_button_state.TRG_LAYER_SEL = 0;
77
      SEQ_UI_PageSet(ui_trglayer_prev_page);
79
      SEQ_UI_PageSet(ui_trglayer_prev_page);
78
    }
80
    }
79
81
80
    return 1; // value changed
82
    return 1; // value changed
81
  } else if( encoder == SEQ_UI_ENCODER_Datawheel ) {
83
  } else if( encoder == SEQ_UI_ENCODER_Datawheel ) {
82
    if( event_mode == SEQ_EVENT_MODE_Drum ) {
84
    if( event_mode == SEQ_EVENT_MODE_Drum && !selbuttons_available ) {
83
      return SEQ_UI_Var8_Inc(&ui_selected_instrument, 0, SEQ_TRG_NumInstrumentsGet(visible_track)-1, incrementer);
85
      return SEQ_UI_Var8_Inc(&ui_selected_instrument, 0, SEQ_TRG_NumInstrumentsGet(visible_track)-1, incrementer);
84
    } else {
86
    } else {
85
      return SEQ_UI_Var8_Inc(&ui_selected_trg_layer, 0, SEQ_TRG_NumLayersGet(visible_track)-1, incrementer);
87
      return SEQ_UI_Var8_Inc(&ui_selected_trg_layer, 0, SEQ_TRG_NumLayersGet(visible_track)-1, incrementer);
86
    }
88
    }
87
  }
89
  }
Line 95... Line 97...
95
// Should return:
97
// Should return:
96
//   1 if value has been changed
98
//   1 if value has been changed
97
//   0 if value hasn't been changed
99
//   0 if value hasn't been changed
98
//  -1 if invalid or unsupported button
100
//  -1 if invalid or unsupported button
99
/////////////////////////////////////////////////////////////////////////////
101
/////////////////////////////////////////////////////////////////////////////
100
static s32 Button_Handler(seq_ui_button_t button, s32 depressed)
102
s32 SEQ_UI_TRGSEL_Button_Handler(seq_ui_button_t button, s32 depressed)
101
{
103
{
102
  if( depressed ) return 0; // ignore when button depressed
104
  if( depressed ) return 0; // ignore when button depressed
103
105
104
#if 0
106
#if 0
105
  // leads to: comparison is always true due to limited range of data type
107
  // leads to: comparison is always true due to limited range of data type
Line 151... Line 153...
151
  //  BD   SD   LT   MT   HT   CP   MA   RS   CB   CY   OH   CH  Smp1 Smp2 Smp3 Smp4 
153
  //  BD   SD   LT   MT   HT   CP   MA   RS   CB   CY   OH   CH  Smp1 Smp2 Smp3 Smp4 
152
  // ...horizontal VU meters...
154
  // ...horizontal VU meters...
153
155
154
  u8 visible_track = SEQ_UI_VisibleTrackGet();
156
  u8 visible_track = SEQ_UI_VisibleTrackGet();
155
  u8 event_mode = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_EVENT_MODE);
157
  u8 event_mode = SEQ_CC_Get(visible_track, SEQ_CC_MIDI_EVENT_MODE);
-
 
158
  u8 selbuttons_available = seq_hwcfg_blm8x8.dout_gp_mapping == 3;
156
159
-
 
160
  if( high_prio ) {
157
  if( high_prio && event_mode == SEQ_EVENT_MODE_Drum ) {
161
    if( event_mode == SEQ_EVENT_MODE_Drum && !selbuttons_available ) {
158
    ///////////////////////////////////////////////////////////////////////////
162
      ///////////////////////////////////////////////////////////////////////////
159
    // frequently update VU meters
163
      // frequently update VU meters
160
164
161
    SEQ_LCD_CursorSet(0, 1);
165
      SEQ_LCD_CursorSet(0, 1);
162
166
Line 165... Line 169...
165
    for(drum=0; drum<num_instruments; ++drum) {
169
      for(drum=0; drum<num_instruments; ++drum) {
166
      if( seq_core_trk[visible_track].layer_muted & (1 << drum) )
170
    if( seq_core_trk[visible_track].layer_muted & (1 << drum) )
167
    SEQ_LCD_PrintString("Mute ");
171
      SEQ_LCD_PrintString("Mute ");
168
      else
172
    else
169
    SEQ_LCD_PrintHBar((seq_layer_vu_meter[drum] >> 3) & 0xf);
173
      SEQ_LCD_PrintHBar((seq_layer_vu_meter[drum] >> 3) & 0xf);
-
 
174
      }
170
    }
175
    }
171
176
172
    return 0; // no error
177
    return 0; // no error
173
  }
178
  }
174
179
175
  if( event_mode == SEQ_EVENT_MODE_Drum ) {
180
  if( event_mode == SEQ_EVENT_MODE_Drum && !selbuttons_available ) {
176
    u8 num_instruments = SEQ_TRG_NumInstrumentsGet(visible_track);
181
    u8 num_instruments = SEQ_TRG_NumInstrumentsGet(visible_track);
177
182
178
    ///////////////////////////////////////////////////////////////////////////
183
    ///////////////////////////////////////////////////////////////////////////
179
    SEQ_LCD_CursorSet(0, 0);
184
    SEQ_LCD_CursorSet(0, 0);
180
185
Line 229... Line 234...
229
// Initialisation
234
// Initialisation
230
/////////////////////////////////////////////////////////////////////////////
235
/////////////////////////////////////////////////////////////////////////////
231
s32 SEQ_UI_TRGSEL_Init(u32 mode)
236
s32 SEQ_UI_TRGSEL_Init(u32 mode)
232
{
237
{
233
  // install callback routines
238
  // install callback routines
234
  SEQ_UI_InstallButtonCallback(Button_Handler);
239
  SEQ_UI_InstallButtonCallback(SEQ_UI_TRGSEL_Button_Handler);
235
  SEQ_UI_InstallEncoderCallback(Encoder_Handler);
240
  SEQ_UI_InstallEncoderCallback(Encoder_Handler);
236
  SEQ_UI_InstallLEDCallback(LED_Handler);
241
  SEQ_UI_InstallLEDCallback(LED_Handler);
237
  SEQ_UI_InstallLCDCallback(LCD_Handler);
242
  SEQ_UI_InstallLCDCallback(LCD_Handler);
238
243
239
  // we want to show horizontal VU meters
244
  // we want to show horizontal VU meters