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

📄 uiser.c

📁 基于EP7312的MP3播放器源代码,包括MCU和PC端代码.
💻 C
📖 第 1 页 / 共 4 页
字号:
//****************************************************************************static voidSerialSendString(char *pcString){    //    // Send the string character by character.    //    while(*pcString)    {        SerialSendChar(*pcString++);    }}//****************************************************************************//// Waits until the serial port is done transmitting all data from it's// transmit FIFO.////****************************************************************************static voidSerialWaitForTransmit(void){    volatile unsigned long *pulPtr = (unsigned long *)HwBaseAddress;    //    // Wait until the serial port transmit is not busy.    //    while(pulPtr[HwStatus >> 2] & HwStatusUartTxBusy)    {    }}//****************************************************************************//// Displays the current value of a string ring on the serial port.////****************************************************************************static unsigned longDisplayStringRing(unsigned long ulIndex){    char *pcValue;    unsigned long ulIdx;    //    // Get a pointer to the string ring values.    //    pcValue = sMenuItems[ulIndex].pcValues;    //    // Get the current value of this menu item.    //    ulIdx = (*(sMenuItems[ulIndex].pulFlags) &             sMenuItems[ulIndex].ulFlagMask) >>            sMenuItems[ulIndex].ulFlagShift;    //    // Skip strings in the string ring until we've reached the current value    // of this menu item.    //    while(ulIdx--)    {        //        // Skip to the end of this string.        //        while(*pcValue)        {            pcValue++;        }        //        // Skip past the trailing NULL character to get to the beginning of the        // next string in the ring.        //        pcValue++;    }    //    // Display the current value of the string ring, preceeded by a space.    //    SerialSendChar(' ');    for(ulIdx = 0; ulIdx < 16; ulIdx++)    {        if(pcValue[ulIdx])        {            SerialSendChar(pcValue[ulIdx]);        }        else        {            break;        }    }    //    // Return the number of characters displayed.    //    return(ulIdx + 1);}//****************************************************************************//// Displays the current value of a menu item on the serial port.////****************************************************************************static unsigned longDisplayValue(unsigned long ulIndex){    int iValue;    //    // Get the current value of the slider.    //    iValue = (*(sMenuItems[ulIndex].pulFlags) &              sMenuItems[ulIndex].ulFlagMask) >>             sMenuItems[ulIndex].ulFlagShift;    //    // Display the current value, preceeded by a space.    //    SerialSendChar(' ');    if(iValue > 9)    {        SerialSendChar('0' + (iValue / 10));    }    else    {        SerialSendChar(' ');    }    SerialSendChar('0' + (iValue % 10));    //    // We displayed three characters.    //    return(3);}//****************************************************************************//// Displays a list of the available codecs within the main body of the menu// item display.////****************************************************************************static unsigned longDisplayCodecs(unsigned long ulIndex){    const unsigned short *pusName;    char cMsg[40];    int i, j;    //    // Loop through up to eight codecs.    //    for(i = 0, j = 0; i < 8; i++)    {        //        // Get the name of this codec.  If we can not get it's name, then we've        // gone through all the available codecs and should stop looking.        //        if(CodecGetNameByIndex(i, &pusName) == 0)        {            break;        }        //        // Copy the short name of this codec to the message buffer.        //        cMsg[j++] = pusName[0];        cMsg[j++] = pusName[1];        cMsg[j++] = pusName[2];        cMsg[j++] = pusName[3];        //        // Remove any trailing spaces from the short name of the codec.        //        while(cMsg[j - 1] == ' ')        {            j--;        }        //        // Add a comma to separate this codec from the next.        //        cMsg[j++] = ',';    }    //    // Replace the last comma with a NULL to terminate the string.    //    cMsg[j - 1] = '\0';    //    // Display the list of codec names.    //    for(i = 0; i < 16; i++)    {        if(cMsg[i])        {            SerialSendChar(cMsg[i]);        }        else        {            break;        }    }    //    // Return the number of characters displayed.    //    return(i);}//****************************************************************************//// UIInit initializes the user interface.////****************************************************************************voidUIInit(void){    //    // Initialize the serial port.    //    SerialInit();    //    // If we contain one of the audio processing libraries, then inform the    // user of that fact now.    //#ifdef SUPPORT_SRS#ifdef SUPPORT_WOW_FULL    SerialSendString("\r\nSRS WOW\r\n");#endif#ifdef SUPPORT_WOW_MINIMAL    SerialSendString("\r\nSRS WOW Minimal\r\n");#endif#ifdef SUPPORT_TRU_BASS    SerialSendString("\r\nSRS TruBass\r\n");#endif#ifdef SUPPORT_SRS_HEADPHONE    SerialSendString("\r\nSRS Headphone\r\n");#endif#endif#ifdef SUPPORT_QSOUND    SerialSendString("\r\nQSound Q2X\r\n");#endif#ifdef SUPPORT_SPATIALIZER    SerialSendString("\r\nSpatializer\r\n");#endif    //    // Initialize the user interface flags.  Set the volume to mid-scale and    // turn off the treble and bass boost.    //    sUI.ulFlags = (15 << FLAG_VOLUME_SHIFT) | FLAG_UPDATE_MENU | FLAG_SLEEP_4;    //    // Initialize the Spatializer flags.    //#ifdef SUPPORT_SPATIALIZER    sUI.ulSpatializerState = ((unsigned long)20 <<                              FLAG_SPATIALIZER_GAIN_SHIFT);    OutputSetSpatializerGain(20);#endif    //    // Initialize the tick count to zero.    //    sUI.usTickCount = 0;    //    // Initialize the state of the button debouncer.  All buttons start in the    // not pressed state.    //    sUI.ulKeys = 0;    sUI.ucState = 0;    sUI.ucClock = 0;    //    // Initialize the volume.    //    OutputSetVolume(15);    //    // Initialize the treble and bass boost.    //    OutputSetTone(0, 0, -6);}//****************************************************************************//// UIPrintTime displays the specified time (given in milliseconds).////****************************************************************************static voidUIPrintTime(unsigned long ulMS){    unsigned long ulMinutes;    //    // Compute the number of minutes and seconds.    //    ulMS /= 1000;    ulMinutes = ulMS / 60;    ulMS -= ulMinutes * 60;    //    // If there are more than 59 minutes and 59 seconds in the time, then    // convert the time to hours and minutes.    //    if(ulMinutes >= 60)    {        ulMS = ulMinutes % 60;        ulMinutes /= 60;    }    //    // Send the time in MM:SS format to the serial port.    //    if(ulMinutes >= 10)    {        SerialSendChar('0' + ((ulMinutes / 10) % 10));    }    else    {        SerialSendChar(' ');    }    SerialSendChar('0' + (ulMinutes % 10));    SerialSendChar(':');    SerialSendChar('0' + ((ulMS / 10) % 10));    SerialSendChar('0' + (ulMS % 10));}//****************************************************************************//// UIPrintBitRate displays the specified bitrate.////****************************************************************************static voidUIPrintBitRate(unsigned long ulBitRate){    //    // Convert the bitrate to kbps.    //    ulBitRate = (ulBitRate + 500) / 1000;    //    // Send the bitrate in XXX format to the serial port.    //    if(ulBitRate >= 100)    {        SerialSendChar('0' + ((ulBitRate / 100) % 10));    }    else    {        SerialSendChar(' ');    }    SerialSendChar('0' + ((ulBitRate / 10) % 10));    SerialSendChar('0' + (ulBitRate % 10));}//****************************************************************************//// UIUpdateDisplay redraws the "display" on the serial port based on the// current mode of the player.////****************************************************************************static voidUIUpdateDisplay(void){    //    // Figure out what to display based on the current mode.    //    switch(sUI.ucMode)    {        //        // We are going into low power mode.        //        case MODE_POWER_OFF:        {            //            // Clear the user display.            //            SerialSendString("                                        ");            SerialSendString("\r                      ");            //            // Wait until the serial port transmit FIFO is empty.            //            SerialWaitForTransmit();            //            // We're done with this state.            //            break;        }        //        // We are coming out of low power mode.        //        case MODE_POWER_ON:        {            //            // Indicate that we need to update the menu.            //            sUI.ulFlags |= FLAG_UPDATE_MENU;            //            // We're done with this state.            //            break;        }        //        // We are downloading data from the host.        //        case MODE_DOWNLOAD:        {            //            // Tell the user that we are downloading.            //            SerialSendString("\rDownloading           ");            //            // We're done with this state.            //            break;        }        //        // We are stopped.        //        case MODE_STOP:        {            //            // Tell the user that we are stopped.            //            SerialSendString("\rStopped ");            //            // Print out the name of the codec being used.            //            if(sUI.pusCodec)            {                SerialSendChar(sUI.pusCodec[0]);                SerialSendChar(sUI.pusCodec[1]);                SerialSendChar(sUI.pusCodec[2]);                SerialSendChar(sUI.pusCodec[3]);            }            else            {                SerialSendString("    ");            }            //            // Print out the bitrate of the current file.            //            if(sUI.ulBitRate)            {                SerialSendChar(' ');                UIPrintBitRate(sUI.ulBitRate);            }            else            {                SerialSendString("    ");            }            //            // Print out the total length of the file.            //            if(sUI.ulTotalMS)            {                SerialSendChar(' ');                UIPrintTime(sUI.ulTotalMS);            }            else            {                SerialSendString("      ");            }            //            // We're done with this state.            //            break;        }        //

⌨️ 快捷键说明

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