📄 uilcd.c
字号:
//****************************************************************************//// UILCD.C - Functions for handling the user interface for the player, using a// 128x33 LCD controlled by a Hitachi HD66410 as the display.//// Copyright (c) 1999,2000,2001 Cirrus Logic, Inc.////****************************************************************************#include "globals.h"#include "../hwport.h"#include "../hwdefs.h"#include "time.h"//****************************************************************************//// We only include the remainder of this file if the LCD is used for our user// interface.////****************************************************************************#ifdef UI_IS_LCD//****************************************************************************//// The indices of the registers in the HD66410.////****************************************************************************#define LCD_REG_CONTROL1 0#define LCD_REG_CONTROL2 1#define LCD_REG_X 2#define LCD_REG_Y 3#define LCD_REG_DATA 4#define LCD_REG_START 5#define LCD_REG_BLINK1 6#define LCD_REG_BLINK2 7#define LCD_REG_BLINK_START 8#define LCD_REG_BLINK_END 9#define LCD_REG_ANNUNCIATOR1 16#define LCD_REG_ANNUNCIATOR2 17#define LCD_REG_ANNUNCIATOR3 18#define LCD_REG_ANNUNCIATOR4 19#define LCD_REG_ANNUNCIATOR5 20#define LCD_REG_ANNUNCIATOR6 21#define LCD_REG_ANNUNCIATOR7 22#define LCD_REG_ANNUNCIATOR8 23#define LCD_REG_ANNUNCIATOR9 24#define LCD_REG_ANNUNCIATOR_BLINK1 25#define LCD_REG_ANNUNCIATOR_BLINK2 26#define LCD_REG_ANNUNCIATOR_BLINK3 27//****************************************************************************//// The various bits in the HD66410 control register one.////****************************************************************************#define LCD_CONTROL1_ADC 0x01#define LCD_CONTROL1_CNF 0x02#define LCD_CONTROL1_IDTY 0x04#define LCD_CONTROL1_OSC 0x08#define LCD_CONTROL1_PWR 0x10#define LCD_CONTROL1_STBY 0x20#define LCD_CONTROL1_DISP 0x40//****************************************************************************//// The various bits in the HD66410 control register two.////****************************************************************************#define LCD_CONTROL2_BLK 0x01#define LCD_CONTROL2_INC 0x02#define LCD_CONTROL2_DDTY 0x04#define LCD_CONTROL2_RMW 0x08//****************************************************************************//// The various icons across the top of the LCD panel.////****************************************************************************#define LCD_ANNUNC3_PLAY 0x01#define LCD_ANNUNC3_LEFT_ARROWCIRCLE 0x02#define LCD_ANNUNC3_RIGHT_ARROWCIRCLE 0x04#define LCD_ANNUNC3_SINGLE 0x08#define LCD_ANNUNC3_RANDOM 0x10#define LCD_ANNUNC3_PROGRAM 0x20#define LCD_ANNUNC3_LEFT_SEMICIRCLE 0x40#define LCD_ANNUNC3_ARROWS 0x80#define LCD_ANNUNC4_TAPE 0x02#define LCD_ANNUNC5_BOOK 0x02#define LCD_ANNUNC5_LOCK 0x04#define LCD_ANNUNC5_BATTERY_FILL1 0x08#define LCD_ANNUNC5_BATTERY_FILL2 0x10#define LCD_ANNUNC5_BATTERY 0x20#define LCD_ANNUNC5_BATTERY_FILL3 0x40#define LCD_ANNUNC5_TAPEBOX 0x80#define LCD_ANNUNC6_RIGHT_SEMICIRCLE 0x80//****************************************************************************//// Include the graphics used for the display.////****************************************************************************#include "graphics.h"//****************************************************************************//// Definitions for the various delays in the user interface, specified in// counts of the 50Hz user interface system clock.//// LOGO1_DELAY The amount of time the first logo is displayed.// LOGO2_DELAY The amount of time the second logo is displayed.// POWER_DELAY The amount of time the power button must be// pressed to power down the player.// MENU_EXIT_DELAY The amount of inactivity which will cause the// player to exit menu mode.// RECORD_DELAY The amount of time the record button must be// pressed to start voice recording.// SEEK_DELAY The amount of time the fast forward and rewind// buttons must be pressed to start seeking within the// track when playing or paused or to start skipping// tracks when stopped.// SEEK_ACCEL The amount of time the fast forward and rewind// buttons must be pressed to continue seeking within// the track when the player is playing or paused.// Should be a power of two.// SEEK1_ACCEL The amount of time the fast forward and rewind// buttons must be pressed to start the first notch of// accelerated seeking within the track when the// player is playing or paused.// SEEK2_ACCEL The amount of time the fast forward and rewind// buttons must be pressed to start the second notch// of accelerated seeking within the track when the// player is playing or paused.// SEEK3_ACCEL The amount of time the fast forward and rewind// buttons must be pressed to start the third notch of// accelerated seeking within the track when the// player is playing or paused.// TRACK_ACCEL The amount of time the fast forward and rewind// buttons must be pressed to continue skipping tracks// when the player is stopped. Should be a power of// two.// VOLUME_DELAY The amount of time the volume buttons must be// pressed to start adjusting the volume.// VOLUME_ACCEL The amount of time the volume buttons must be// pressed to continue adjusting the volume. Should// be a power of two.// MENU_DELAY The amount of time the menu arrow buttons must be// pressed to start scrolling in the given direction.// MENU_LR_ACCEL The amount of time the left and right menu arrow// buttons must be pressed to continue scrolling in// the given direction. Should be a power of two.// MENU_UD_ACCEL The amount of time the up and down menu arrow// buttons must be pressed to continue adjusting in// the given direction. Should be a power of two.// BATTERY_DELAY The amount of time between updates of the battery// meter. Should be a power of two.// VISUAL_DELAY The amount of time between updates of the visual// area. Should be a power of two.// SCROLL_DELAY The amount of time between updates of the scrolling// track name. Should be a power of two.//// For values which have a xxx_DELAY and xxx_ACCEL pair, the xxx_DELAY// determines the amount of the time the button must be pressed to start// performing that function, and the xxx_ACCEL determines the amount of time// between iterative operations of that function. For example, after holding// the volume up button for VOLUME_DELAY time, the player will turn up the// volume by one. Then, every VOLUME_ACCEL time after that until the button// is released, the player will turn up the volume by one.////****************************************************************************#define LOGO1_DELAY 100 // 2 seconds#define LOGO2_DELAY 100 // 2 seconds#define POWER_DELAY 75 // 1.5 seconds#define MENU_EXIT_DELAY 250 // 5 seconds#define RECORD_DELAY 50 // 1 second#define SEEK_DELAY 25 // .5 seconds#define SEEK_ACCEL 8 // .16 seconds#define SEEK1_ACCEL 150 // 3 seconds#define SEEK2_ACCEL 300 // 6 seconds#define SEEK3_ACCEL 450 // 9 seconds#define TRACK_ACCEL 8 // .16 seconds#define VOLUME_DELAY 25 // .5 seconds#define VOLUME_ACCEL 4 // .08 seconds#define MENU_DELAY 25 // .5 seconds#define MENU_LR_ACCEL 8 // .16 seconds#define MENU_UD_ACCEL 4 // .08 seconds#define BATTERY_DELAY 512 // 10.24 seconds#define VISUAL_DELAY 4 // .08 seconds#define SCROLL_DELAY 16 // .32 seconds//****************************************************************************//// A set of flags indicating the portions of the display that need updating.////****************************************************************************#define FLAG_UPDATE_STATIC 0x00000001#define FLAG_UPDATE_ICON 0x00000002#define FLAG_UPDATE_TRACK 0x00000004#define FLAG_UPDATE_TIME 0x00000008#define FLAG_UPDATE_VOLUME 0x00000010#define FLAG_UPDATE_MENU 0x00000020#define FLAG_UPDATE_VALUE 0x00000040#define FLAG_UPDATE_VISUAL 0x00000080//****************************************************************************//// The various bit fields in the ulFlags member of the user interface// persistent state.////****************************************************************************#define FLAG_VOLUME_MASK 0x0000001f#define FLAG_BASS_BOOST_MASK 0x000001e0#define FLAG_TREBLE_BOOST_MASK 0x00001e00#define FLAG_UPDATE_SCREEN 0x00002000#define FLAG_WAIT_FOR_ALL_UP 0x00004000#define FLAG_BACKLIGHT_MASK 0x00018000#define FLAG_BACKLIGHT_OFF 0x00000000#define FLAG_BACKLIGHT_5 0x00008000#define FLAG_BACKLIGHT_10 0x00010000#define FLAG_BACKLIGHT_ON 0x00018000#define FLAG_SLEEP_MASK 0x00060000#define FLAG_SLEEP_1 0x00000000#define FLAG_SLEEP_2 0x00020000#define FLAG_SLEEP_3 0x00040000#define FLAG_SLEEP_4 0x00060000#define FLAG_MENU_ITEM_MASK 0x00f80000#define FLAG_BACKLIGHT 0x01000000#define FLAG_UPDATE_TRACK_NAME 0x02000000#define FLAG_VISUAL_MODE_MASK 0x0c000000#define FLAG_VISUAL_MODE_NONE 0x00000000#define FLAG_VISUAL_MODE_WAVEFORM 0x04000000#define FLAG_VISUAL_MODE_SPECTRUM 0x08000000#define FLAG_EFFECT_MASK 0x30000000#define FLAG_DISPLAY_STATE_MASK 0xc0000000#define FLAG_DISPLAY_STATE_LOGO1 0x00000000#define FLAG_DISPLAY_STATE_LOGO2 0x40000000#define FLAG_DISPLAY_STATE_MAIN 0x80000000#define FLAG_DISPLAY_STATE_MENU 0xc0000000#define FLAG_VOLUME_SHIFT 0#define FLAG_BASS_BOOST_SHIFT 5#define FLAG_TREBLE_BOOST_SHIFT 9#define FLAG_BACKLIGHT_SHIFT 15#define FLAG_SLEEP_SHIFT 17#define FLAG_MENU_ITEM_SHIFT 19#define FLAG_VISUAL_MODE_SHIFT 26#define FLAG_EFFECT_SHIFT 28//****************************************************************************//// The various bit fields in the ulSRSState member of the user interface// persistent state.////****************************************************************************#define FLAG_SRS_WIDTH_MASK 0x0000001f#define FLAG_SRS_TRU_BASS_MASK 0x000003e0#define FLAG_SRS_WIDTH_SHIFT 0#define FLAG_SRS_TRU_BASS_SHIFT 5//****************************************************************************//// The various bit fields in the ulQSoundState member of the user interface// persistent state.////****************************************************************************#define FLAG_QSOUND_WIDTH_MASK 0x0000001f#define FLAG_QSOUND_MODE_MASK 0x00000020#define FLAG_QSOUND_WIDTH_SHIFT 0#define FLAG_QSOUND_MODE_SHIFT 5//****************************************************************************//// The various bit fields in the ulSpatializerState member of the user// interface persistent state.////****************************************************************************#define FLAG_SPATIALIZER_BASS_MASK 0x0000001f#define FLAG_SPATIALIZER_VBASS_MASK 0x000003e0#define FLAG_SPATIALIZER_GAIN_MASK 0x00007c00#define FLAG_SPATIALIZER_BASS_SHIFT 0#define FLAG_SPATIALIZER_VBASS_SHIFT 5#define FLAG_SPATIALIZER_GAIN_SHIFT 10//****************************************************************************//// The flags in the current player mode which indicate if we are seeking// forward or backward.////****************************************************************************#define FLAG_SEEK_FORWARD 0x20#define FLAG_SEEK_BACKWARD 0x40//****************************************************************************//// The persistent state of the user interface code.////****************************************************************************static struct{ // // Various flags indicating the current state of the user interface. // unsigned long ulFlags; // // The most recent value written to the LCD. // unsigned short usLCDValue; // // The count of the number of clock ticks that have occurred. This is our // time base for the various time-based elements of the user interface // (such as automatically powering down the player after 30 seconds of // inactivity). // unsigned short usTickCount; // // The time at which the next time delayed action is to occur. This is // used to advance between the various logos displayed at startup, to // automatically exit from the menu, and to automatically power down the // player. // unsigned short usTargetTime; // // The time at which the backlight should be turned off. // unsigned short usBacklightTime; // // The value of usTickCount when each of the buttons was pressed. These // values only have a real meaning when the corresponding bit in ucState // is set. // unsigned short usPressTime[8]; // // The current set of virtual buttons that are pressed. This is returned // to the player to control the playback of audio. // unsigned long ulKeys; // // The current de-bounced state of the buttons. // unsigned char ucState; // // A two-cycle clock used to de-bounce the buttons. // unsigned char ucClock; // // The current mode of the player. // unsigned char ucMode; // // An unused byte to pad the next member to a word boundary. // unsigned char ucUnused1; // // The current position within the current file in seconds. // unsigned long ulCurrentTime; // // The string representing the file currently opened. // unsigned short pusName[80]; // // The length of the track name string. // unsigned char ucNameLength; // // The current offset into the track name string that is being displayed. // unsigned char ucNameOffset; // // The amount of time that we pause the display before scrolling starts. // unsigned char ucNamePause; // // An unused byte to pad the next member to a word boundary. // unsigned char ucUnused2;#ifdef SUPPORT_SRS // // The current settings of the SRS control. // unsigned long ulSRSState;#endif#ifdef SUPPORT_QSOUND // // The current settings of the QSound control. // unsigned long ulQSoundState;#endif#ifdef SUPPORT_SPATIALIZER // // The current settings of the Spatializer control.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -