⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 settings_menu.c

📁 编译后直接运行的MP3播放器全部C语言源代码 一个包含FAT文件系统、系统引导 Boot、FLASH Driver等内容的
💻 C
📖 第 1 页 / 共 3 页
字号:
/*************************************************************************** *             __________               __   ___. *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  / *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  < *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \ *                     \/            \/     \/    \/            \/ * $Id: settings_menu.c,v 1.130 2004/01/26 17:05:21 hardeeps Exp $ * * Copyright (C) 2002 Robert Hak * * 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 "lcd.h"#include "menu.h"#include "mpeg.h"#include "button.h"#include "kernel.h"#include "thread.h"#include "sprintf.h"#include "settings.h"#include "settings_menu.h"#include "backlight.h"#include "playlist.h"           /* for playlist_shuffle */#include "fat.h"                /* For dotfile settings */#include "sleeptimer.h"#include "powermgmt.h"#include "rtc.h"#include "ata.h"#include "tree.h"#include "screens.h"#ifdef HAVE_LCD_BITMAP#include "peakmeter.h"#endif#include "lang.h"#ifdef HAVE_MAS3507Dvoid dac_line_in(bool enable);#endif#ifdef HAVE_ALARM_MOD#include "alarm_menu.h"#endifstatic bool car_adapter_mode(void){    return set_bool_options( str(LANG_CAR_ADAPTER_MODE),                             &global_settings.car_adapter_mode,                             str(LANG_SET_BOOL_YES),                             str(LANG_SET_BOOL_NO),                             set_car_adapter_mode);}static bool contrast(void){    return set_int( str(LANG_CONTRAST), "", &global_settings.contrast,                     lcd_set_contrast, 1, MIN_CONTRAST_SETTING,                    MAX_CONTRAST_SETTING );}static bool caption_backlight(void){    bool rc = set_bool( str(LANG_CAPTION_BACKLIGHT),                        &global_settings.caption_backlight);    return rc;}/** * Menu to set icon visibility */static bool show_icons(void){    return set_bool( str(LANG_SHOW_ICONS), &global_settings.show_icons );}#ifdef HAVE_LCD_BITMAP /** * Menu to set LCD Mode (normal/inverse) */static bool invert(void){     bool rc = set_bool_options(str(LANG_INVERT),                                &global_settings.invert,                                str(LANG_INVERT_LCD_INVERSE),                                str(LANG_INVERT_LCD_NORMAL),                                lcd_set_invert_display);     return rc;}/** * Menu to set Line Selector Type (Pointer/Bar) */static bool invert_cursor(void){        return set_bool_options(str(LANG_INVERT_CURSOR),                            &global_settings.invert_cursor,                            str(LANG_INVERT_CURSOR_BAR),                            str(LANG_INVERT_CURSOR_POINTER),                            NULL);}/** * Menu to turn the display+buttons by 180 degrees */static bool flip_display(void){    bool rc = set_bool( str(LANG_FLIP_DISPLAY),                        &global_settings.flip_display);        button_set_flip(global_settings.flip_display);    lcd_set_flip(global_settings.flip_display);    return rc;}/** * Menu to configure the battery display on status bar */static bool battery_type(void){    char* names[] = { str(LANG_DISPLAY_GRAPHIC),                       str(LANG_DISPLAY_NUMERIC)  };    return set_option( str(LANG_BATTERY_DISPLAY),                        &global_settings.battery_type, INT, names, 2, NULL);}/** * Menu to configure the volume display on status bar */static bool volume_type(void){    char* names[] = { str(LANG_DISPLAY_GRAPHIC),                       str(LANG_DISPLAY_NUMERIC) };    return set_option( str(LANG_VOLUME_DISPLAY), &global_settings.volume_type,                       INT, names, 2, NULL);}#ifdef PM_DEBUGstatic bool peak_meter_fps_menu(void) {    bool retval = false;    retval = set_int( "Refresh rate", "/s",              &peak_meter_fps,             NULL, 1, 5, 40);    return retval;}#endif /* PM_DEBUG *//** * Menu to set the hold time of normal peaks. */static bool peak_meter_hold(void) {    bool retval = false;    char* names[] = { str(LANG_OFF),                      "200 ms ", "300 ms ", "500 ms ", "1 s ", "2 s ",                      "3 s ", "4 s ", "5 s ", "6 s ", "7 s",                      "8 s", "9 s", "10 s", "15 s", "20 s",                      "30 s", "1 min"    };    retval = set_option( str(LANG_PM_PEAK_HOLD),                         &global_settings.peak_meter_hold, INT, names,                         18, NULL);    peak_meter_init_times(global_settings.peak_meter_release,        global_settings.peak_meter_hold,         global_settings.peak_meter_clip_hold);    return retval;}/** * Menu to set the hold time of clips. */static bool peak_meter_clip_hold(void) {    bool retval = false;    char* names[] = { str(LANG_PM_ETERNAL),                      "1s ", "2s ", "3s ", "4s ", "5s ",                      "6s ", "7s ", "8s ", "9s ", "10s",                      "15s", "20s", "25s", "30s", "45s",                      "60s", "90s", "2min", "3min", "5min",                      "10min", "20min", "45min", "90min"    };    retval = set_option( str(LANG_PM_CLIP_HOLD),                          &global_settings.peak_meter_clip_hold, INT, names,                         25, peak_meter_set_clip_hold);    peak_meter_init_times(global_settings.peak_meter_release,        global_settings.peak_meter_hold,         global_settings.peak_meter_clip_hold);    return retval;}/** * Menu to set the release time of the peak meter. */static bool peak_meter_release(void)  {    bool retval = false;    /* The range of peak_meter_release is restricted so that it       fits into a 7 bit number. The 8th bit is used for storing       something else in the rtc ram.       Also, the max value is 0x7e, since the RTC value 0xff is reserved */    retval = set_int( str(LANG_PM_RELEASE), str(LANG_PM_UNITS_PER_READ),                     &global_settings.peak_meter_release,             NULL, 1, 1, 0x7e);    peak_meter_init_times(global_settings.peak_meter_release,        global_settings.peak_meter_hold,         global_settings.peak_meter_clip_hold);    return retval;}/** * Menu to select wether the scale of the meter  * displays dBfs of linear values. */static bool peak_meter_scale(void) {    bool retval = false;    bool use_dbfs = global_settings.peak_meter_dbfs;    retval = set_bool_options(str(LANG_PM_SCALE),         &use_dbfs,         str(LANG_PM_DBFS), str(LANG_PM_LINEAR),        NULL);    /* has the user really changed the scale? */    if (use_dbfs != global_settings.peak_meter_dbfs) {        /* store the change */        global_settings.peak_meter_dbfs = use_dbfs;        peak_meter_set_use_dbfs(use_dbfs);        /* If the user changed the scale mode the meaning of           peak_meter_min (peak_meter_max) has changed. Thus we have           to convert the values stored in global_settings. */        if (use_dbfs) {            /* we only store -dBfs */            global_settings.peak_meter_min = -peak_meter_get_min() / 100;            global_settings.peak_meter_max = -peak_meter_get_max() / 100;        } else {            int max;                        /* linear percent */            global_settings.peak_meter_min = peak_meter_get_min();            /* converting dBfs -> percent results in a precision loss.               I assume that the user doesn't bother that conversion               dBfs <-> percent isn't symmetrical for odd values but that               he wants 0 dBfs == 100%. Thus I 'correct' the percent value               resulting from dBfs -> percent manually here */            max = peak_meter_get_max();            global_settings.peak_meter_max = max < 99 ? max : 100;        }        settings_apply_pm_range();    }    return retval;}/** * Adjust the min value of the value range that * the peak meter shall visualize. */static bool peak_meter_min(void) {    bool retval = false;    if (global_settings.peak_meter_dbfs) {        /* for dBfs scale */        int range_max = -global_settings.peak_meter_max;        int min = -global_settings.peak_meter_min;        retval =  set_int(str(LANG_PM_MIN), str(LANG_PM_DBFS),            &min, NULL, 1, -89, range_max);        global_settings.peak_meter_min = - min;    }     /* for linear scale */    else {        int min = global_settings.peak_meter_min;        retval =  set_int(str(LANG_PM_MIN), "%",            &min, NULL,             1, 0, global_settings.peak_meter_max - 1);        global_settings.peak_meter_min = (unsigned char)min;    }    settings_apply_pm_range();    return retval;}/** * Adjust the max value of the value range that * the peak meter shall visualize. */static bool peak_meter_max(void) {    bool retval = false;    if (global_settings.peak_meter_dbfs) {        /* for dBfs scale */        int range_min = -global_settings.peak_meter_min;        int max = -global_settings.peak_meter_max;;        retval =  set_int(str(LANG_PM_MAX), str(LANG_PM_DBFS),            &max, NULL, 1, range_min, 0);        global_settings.peak_meter_max = - max;    }         /* for linear scale */    else {        int max = global_settings.peak_meter_max;        retval =  set_int(str(LANG_PM_MAX), "%",            &max, NULL,             1, global_settings.peak_meter_min + 1, 100);        global_settings.peak_meter_max = (unsigned char)max;    }    settings_apply_pm_range();    return retval;}/** * Menu to select wether the meter is in * precision or in energy saver mode */static bool peak_meter_performance(void) {    bool retval = false;    retval = set_bool_options(str(LANG_PM_PERFORMANCE),         &global_settings.peak_meter_performance,         str(LANG_PM_HIGH_PERFORMANCE), str(LANG_PM_ENERGY_SAVER),        NULL);    if (global_settings.peak_meter_performance) {        peak_meter_fps = 25;    } else {        peak_meter_fps = 20;    }    return retval;}/** * Menu to configure the peak meter */static bool peak_meter_menu(void) {    int m;    bool result;    struct menu_items items[] = {        { str(LANG_PM_RELEASE)  , peak_meter_release   },          { str(LANG_PM_PEAK_HOLD), peak_meter_hold      },          { str(LANG_PM_CLIP_HOLD), peak_meter_clip_hold },        { str(LANG_PM_PERFORMANCE), peak_meter_performance },#ifdef PM_DEBUG        { "Refresh rate"        , peak_meter_fps_menu  },#endif        { str(LANG_PM_SCALE)    , peak_meter_scale     },        { str(LANG_PM_MIN)      , peak_meter_min       },        { str(LANG_PM_MAX)      , peak_meter_max       },    };        m=menu_init( items, sizeof(items) / sizeof(*items) );    result = menu_run(m);    menu_exit(m);    return result;}#endif /* HAVE_LCD_BITMAP */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -