1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 Björn Stenberg
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdbool.h>
#include "kernel.h"
#include "lcd.h"
#include "menu.h"
#include "button.h"
#include "mp3_playback.h"
#include "settings.h"
#include "status.h"
#include "screens.h"
#ifdef HAVE_LCD_BITMAP
#include "icons.h"
#endif
#include "lang.h"
#include "sprintf.h"
#include "talk.h"
#include "misc.h"
static const char* const fmt[] =
{
"", /* no decimals */
"%d.%d %s ", /* 1 decimal */
"%d.%02d %s " /* 2 decimals */
};
bool set_sound(const char* string,
int* variable,
int setting)
{
bool done = false;
bool changed = true;
int min, max;
int val;
int numdec;
int integer;
int dec;
const char* unit;
char str[32];
int talkunit = UNIT_INT;
int steps;
int button;
unit = mpeg_sound_unit(setting);
numdec = mpeg_sound_numdecimals(setting);
steps = mpeg_sound_steps(setting);
min = mpeg_sound_min(setting);
max = mpeg_sound_max(setting);
if (*unit == 'd') /* crude reconstruction */
talkunit = UNIT_DB;
else if (*unit == '%')
talkunit = UNIT_PERCENT;
else if (*unit == 'H')
talkunit = UNIT_HERTZ;
#ifdef HAVE_LCD_BITMAP
if(global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
#endif
lcd_clear_display();
lcd_puts_scroll(0,0,string);
while (!done) {
if (changed) {
val = mpeg_val2phys(setting, *variable);
if(numdec)
{
integer = val / (10 * numdec);
dec = val % (10 * numdec);
snprintf(str,sizeof str, fmt[numdec], integer, dec, unit);
}
else
{
snprintf(str,sizeof str,"%d %s ", val, unit);
}
if (global_settings.talk_menu)
talk_value(val, talkunit, false); /* speak it */
}
lcd_puts(0,1,str);
status_draw(true);
lcd_update();
changed = false;
button = button_get_w_tmo(HZ/2);
switch( button ) {
case SETTINGS_INC:
case SETTINGS_INC | BUTTON_REPEAT:
(*variable)+=steps;
if(*variable > max )
*variable = max;
changed = true;
break;
case SETTINGS_DEC:
case SETTINGS_DEC | BUTTON_REPEAT:
(*variable)-=steps;
if(*variable < min )
*variable = min;
changed = true;
break;
case SETTINGS_OK:
case SETTINGS_CANCEL:
#ifdef SETTINGS_OK2
case SETTINGS_OK2:
#endif
#ifdef SETTINGS_CANCEL2
case SETTINGS_CANCEL2:
#endif
done = true;
break;
default:
if(default_event_handler(button) == SYS_USB_CONNECTED)
return true;
break;
}
if (changed) {
mpeg_sound_set(setting, *variable);
#if CONFIG_HWCODEC == MAS3507D
if(setting == SOUND_BALANCE)
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
#endif
}
}
lcd_stop_scroll();
return false;
}
static bool volume(void)
{
return set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME);
}
static bool balance(void)
{
return set_sound(str(LANG_BALANCE), &global_settings.balance,
SOUND_BALANCE);
}
static bool bass(void)
{
return set_sound(str(LANG_BASS), &global_settings.bass, SOUND_BASS);
}
static bool treble(void)
{
return set_sound(str(LANG_TREBLE), &global_settings.treble, SOUND_TREBLE);
}
#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
static bool loudness(void)
{
return set_sound(str(LANG_LOUDNESS), &global_settings.loudness,
SOUND_LOUDNESS);
}
static bool mdb_strength(void)
{
return set_sound(str(LANG_MDB_STRENGTH), &global_settings.mdb_strength,
SOUND_MDB_STRENGTH);
}
static bool mdb_harmonics(void)
{
return set_sound(str(LANG_MDB_HARMONICS), &global_settings.mdb_harmonics,
SOUND_MDB_HARMONICS);
}
static bool mdb_center(void)
{
return set_sound(str(LANG_MDB_CENTER), &global_settings.mdb_center,
SOUND_MDB_CENTER);
}
static bool mdb_shape(void)
{
return set_sound(str(LANG_MDB_SHAPE), &global_settings.mdb_shape,
SOUND_MDB_SHAPE);
}
static void set_mdb_enable(bool value)
{
mpeg_sound_set(SOUND_MDB_ENABLE, (int)value);
}
static bool mdb_enable(void)
{
return set_bool_options(str(LANG_MDB_ENABLE),
&global_settings.mdb_enable,
STR(LANG_SET_BOOL_YES),
STR(LANG_SET_BOOL_NO),
set_mdb_enable);
}
static void set_superbass(bool value)
{
mpeg_sound_set(SOUND_SUPERBASS, (int)value);
}
static bool superbass(void)
{
return set_bool_options(str(LANG_SUPERBASS),
&global_settings.superbass,
STR(LANG_SET_BOOL_YES),
STR(LANG_SET_BOOL_NO),
set_superbass);
}
static void set_avc(int val)
{
mpeg_sound_set(SOUND_AVC, val);
}
static bool avc(void)
{
static const struct opt_items names[] = {
{ STR(LANG_OFF) },
{ "20ms", TALK_ID(20, UNIT_MS) },
{ "2s", TALK_ID(2, UNIT_SEC) },
{ "4s", TALK_ID(4, UNIT_SEC) },
{ "8s", TALK_ID(8, UNIT_SEC) }
};
return set_option(str(LANG_DECAY), &global_settings.avc, INT,
names, 5, set_avc);
}
#endif
#ifdef HAVE_RECORDING
static bool recsource(void)
{
static const struct opt_items names[] = {
{ STR(LANG_RECORDING_SRC_MIC) },
{ STR(LANG_RECORDING_SRC_LINE) },
{ STR(LANG_RECORDING_SRC_DIGITAL) }
};
return set_option(str(LANG_RECORDING_SOURCE),
&global_settings.rec_source, INT,
names, 3, NULL );
}
static bool recfrequency(void)
{
static const struct opt_items names[] = {
{ "44.1kHz", TALK_ID(44, UNIT_KHZ) },
{ "48kHz", TALK_ID(48, UNIT_KHZ) },
{ "32kHz", TALK_ID(32, UNIT_KHZ) },
{ "22.05kHz", TALK_ID(22, UNIT_KHZ) },
{ "24kHz", TALK_ID(24, UNIT_KHZ) },
{ "16kHz", TALK_ID(16, UNIT_KHZ) }
};
return set_option(str(LANG_RECORDING_FREQUENCY),
&global_settings.rec_frequency, INT,
names, 6, NULL );
}
static bool recchannels(void)
{
static const struct opt_items names[] = {
{ STR(LANG_CHANNEL_STEREO) },
{ STR(LANG_CHANNEL_MONO) }
};
return set_option(str(LANG_RECORDING_CHANNELS),
&global_settings.rec_channels, INT,
names, 2, NULL );
}
static bool recquality(void)
{
return set_int(str(LANG_RECORDING_QUALITY), "", UNIT_INT,
&global_settings.rec_quality,
NULL, 1, 0, 7 );
}
static bool receditable(void)
{
return set_bool(str(LANG_RECORDING_EDITABLE),
&global_settings.rec_editable);
}
static bool rectimesplit(void)
{
static const struct opt_items names[] = {
{ STR(LANG_OFF) },
{ "00:05" , TALK_ID(5, UNIT_MIN) },
{ "00:10" , TALK_ID(10, UNIT_MIN) },
{ "00:15" , TALK_ID(15, UNIT_MIN) },
{ "00:30" , TALK_ID(30, UNIT_MIN) },
{ "01:00" , TALK_ID(1, UNIT_HOUR) },
{ "01:14" , TALK_ID(74, UNIT_MIN) },
{ "01:20" , TALK_ID(80, UNIT_MIN) },
{ "02:00" , TALK_ID(2, UNIT_HOUR) },
{ "04:00" , TALK_ID(4, UNIT_HOUR) },
{ "06:00" , TALK_ID(6, UNIT_HOUR) },
{ "08:00" , TALK_ID(8, UNIT_HOUR) },
{ "10:00" , TALK_ID(10, UNIT_HOUR) },
{ "12:00" , TALK_ID(12, UNIT_HOUR) },
{ "18:00" , TALK_ID(18, UNIT_HOUR) },
{ "24:00" , TALK_ID(24, UNIT_HOUR) }
};
return set_option(str(LANG_RECORD_TIMESPLIT),
&global_settings.rec_timesplit, INT,
names, 16, NULL );
}
static bool recprerecord(void)
{
static const struct opt_items names[] = {
{ STR(LANG_OFF) },
{ "1s", TALK_ID(1, UNIT_SEC) },
{ "2s", TALK_ID(2, UNIT_SEC) },
{ "3s", TALK_ID(3, UNIT_SEC) },
{ "4s", TALK_ID(4, UNIT_SEC) },
{ "5s", TALK_ID(5, UNIT_SEC) },
{ "6s", TALK_ID(6, UNIT_SEC) },
{ "7s", TALK_ID(7, UNIT_SEC) },
{ "8s", TALK_ID(8, UNIT_SEC) },
{ "9s", TALK_ID(9, UNIT_SEC) },
{ "10s", TALK_ID(10, UNIT_SEC) },
{ "11s", TALK_ID(11, UNIT_SEC) },
{ "12s", TALK_ID(12, UNIT_SEC) },
{ "13s", TALK_ID(13, UNIT_SEC) },
{ "14s", TALK_ID(14, UNIT_SEC) },
{ "15s", TALK_ID(15, UNIT_SEC) },
{ "16s", TALK_ID(16, UNIT_SEC) },
{ "17s", TALK_ID(17, UNIT_SEC) },
{ "18s", TALK_ID(18, UNIT_SEC) },
{ "19s", TALK_ID(19, UNIT_SEC) },
{ "20s", TALK_ID(20, UNIT_SEC) },
{ "21s", TALK_ID(21, UNIT_SEC) },
{ "22s", TALK_ID(22, UNIT_SEC) },
{ "23s", TALK_ID(23, UNIT_SEC) },
{ "24s", TALK_ID(24, UNIT_SEC) },
{ "25s", TALK_ID(25, UNIT_SEC) },
{ "26s", TALK_ID(26, UNIT_SEC) },
{ "27s", TALK_ID(27, UNIT_SEC) },
{ "28s", TALK_ID(28, UNIT_SEC) },
{ "29s", TALK_ID(29, UNIT_SEC) },
{ "30s", TALK_ID(30, UNIT_SEC) }
};
return set_option(str(LANG_RECORD_PRERECORD_TIME),
&global_settings.rec_prerecord_time, INT,
names, 31, NULL );
}
static bool recdirectory(void)
{
static const struct opt_items names[] = {
{ rec_base_directory, -1 },
{ STR(LANG_RECORD_CURRENT_DIR) }
};
return set_option(str(LANG_RECORD_DIRECTORY),
&global_settings.rec_directory, INT,
names, 2, NULL );
}
static bool reconstartup(void)
{
return set_bool(str(LANG_RECORD_STARTUP),
&global_settings.rec_startup);
}
#endif /* MAS3587F */
static void set_chanconf(int val)
{
mpeg_sound_set(SOUND_CHANNELS, val);
}
static bool chanconf(void)
{
static const struct opt_items names[] = {
{ STR(LANG_CHANNEL_STEREO) },
{ STR(LANG_CHANNEL_MONO) },
{ STR(LANG_CHANNEL_CUSTOM) },
{ STR(LANG_CHANNEL_LEFT) },
{ STR(LANG_CHANNEL_RIGHT) },
{ STR(LANG_CHANNEL_KARAOKE) }
};
return set_option(str(LANG_CHANNEL), &global_settings.channel_config, INT,
names, 6, set_chanconf );
}
static bool stereo_width(void)
{
return set_sound(str(LANG_STEREO_WIDTH), &global_settings.stereo_width,
SOUND_STEREO_WIDTH);
}
bool sound_menu(void)
{
int m;
bool result;
static const struct menu_item items[] = {
{ ID2P(LANG_VOLUME), volume },
{ ID2P(LANG_BASS), bass },
{ ID2P(LANG_TREBLE), treble },
{ ID2P(LANG_BALANCE), balance },
{ ID2P(LANG_CHANNEL_MENU), chanconf },
{ ID2P(LANG_STEREO_WIDTH), stereo_width },
#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
{ ID2P(LANG_LOUDNESS), loudness },
{ ID2P(LANG_AUTOVOL), avc },
{ ID2P(LANG_SUPERBASS), superbass },
{ ID2P(LANG_MDB_ENABLE), mdb_enable },
{ ID2P(LANG_MDB_STRENGTH), mdb_strength },
{ ID2P(LANG_MDB_HARMONICS), mdb_harmonics },
{ ID2P(LANG_MDB_CENTER), mdb_center },
{ ID2P(LANG_MDB_SHAPE), mdb_shape },
#endif
};
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
NULL, NULL, NULL);
result = menu_run(m);
menu_exit(m);
return result;
}
#ifdef HAVE_RECORDING
bool recording_menu(bool no_source)
{
int m;
int i = 0;
struct menu_item items[9];
bool result;
items[i].desc = ID2P(LANG_RECORDING_QUALITY);
items[i++].function = recquality;
items[i].desc = ID2P(LANG_RECORDING_FREQUENCY);
items[i++].function = recfrequency;
if(!no_source) {
items[i].desc = ID2P(LANG_RECORDING_SOURCE);
items[i++].function = recsource;
}
items[i].desc = ID2P(LANG_RECORDING_CHANNELS);
items[i++].function = recchannels;
items[i].desc = ID2P(LANG_RECORDING_EDITABLE);
items[i++].function = receditable;
items[i].desc = ID2P(LANG_RECORD_TIMESPLIT);
items[i++].function = rectimesplit;
items[i].desc = ID2P(LANG_RECORD_PRERECORD_TIME);
items[i++].function = recprerecord;
items[i].desc = ID2P(LANG_RECORD_DIRECTORY);
items[i++].function = recdirectory;
items[i].desc = ID2P(LANG_RECORD_STARTUP);
items[i++].function = reconstartup;
m=menu_init( items, i, NULL, NULL, NULL, NULL);
result = menu_run(m);
menu_exit(m);
return result;
}
#endif
|