📄 settings.c
字号:
config_block[0x1b] = (unsigned char) (((global_settings.browse_current & 1)) | ((global_settings.play_selected & 1) << 1) | ((global_settings.recursive_dir_insert & 3) << 2)); config_block[0x1c] = (unsigned char)global_settings.peak_meter_hold | (global_settings.flip_display ? 0x40 : 0) | (global_settings.rec_editable?0x80:0); memcpy(&config_block[0x1d], &global_settings.resume_seed, 4); config_block[0x21] = (unsigned char) ((global_settings.repeat_mode & 3) | ((global_settings.rec_channels & 1) << 2) | ((global_settings.rec_mic_gain & 0x0f) << 4)); config_block[0x22] = (unsigned char) ((global_settings.rec_quality & 7) | ((global_settings.rec_source & 3) << 3) | ((global_settings.rec_frequency & 7) << 5)); config_block[0x23] = (unsigned char)global_settings.rec_left_gain; config_block[0x24] = (unsigned char)global_settings.rec_right_gain; config_block[0x25] = (unsigned char) ((global_settings.disk_poweroff & 1) | ((global_settings.buffer_margin & 7) << 1) | ((global_settings.trickle_charge & 1) << 4)); { int elapsed_secs; elapsed_secs = (current_tick - lasttime) / HZ; global_settings.runtime += elapsed_secs; lasttime += (elapsed_secs * HZ); if ( global_settings.runtime > global_settings.topruntime ) global_settings.topruntime = global_settings.runtime; config_block[0x26]=(unsigned char)(global_settings.runtime & 0xff); config_block[0x27]=(unsigned char)(global_settings.runtime >> 8); config_block[0x28]=(unsigned char)(global_settings.topruntime & 0xff); config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8); } #ifdef HAVE_LCD_CHARCELLS config_block[0xa8]=(unsigned char)global_settings.jump_scroll; config_block[0xa9]=(unsigned char)global_settings.jump_scroll_delay;#endif config_block[0xaa] = (unsigned char) global_settings.max_files_in_playlist & 0xff; config_block[0xab] = (unsigned char) (global_settings.max_files_in_playlist >> 8) & 0xff; config_block[0xac] = (unsigned char) global_settings.max_files_in_dir & 0xff; config_block[0xad] = (unsigned char) (global_settings.max_files_in_dir >> 8) & 0xff; config_block[0xae] = (unsigned char) ((global_settings.fade_on_stop & 1) | ((global_settings.caption_backlight & 1) << 1) | ((global_settings.car_adapter_mode & 1) << 2) | ((global_settings.line_in & 1) << 3) | ((global_settings.playlist_viewer_icons & 1) << 4) | ((global_settings.playlist_viewer_indices & 1) << 5) | ((global_settings.playlist_viewer_track_display & 1) << 6)); config_block[0xaf] = ((global_settings.usemrb << 5) | (global_settings.autocreatebookmark << 2) | (global_settings.autoloadbookmark)); config_block[0xb0] = (unsigned char)global_settings.peak_meter_clip_hold | (global_settings.peak_meter_performance ? 0x80 : 0); config_block[0xb1] = global_settings.peak_meter_release | (global_settings.peak_meter_dbfs ? 0x80 : 0); config_block[0xb2] = (unsigned char)global_settings.peak_meter_min; config_block[0xb3] = (unsigned char)global_settings.peak_meter_max; config_block[0xb4]=(global_settings.battery_capacity - 1000) / 50; config_block[0xb5]=(unsigned char)global_settings.scroll_step; config_block[0xb6]=(unsigned char)global_settings.scroll_delay; config_block[0xb7]=(unsigned char)global_settings.bidir_limit; strncpy(&config_block[0xb8], global_settings.wps_file, MAX_FILENAME); strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME); strncpy(&config_block[0xe0], global_settings.font_file, MAX_FILENAME); config_block[0xf4]=((unsigned char)global_settings.rec_prerecord_time | ((unsigned char)global_settings.rec_directory << 5)); if(save_config_buffer()) { lcd_clear_display();#ifdef HAVE_LCD_CHARCELLS lcd_puts(0, 0, str(LANG_SETTINGS_SAVE_PLAYER)); lcd_puts(0, 1, str(LANG_SETTINGS_BATTERY_PLAYER));#else lcd_puts(4, 2, str(LANG_SETTINGS_SAVE_RECORDER)); lcd_puts(2, 4, str(LANG_SETTINGS_BATTERY_RECORDER)); lcd_update();#endif sleep(HZ*2); return -1; } return 0;}#ifdef HAVE_LCD_BITMAP/** * Applies the range infos stored in global_settings to * the peak meter. */void settings_apply_pm_range(void){ int pm_min, pm_max; /* depending on the scale mode (dBfs or percent) the values of global_settings.peak_meter_dbfs have different meanings */ if (global_settings.peak_meter_dbfs) { /* convert to dBfs * 100 */ pm_min = -(((int)global_settings.peak_meter_min) * 100); pm_max = -(((int)global_settings.peak_meter_max) * 100); } else { /* percent is stored directly -> no conversion */ pm_min = global_settings.peak_meter_min; pm_max = global_settings.peak_meter_max; } /* apply the range */ peak_meter_init_range(global_settings.peak_meter_dbfs, pm_min, pm_max);}#endif /* HAVE_LCD_BITMAP */void settings_apply(void){ char buf[64]; mpeg_sound_set(SOUND_BASS, global_settings.bass); mpeg_sound_set(SOUND_TREBLE, global_settings.treble); mpeg_sound_set(SOUND_BALANCE, global_settings.balance); mpeg_sound_set(SOUND_VOLUME, global_settings.volume); mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config);#ifdef HAVE_MAS3587F mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness); mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost); mpeg_sound_set(SOUND_AVC, global_settings.avc);#endif mpeg_set_buffer_margin(global_settings.buffer_margin); lcd_set_contrast(global_settings.contrast); lcd_scroll_speed(global_settings.scroll_speed); backlight_set_timeout(global_settings.backlight_timeout); backlight_set_on_when_charging(global_settings.backlight_on_when_charging); ata_spindown(global_settings.disk_spindown);#ifdef HAVE_MAS3507D dac_line_in(global_settings.line_in);#endif#ifdef HAVE_ATA_POWER_OFF ata_poweroff(global_settings.disk_poweroff);#endif set_poweroff_timeout(global_settings.poweroff);#ifdef HAVE_CHARGE_CTRL charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI; enable_trickle_charge(global_settings.trickle_charge);#endif set_battery_capacity(global_settings.battery_capacity);#ifdef HAVE_LCD_BITMAP lcd_set_invert_display(global_settings.invert); lcd_set_flip(global_settings.flip_display); button_set_flip(global_settings.flip_display); lcd_update(); /* refresh after flipping the screen */ settings_apply_pm_range(); peak_meter_init_times( global_settings.peak_meter_release, global_settings.peak_meter_hold, global_settings.peak_meter_clip_hold);#endif if ( global_settings.wps_file[0] && global_settings.wps_file[0] != 0xff ) { snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.wps", global_settings.wps_file); wps_load(buf, false); } else wps_reset();#ifdef HAVE_LCD_BITMAP if ( global_settings.font_file[0] && global_settings.font_file[0] != 0xff ) { snprintf(buf, sizeof buf, ROCKBOX_DIR FONT_DIR "/%s.fnt", global_settings.font_file); font_load(buf); } else font_reset(); lcd_scroll_step(global_settings.scroll_step);#else lcd_jump_scroll(global_settings.jump_scroll); lcd_jump_scroll_delay(global_settings.jump_scroll_delay * (HZ/10));#endif lcd_bidir_scroll(global_settings.bidir_limit); lcd_scroll_delay(global_settings.scroll_delay * (HZ/10)); if ( global_settings.lang_file[0] && global_settings.lang_file[0] != 0xff ) { snprintf(buf, sizeof buf, ROCKBOX_DIR LANG_DIR "/%s.lng", global_settings.lang_file); lang_load(buf); } set_car_adapter_mode(global_settings.car_adapter_mode);}/* * load settings from disk or RTC RAM */void settings_load(void){ DEBUGF( "reload_all_settings()\n" ); /* populate settings with default values */ settings_reset(); /* load the buffer from the RTC (resets it to all-unused if the block is invalid) and decode the settings which are set in the block */ if (!load_config_buffer()) { if (config_block[0x4] != 0xFF) global_settings.volume = config_block[0x4]; if (config_block[0x5] != 0xFF) global_settings.balance = (char)config_block[0x5]; if (config_block[0x6] != 0xFF) global_settings.bass = config_block[0x6]; if (config_block[0x7] != 0xFF) global_settings.treble = config_block[0x7]; if (config_block[0x8] != 0xFF) global_settings.loudness = config_block[0x8]; if (config_block[0x9] != 0xFF) global_settings.bass_boost = config_block[0x9]; if (config_block[0xa] != 0xFF) { global_settings.contrast = config_block[0xa] & 0x3f; global_settings.invert = config_block[0xa] & 0x40 ? true : false; if ( global_settings.contrast < MIN_CONTRAST_SETTING ) global_settings.contrast = lcd_default_contrast(); global_settings.show_icons = config_block[0xa] & 0x80 ? true : false; } if (config_block[0xb] != 0xFF) { /* Bit 7 is unused to be able to detect uninitialized entry */ global_settings.backlight_timeout = config_block[0xb] & 0x1f; global_settings.invert_cursor = config_block[0xb] & 0x20 ? true : false; global_settings.backlight_on_when_charging = config_block[0xb] & 0x40 ? true : false; } if (config_block[0xc] != 0xFF) global_settings.poweroff = config_block[0xc]; if (config_block[0xd] != 0xFF) global_settings.resume = config_block[0xd]; if (config_block[0xe] != 0xFF) { global_settings.playlist_shuffle = config_block[0xe] & 1; global_settings.dirfilter = (config_block[0xe] >> 1) & 1; global_settings.sort_case = (config_block[0xe] >> 2) & 1; global_settings.discharge = (config_block[0xe] >> 3) & 1; global_settings.statusbar = (config_block[0xe] >> 4) & 1; global_settings.dirfilter |= ((config_block[0xe] >> 5) & 1) << 1; global_settings.scrollbar = (config_block[0xe] >> 6) & 1; /* Don't use the last bit, it must be unused to detect an uninitialized entry */ } if (config_block[0xf] != 0xFF) { global_settings.volume_type = config_block[0xf] & 1; global_settings.battery_type = (config_block[0xf] >> 1) & 1; global_settings.timeformat = (config_block[0xf] >> 2) & 1; global_settings.scroll_speed = config_block[0xf] >> 3; } if (config_block[0x10] != 0xFF) { global_settings.ff_rewind_min_step = (config_block[0x10] >> 4) & 15; global_settings.ff_rewind_accel = config_block[0x10] & 15; } if (config_block[0x11] != 0xFF) { global_settings.avc = config_block[0x11] & 0x03; global_settings.channel_config = (config_block[0x11] >> 2) & 0x07; } if (config_block[0x12] != 0xFF) global_settings.resume_index = *((short*)(&config_block[0x12])); if (config_block[0x14] != 0xFF) global_settings.resume_first_index= *((short*)(&config_block[0x14])); if (config_block[0x16] != 0xFF) memcpy(&global_settings.resume_offset, &config_block[0x16], 4); if (config_block[0x1a] != 0xFF) global_settings.disk_spindown = config_block[0x1a]; if (config_block[0x1b] != 0xFF) { global_settings.browse_current = (config_block[0x1b]) & 1; global_settings.play_selected = (config_block[0x1b] >> 1) & 1; global_settings.recursive_dir_insert = (config_block[0x1b] >> 2) & 3; } if (config_block[0x1c] != 0xFF) { global_settings.peak_meter_hold = (config_block[0x1c]) & 0x1f; global_settings.flip_display = (config_block[0x1c] & 0x40)?true:false; global_settings.rec_editable = (config_block[0x1c] & 0x80)?true:false; } if (config_block[0x1d] != 0xFF) memcpy(&global_settings.resume_seed, &config_block[0x1d], 4); if (config_block[0x21] != 0xFF) { global_settings.repeat_mode = config_block[0x21] & 3; global_settings.rec_channels = (config_block[0x21] >> 2) & 1; global_settings.rec_mic_gain = (config_block[0x21] >> 4) & 0x0f; } if (config_block[0x22] != 0xFF) { global_settings.rec_quality = config_block[0x22] & 7; global_settings.rec_source = (config_block[0x22] >> 3) & 3; global_settings.rec_frequency = (config_block[0x22] >> 5) & 7; } if (config_block[0x23] != 0xFF) global_settings.rec_left_gain = config_block[0x23] & 0x0f; if (config_block[0x24] != 0xFF) global_settings.rec_right_gain = config_block[0x24] & 0x0f; if (config_block[0x25] != 0xFF) { global_settings.disk_poweroff = config_block[0x25] & 1; global_settings.buffer_margin = (config_block[0x25] >> 1) & 7; global_settings.trickle_charge = (config_block[0x25] >> 4) & 1; } if (config_block[0x27] != 0xff) global_settings.runtime = config_block[0x26] | (config_block[0x27] << 8); if (config_block[0x29] != 0xff) global_settings.topruntime = config_block[0x28] | (config_block[0x29] << 8); if (config_block[0xae] != 0xff) { global_settings.fade_on_stop = config_block[0xae] & 1; global_settings.caption_backlight = (config_block[0xae] >> 1) & 1; global_settings.car_adapter_mode = (config_block[0xae] >> 2) & 1; global_settings.line_in = (config_block[0xae] >> 3) & 1; global_settings.playlist_viewer_icons = (config_block[0xae] >> 4) & 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -