Subversion Repositories svn.mios32

Rev

Rev 2164 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2039 tk 1
// $Id: seq_ui_pages.c 2532 2017-10-12 21:50:45Z tk $
2
/*
3
 * Page table
4
 *
5
 * ==========================================================================
6
 *
7
 *  Copyright (C) 2008 Thorsten Klose (tk@midibox.org)
8
 *  Licensed for personal non-commercial use only.
9
 *  All other rights reserved.
10
 *
11
 * ==========================================================================
12
 */
13
 
14
/////////////////////////////////////////////////////////////////////////////
15
// Include files
16
/////////////////////////////////////////////////////////////////////////////
17
 
18
#include <mios32.h>
19
#include <string.h>
20
 
21
#include "seq_ui.h"
22
#include "seq_ui_pages.h"
23
#include "seq_lcd.h"
24
 
25
/////////////////////////////////////////////////////////////////////////////
26
// Global variables
27
/////////////////////////////////////////////////////////////////////////////
28
 
29
 
30
/////////////////////////////////////////////////////////////////////////////
31
// The big page table
32
// Order of entries must be kept in sync with the seq_ui_page_t enum in seq_ui_pages.h
33
/////////////////////////////////////////////////////////////////////////////
34
 
35
typedef struct {
36
  const char *cfg_name;           // used in MBSEQ_HW.V4 file to config the page
37
  const char short_name[6];       // used in MENU page, up to 5 chars
38
  const char long_name[19];       // used in main page, up to 18 chars
39
  u8    old_bm_index;             // for compatibility of bookmark files, never change these numbers!
40
  s32 (*init_callback)(u32 mode); // will be called to initialize the page
41
} seq_ui_page_entry_t;
42
 
43
static const seq_ui_page_entry_t ui_menu_pages[SEQ_UI_PAGES] = {
44
  { "NONE",         "TODO ", "TODO page         ",  0, (void *)&SEQ_UI_TODO_Init },
45
  { "MENU",         "Menu ", "Page Menu         ",  1, (void *)&SEQ_UI_MENU_Init },
46
  { "FXSEL",        " Fx  ", "Fx Selection      ",  2, (void *)&SEQ_UI_FX_Init },
47
  { "STEPSEL",      "StpS.", "Step Selection    ",  3, (void *)&SEQ_UI_STEPSEL_Init },
48
  { "TRGSEL",       "TrgS.", "Trigger Selection ",  4, (void *)&SEQ_UI_TRGSEL_Init },
49
  { "PARSEL",       "ParS.", "Param. Selection  ",  5, (void *)&SEQ_UI_PARSEL_Init },
2532 tk 50
  { "INSEL",        "InsS.", "Inst. Selection   ",  6, (void *)&SEQ_UI_INSSEL_Init },
51
  { "TRACKSEL",     "TrkS.", "Track Selection   ",  7, (void *)&SEQ_UI_TRACKSEL_Init },
52
  { "BPM_PRESETS",  "BpmP.", "BPM Presets       ",  8, (void *)&SEQ_UI_BPM_PRESETS_Init },
2039 tk 53
 
54
  { "RES2",         "Res2 ", "Reserved page #2  ",  9, (void *)&SEQ_UI_TODO_Init },
55
  { "RES3",         "Res3 ", "Reserved page #3  ", 10, (void *)&SEQ_UI_TODO_Init },
56
  { "RES4",         "Res4 ", "Reserved page #4  ", 11, (void *)&SEQ_UI_TODO_Init },
57
  { "RES5",         "Res5 ", "Reserved page #5  ", 12, (void *)&SEQ_UI_TODO_Init },
58
  { "RES6",         "Res6 ", "Reserved page #6  ", 13, (void *)&SEQ_UI_TODO_Init },
59
  { "RES7",         "Res7 ", "Reserved page #7  ", 14, (void *)&SEQ_UI_TODO_Init },
60
  { "RES8",         "Res8 ", "Reserved page #8  ", 15, (void *)&SEQ_UI_TODO_Init },
61
 
62
  // menu selection  starts here
63
  { "EDIT",         "Edit ", "Edit              ", 16, (void *)&SEQ_UI_EDIT_Init },
64
  { "MUTE",         "Mute ", "Mute Tracks       ", 17, (void *)&SEQ_UI_MUTE_Init },
65
  { "MUTE_PORTS",   "PMute", "Mute Ports        ", 18, (void *)&SEQ_UI_PMUTE_Init },
66
  { "PATTERNS",     "Pat. ", "Patterns          ", 19, (void *)&SEQ_UI_PATTERN_Init },
67
  { "SONG",         "Song ", "Song              ", 20, (void *)&SEQ_UI_SONG_Init },
68
  { "MIXER",        "Mix  ", "Mixer             ", 21, (void *)&SEQ_UI_MIXER_Init },
69
  { "EVENTS",       "Evnt ", "Track Events      ", 22, (void *)&SEQ_UI_TRKEVNT_Init },
2092 tk 70
  { "INSTRUMENT",   "Inst ", "Track Instrument  ",  0, (void *)&SEQ_UI_TRKINST_Init },
2039 tk 71
  { "MODE",         "Mode ", "Track Mode        ", 23, (void *)&SEQ_UI_TRKMODE_Init },
72
  { "DIRECTION",    "Dir. ", "Track Direction   ", 24, (void *)&SEQ_UI_TRKDIR_Init },
73
  { "DIVIDER",      "Div. ", "Track ClockDivider", 25, (void *)&SEQ_UI_TRKDIV_Init },
74
  { "LENGTH",       "Len. ", "Track Length      ", 26, (void *)&SEQ_UI_TRKLEN_Init },
75
  { "TRANSPOSE",    "Trn. ", "Track Transpose   ", 27, (void *)&SEQ_UI_TRKTRAN_Init },
76
  { "GROOVE",       "Grv. ", "Track Groove      ", 28, (void *)&SEQ_UI_TRKGRV_Init },
77
  { "TRG_ASSIGN",   "Trg. ", "Track Triggers    ", 29, (void *)&SEQ_UI_TRGASG_Init },
78
  { "MORPH",        "Mrp. ", "Track Morphing    ", 30, (void *)&SEQ_UI_TRKMORPH_Init },
79
  { "RANDOM",       "Rnd. ", "Random Generator  ", 31, (void *)&SEQ_UI_TRKRND_Init },
80
  { "EUCLID",       "Eucl.", "Track Euclid Gen. ", 55, (void *)&SEQ_UI_TRKEUCLID_Init },
2164 tk 81
  { "JAM",          "Jam  ", "Jam (Recording)   ", 32, (void *)&SEQ_UI_TRKJAM_Init },
2039 tk 82
  { "MANUAL",       "Man. ", "Manual Trigger    ", 33, (void *)&SEQ_UI_MANUAL_Init },
83
  { "FX_ECHO",      "Echo ", "Track Fx: Echo    ", 34, (void *)&SEQ_UI_FX_ECHO_Init },
84
  { "FX_HUMANIZER", "Hum. ", "Track Fx: Humanize", 35, (void *)&SEQ_UI_FX_HUMANIZE_Init },
2118 tk 85
  { "FX_ROBOTIZER", "Rob. ", "Track Fx: Robotize", 57, (void *)&SEQ_UI_FX_ROBOTIZE_Init },
2039 tk 86
  { "FX_LIMIT",     "Limit", "Track Fx: Limit   ", 36, (void *)&SEQ_UI_FX_LIMIT_Init },
87
  { "FX_LFO",       "LFO  ", "Track Fx: LFO     ", 37, (void *)&SEQ_UI_FX_LFO_Init },
88
  { "FX_DUPLICATE", "Dupl.", "Track Fx: Duplict.", 56, (void *)&SEQ_UI_FX_DUPL_Init },
89
  { "FX_LOOP",      "Loop ", "Global Fx: Loop   ", 38, (void *)&SEQ_UI_FX_LOOP_Init },
90
  { "FX_SCALE",     "Scale", "Global Fx: Scale  ", 39, (void *)&SEQ_UI_FX_SCALE_Init },
91
  { "UTIL",         "Util ", "Utilities         ", 40, (void *)&SEQ_UI_UTIL_Init },
92
  { "BPM",          "BPM  ", "BPM Selection     ", 41, (void *)&SEQ_UI_BPM_Init },
93
  { "OPTIONS",      "Opt. ", "Options           ", 42, (void *)&SEQ_UI_OPT_Init },
94
  { "SAVE",         "Save ", "Save Pattern      ", 43, (void *)&SEQ_UI_SAVE_Init },
95
  { "METRONOME",    "Metr.", "Metronome         ", 44, (void *)&SEQ_UI_METRONOME_Init },
96
  { "MIDI",         "MIDI ", "MIDI Configuration", 45, (void *)&SEQ_UI_MIDI_Init },
97
  { "MIDIMON",      "MMon ", "MIDI Monitor      ", 46, (void *)&SEQ_UI_MIDIMON_Init },
98
  { "SYSEX",        "SysEx", "SysEx             ", 47, (void *)&SEQ_UI_SYSEX_Init },
99
  { "CVCFG",        "CVCfg", "CV Configuration  ", 48, (void *)&SEQ_UI_CV_Init },
100
  { "DISK",         "Disk ", "Disk (SD Card)    ", 49, (void *)&SEQ_UI_DISK_Init },
101
  { "ETH_OSC",      "Eth. ", "Ethernet (OSC)    ", 50, (void *)&SEQ_UI_ETH_Init },
102
  { "LIVE",         "Live ", "Live Play         ", 53, (void *)&SEQ_UI_TRKLIVE_Init },
103
  { "REMIX",        "Remix", "Pattern Remix     ", 54, (void *)&SEQ_UI_PATTERN_RMX_Init },
104
  { "BOOKMARKS",    "BookM", "Bookmarks         ", 51, (void *)&SEQ_UI_BOOKMARKS_Init },
105
  { "ABOUT",        "About", "About this MIDIbox", 52, (void *)&SEQ_UI_INFO_Init },
106
};
107
 
108
 
109
/////////////////////////////////////////////////////////////////////////////
110
// Access functions to the table
111
/////////////////////////////////////////////////////////////////////////////
112
s32 SEQ_UI_PAGES_CallInit(seq_ui_page_t page)
113
{
114
  if( page >= SEQ_UI_PAGES )
115
    return -1; // invalid page
116
 
117
  if( ui_menu_pages[ui_page].init_callback != NULL )
118
    return ui_menu_pages[ui_page].init_callback(0); // mode
119
 
120
  return -2; // no init function available
121
}
122
 
123
const char *SEQ_UI_PAGES_PageNameGet(seq_ui_page_t page)
124
{
125
  if( page >= SEQ_UI_PAGES )
126
    return "** Invalid Page **";
127
 
128
  return (const char *)ui_menu_pages[page].long_name;
129
}
130
 
131
const char *SEQ_UI_PAGES_CfgNameGet(seq_ui_page_t page)
132
{
133
  if( page >= SEQ_UI_PAGES )
134
    return "INVALID";
135
 
136
  return ui_menu_pages[page].cfg_name;
137
}
138
 
139
seq_ui_page_t SEQ_UI_PAGES_CfgNameSearch(const char *name)
140
{
141
  int i;
142
 
143
  seq_ui_page_entry_t *page_ptr = (seq_ui_page_entry_t *)&ui_menu_pages[0];
144
  for(i=0; i<SEQ_UI_PAGES; ++i, ++page_ptr) {
145
    if( strcasecmp(name, page_ptr->cfg_name) == 0 )
146
      return i;
147
  }
148
 
149
  return SEQ_UI_PAGE_NONE;
150
}
151
 
152
seq_ui_page_t SEQ_UI_PAGES_OldBmIndexSearch(u32 bm_index)
153
{
154
  int i;
155
 
156
  seq_ui_page_entry_t *page_ptr = (seq_ui_page_entry_t *)&ui_menu_pages[0];
157
  for(i=0; i<SEQ_UI_PAGES; ++i, ++page_ptr) {
158
    if( page_ptr->old_bm_index == bm_index )
159
      return i;
160
  }
161
 
162
  return SEQ_UI_PAGE_NONE;
163
}
164
 
165
 
166
/////////////////////////////////////////////////////////////////////////////
167
// Menu Shortcuts
168
/////////////////////////////////////////////////////////////////////////////
169
 
170
// following pages are directly accessible with the GP buttons when MENU button is pressed
171
static seq_ui_page_t ui_shortcut_menu_pages[16] = {
172
  SEQ_UI_PAGE_MIXER,       // GP1
173
  SEQ_UI_PAGE_TRKEVNT,     // GP2
174
  SEQ_UI_PAGE_TRKMODE,     // GP3
175
  SEQ_UI_PAGE_TRKDIR,      // GP4
176
  SEQ_UI_PAGE_TRKDIV,      // GP5
177
  SEQ_UI_PAGE_TRKLEN,      // GP6
178
  SEQ_UI_PAGE_TRKTRAN,     // GP7
179
  SEQ_UI_PAGE_TRKGRV,      // GP8
180
  SEQ_UI_PAGE_TRGASG,      // GP9
181
  SEQ_UI_PAGE_FX,          // GP10
182
  SEQ_UI_PAGE_MANUAL,      // GP11
183
  SEQ_UI_PAGE_TRKMORPH,    // GP12
184
  SEQ_UI_PAGE_BPM,         // GP13
185
  SEQ_UI_PAGE_SAVE,        // GP14
186
  SEQ_UI_PAGE_MIDI,        // GP15
187
  SEQ_UI_PAGE_SYSEX        // GP16
188
};
189
 
190
seq_ui_page_t SEQ_UI_PAGES_MenuShortcutPageGet(u8 pos)
191
{
192
  if( pos >= 16 )
193
    return SEQ_UI_PAGE_NONE;
194
 
195
  return ui_shortcut_menu_pages[pos];
196
}
197
 
198
s32 SEQ_UI_PAGES_MenuShortcutPageSet(u8 pos, seq_ui_page_t page)
199
{
200
  if( page >= SEQ_UI_PAGES )
201
    return -1; // invalid page
202
 
203
  if( pos >= 16 )
204
    return -2; // invalid pos
205
 
206
  ui_shortcut_menu_pages[pos] = page;
207
 
208
  return 0; // no error
209
}
210
 
211
 
212
const char *SEQ_UI_PAGES_MenuShortcutNameGet(u8 pos)
213
{
214
  if( pos >= 16 )
215
    return "?????";
216
 
217
  return ui_menu_pages[ui_shortcut_menu_pages[pos]].short_name;
218
}