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

📄 player_8c-source.html

📁 MP3播放器源代码, VS1003B
💻 HTML
📖 第 1 页 / 共 4 页
字号:
00543     <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00544       <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a14">PS_NEXT_SONG</a>; <span class="comment">/* Request */</span>00545     }      00546     <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00547       <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a15">PS_PREVIOUS_SONG</a>; <span class="comment">/* Request */</span>00548     }      00549     <span class="keywordflow">break</span>;00550 00551 00552   <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a4">UI_VOLUME</a>:00553     00554     <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00555       uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00556       <span class="keywordflow">if</span> (volume++ == 254) volume = 254; <span class="comment">//Change + limit to 254 (minimum vol)</span>00557       <a class="code" href="vs10xx_8h.html#a33">Mp3SetVolume</a>(volume,volume);00558     }00559     00560     <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00561       uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00562       <span class="keywordflow">if</span> (volume-- == 0) volume = 0; <span class="comment">//Change + limit to 0 (maximum volume)</span>00563       <a class="code" href="vs10xx_8h.html#a33">Mp3SetVolume</a>(volume,volume);00564     }00565     <span class="keywordflow">break</span>; <span class="comment">// UI_VOLUME</span>00566 00567   <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a5">UI_BASS</a>:00568   <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a6">UI_TREBLE</a>: <span class="comment">//BASS and TREBLE use the same VS10xx register</span>00569     bassUpdateNeeded = 0;00570     00571     <span class="comment">//First let's see if a key is pressed; does the user want to set level?</span>00572 00573     <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a6">uiMode</a>==<a class="code" href="ui_8h.html#a24a5">UI_BASS</a>){ <span class="comment">//BASS screen is active</span>00574 00575       <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00576         bassUpdateNeeded = 1;00577         <span class="keywordflow">if</span> (bass-- == 0) bass = 0; <span class="comment">//Change + limit to 0 (OFF setting)</span>00578       }00579       <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00580         bassUpdateNeeded = 1;00581         <span class="keywordflow">if</span> (bass++ == 127) bass = 127; <span class="comment">//Change + limit to 127 (max setting)</span>00582       }00583 00584     }<span class="keywordflow">else</span>{ <span class="comment">//TREBLE screen is active</span>00585       00586       <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00587         bassUpdateNeeded = 1; <span class="comment">//SCI_BASS is for both bass and treble</span>00588         <span class="keywordflow">if</span> (treble-- == 0) treble = 0; <span class="comment">//Change + limit to 0 (OFF setting)</span>00589       }00590       <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00591         bassUpdateNeeded = 1; <span class="comment">//SCI_BASS is for both bass and treble</span>00592         <span class="keywordflow">if</span> (treble++ == 127) treble = 127; <span class="comment">//Change + limit to 127 (max)</span>00593       }00594       00595     }00596 00597 00598     <span class="keywordflow">if</span> (bassUpdateNeeded){00599       <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> newBassRegister;00600 00601       <span class="comment">//User has pushed button to alter bass/treble register</span>00602       <span class="comment">//calculate new value</span>00603 00619       <span class="comment">//Let's start from bass frequency setting.</span>00620       <span class="comment">//min(0) should give 2 (20Hz), max(127) should give 15 (150Hz)</span>00621       newBassRegister = (bass + 23) / 10; <span class="comment">//into bits 3..0, clear hibits</span>00622       00623       <span class="comment">//Bass boost level.</span>00624       <span class="comment">//min(0) should give 0, max(127) should give 15</span>00625       newBassRegister |= (bass&gt;&gt;3)&lt;&lt;4; <span class="comment">//insert to bits 7..4</span>00626 00627       <span class="comment">//Then the treble frequency</span>00628       <span class="comment">//min(0) should give 15(15kHx), max(127) should give 2(2kHz)</span>00629       newBassRegister |= (((148-treble)&gt;&gt;3)+2)&lt;&lt;8; <span class="comment">//insert into bits 11..8</span>00630 00631       <span class="comment">//Finally the treble value (-8..7)</span>00632       <span class="comment">//min(0) should give -8, max(127) should give 7;</span>00633       newBassRegister |= ((treble&gt;&gt;3)-8)&lt;&lt;12; <span class="comment">//insert into bits 15..12</span>00634       00635       00636       uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00637 00638       <span class="keywordflow">if</span> (<a class="code" href="vs10xx_8h.html#a38">Mp3ReadRegister</a>(<a class="code" href="vs10xx_8h.html#a4">SPI_BASS</a>)!=newBassRegister){00639         <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(<a class="code" href="vs10xx_8h.html#a4">SPI_BASS</a>,newBassRegister&gt;&gt;8,newBassRegister&amp;0xff);00640       }00641 00642       <span class="comment">//i = newBassRegister;</span>00643       <span class="comment">//displayTitle[4] = lcd_hexchars[i&gt;&gt;12];</span>00644       <span class="comment">//displayTitle[5] = lcd_hexchars[(i&gt;&gt;8)&amp;0x0f];</span>00645       <span class="comment">//displayTitle[6] = lcd_hexchars[(i&gt;&gt;4)&amp;0x0f];</span>00646       <span class="comment">//displayTitle[7] = lcd_hexchars[i&amp;0x0f];</span>00647     00648 00649     }00650 00651     <span class="keywordflow">break</span>; <span class="comment">// UI_BASS and UI_TREBLE</span>00652 00653 00654   <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a8">UI_RECLEVEL</a>:00655     00656     <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a23">PS_RECORDING</a>){00657       <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00658         uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00659         <span class="keywordflow">if</span> (reclevel++ == 100){00660           reclevel = 100;00661         }00662         <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(<a class="code" href="vs10xx_8h.html#a15">SPI_AICTRL1</a>,00663                          ((<span class="keywordtype">int</span>)reclevel*32)&gt;&gt;8,((<span class="keywordtype">int</span>)reclevel*32)&amp;0xff);00664         <a class="code" href="board_8h.html#a44">SPIPutChar</a>(0);<a class="code" href="board_8h.html#a43">SPIWait</a>();00665       }00666       00667       <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00668         uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00669         <span class="keywordflow">if</span> (reclevel-- == 0){00670           reclevel = 0;00671         }00672         <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(<a class="code" href="vs10xx_8h.html#a15">SPI_AICTRL1</a>,00673                          ((<span class="keywordtype">int</span>)reclevel*32)&gt;&gt;8,((<span class="keywordtype">int</span>)reclevel*32)&amp;0xff);00674         <a class="code" href="board_8h.html#a44">SPIPutChar</a>(0);<a class="code" href="board_8h.html#a43">SPIWait</a>();00675       }00676     }<span class="keywordflow">else</span>{00677       <span class="comment">//Not in recording</span>00678       <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00679         <span class="comment">//Enter recording mode</span>00680         <a class="code" href="player_8c.html#a3">playingState</a>=<a class="code" href="ui_8h.html#a25a23">PS_RECORDING</a>; <span class="comment">//request to record</span>00681       }00682     }00683     <span class="keywordflow">break</span>; <span class="comment">// UI_RECLEVEL</span>00684 00685   <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a10">UI_STOP</a>:00686     00687     <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00688       <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a13">PS_END_OF_SONG</a>; <span class="comment">/* Request to abort playing */</span>00689     }      00690     <span class="keywordflow">break</span>; <span class="comment">// UI_STOP</span>00691     00692   <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a7">UI_CUE</a>:00693     00694     <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a3">playingState</a> == <a class="code" href="ui_8h.html#a25a12">PS_NORMAL</a>){ <span class="comment">/* Only control when PS_NORMAL */</span>00695       <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00696         uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>; <span class="comment">/* Don't go back to title just yet */</span>00697         <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a16">PS_CUE</a>; <span class="comment">/* Request */</span>00698       }      00699       <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00700         uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00701         <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a19">PS_REWIND</a>; <span class="comment">/* Request */</span>00702       }      00703     }00704 00705     <span class="keywordflow">break</span>; <span class="comment">// UI_SKIP</span>00706 00707   <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a11">UI_END_OF_MODES</a>:00708     <a class="code" href="player_8c.html#a6">uiMode</a> = <a class="code" href="ui_8h.html#a24a2">UI_TITLE</a>;00709     <span class="keywordflow">break</span>; <span class="comment">// UI_END_OF_MODES</span>00710     00711 00712   } <span class="comment">//End Switch</span>00713 00714 00715   <span class="comment">// Draw screen</span>00716   <a class="code" href="display_8c.html#a7">UpdateDisplay</a>();00717 }00718   00719 00720 <a name="l00724"></a><a class="code" href="player_8c.html#a13">00724</a> <span class="keywordtype">void</span> <a class="code" href="player_8c.html#a13">PlayCurrentFile</a>(){00725   xdata <span class="keywordtype">char</span> c, nFragments;00726 00727   <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a12">PS_NORMAL</a>; <span class="comment">/* Request to play normally */</span>

⌨️ 快捷键说明

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