player_8c.html
来自「MP3 Player Source Code」· HTML 代码 · 共 945 行 · 第 1/5 页
HTML
945 行
00473 <span class="keywordtype">signed</span> <span class="keywordtype">char</span> thisband = <a class="code" href="vs10xx_8h.html#a38">Mp3ReadRegister</a>(6);00474 00475 <span class="comment">/* thisband now has spectrum value 0..63. We adjust it a little</span>00476 <span class="comment"> for best image on the evakit LCD. You also get peak values</span>00477 <span class="comment"> etc from the chip but we don't use them in the evakit screen.</span>00478 <span class="comment"> we use 8 bands, but up to 23 are obtainable from the chip. */</span>00479 00480 thisband &= 63; <span class="comment">/* mask all but level info */</span>00481 thisband >>= 1; <span class="comment">/* LCD resolution is not high */</span>00482 thisband -= 3; <span class="comment">/* base offset */</span> 00483 <span class="keywordflow">if</span> (i==0) thisband -= 2; <span class="comment">/* decrease bass bar level */</span>00484 <span class="keywordflow">if</span> (i==6) thisband += 1; <span class="comment">/* increase treble bar level */</span>00485 <span class="keywordflow">if</span> (i==7) thisband += 1; <span class="comment">/* increase treble bar level */</span>00486 <span class="keywordflow">if</span> (thisband>7) thisband = 7; <span class="comment">/* high limit */</span>00487 <span class="keywordflow">if</span> (thisband<0) thisband =<span class="charliteral">' '</span>; <span class="comment">/* low limit */</span>00488 00489 <a class="code" href="display_8c.html#a1">displayTitle</a>[i+8] = thisband; <span class="comment">//Store to display mem</span>00490 00491 }<span class="comment">//for each band</span>00492 }00493 <span class="keywordflow">break</span>;00494 00495 } <span class="comment">//switch(uiMode) </span>00496 00497 <span class="comment">// Buttons handler</span>00498 <span class="comment">// Perform mode-dependent button handling</span>00499 00500 <span class="keywordflow">if</span> ((<a class="code" href="board_8h.html#a14">KEY_BUTTON</a>) && (uiReturnDelay < <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>-20)){00501 <a class="code" href="lcd_8c.html#a4">LcdReset</a>();00502 <a class="code" href="player_8c.html#a6">uiMode</a>++;00503 uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00504 }00505 00506 <span class="keywordflow">switch</span>(<a class="code" href="player_8c.html#a6">uiMode</a>){00507 00508 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a2">UI_TITLE</a>:00509 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a3">UI_SPEC</a>:00510 00511 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00512 <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>00513 } 00514 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00515 <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>00516 } 00517 <span class="keywordflow">break</span>;00518 00519 00520 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a4">UI_VOLUME</a>:00521 00522 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00523 uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00524 <span class="keywordflow">if</span> (volume++ == 254) volume = 254; <span class="comment">//Change + limit to 254 (minimum vol)</span>00525 <a class="code" href="vs10xx_8h.html#a33">Mp3SetVolume</a>(volume,volume);00526 }00527 00528 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00529 uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00530 <span class="keywordflow">if</span> (volume-- == 0) volume = 0; <span class="comment">//Change + limit to 0 (maximum volume)</span>00531 <a class="code" href="vs10xx_8h.html#a33">Mp3SetVolume</a>(volume,volume);00532 }00533 <span class="keywordflow">break</span>; <span class="comment">// UI_VOLUME</span>00534 00535 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a5">UI_BASS</a>:00536 <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>00537 bassUpdateNeeded = 0;00538 00539 <span class="comment">//First let's see if a key is pressed; does the user want to set level?</span>00540 00541 <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>00542 00543 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00544 bassUpdateNeeded = 1;00545 <span class="keywordflow">if</span> (bass-- == 0) bass = 0; <span class="comment">//Change + limit to 0 (OFF setting)</span>00546 }00547 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00548 bassUpdateNeeded = 1;00549 <span class="keywordflow">if</span> (bass++ == 127) bass = 127; <span class="comment">//Change + limit to 127 (max setting)</span>00550 }00551 00552 }<span class="keywordflow">else</span>{ <span class="comment">//TREBLE screen is active</span>00553 00554 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00555 bassUpdateNeeded = 1; <span class="comment">//SCI_BASS is for both bass and treble</span>00556 <span class="keywordflow">if</span> (treble-- == 0) treble = 0; <span class="comment">//Change + limit to 0 (OFF setting)</span>00557 }00558 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00559 bassUpdateNeeded = 1; <span class="comment">//SCI_BASS is for both bass and treble</span>00560 <span class="keywordflow">if</span> (treble++ == 127) treble = 127; <span class="comment">//Change + limit to 127 (max)</span>00561 }00562 00563 }00564 00565 00566 <span class="keywordflow">if</span> (bassUpdateNeeded){00567 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> newBassRegister;00568 00569 <span class="comment">//User has pushed button to alter bass/treble register</span>00570 <span class="comment">//calculate new value</span>00571 00587 <span class="comment">//Let's start from bass frequency setting.</span>00588 <span class="comment">//min(0) should give 2 (20Hz), max(127) should give 15 (150Hz)</span>00589 newBassRegister = (bass + 23) / 10; <span class="comment">//into bits 3..0, clear hibits</span>00590 00591 <span class="comment">//Bass boost level.</span>00592 <span class="comment">//min(0) should give 0, max(127) should give 15</span>00593 newBassRegister |= (bass>>3)<<4; <span class="comment">//insert to bits 7..4</span>00594 00595 <span class="comment">//Then the treble frequency</span>00596 <span class="comment">//min(0) should give 15(15kHx), max(127) should give 2(2kHz)</span>00597 newBassRegister |= (((148-treble)>>3)+2)<<8; <span class="comment">//insert into bits 11..8</span>00598 00599 <span class="comment">//Finally the treble value (-8..7)</span>00600 <span class="comment">//min(0) should give -8, max(127) should give 7;</span>00601 newBassRegister |= ((treble>>3)-8)<<12; <span class="comment">//insert into bits 15..12</span>00602 00603 00604 uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00605 00606 <span class="keywordflow">if</span> (<a class="code" href="vs10xx_8h.html#a38">Mp3ReadRegister</a>(SPI_BASS)!=newBassRegister){00607 <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(SPI_BASS,newBassRegister>>8,newBassRegister&0xff);00608 }00609 00610 <span class="comment">//i = newBassRegister;</span>00611 <span class="comment">//displayTitle[4] = lcd_hexchars[i>>12];</span>00612 <span class="comment">//displayTitle[5] = lcd_hexchars[(i>>8)&0x0f];</span>00613 <span class="comment">//displayTitle[6] = lcd_hexchars[(i>>4)&0x0f];</span>00614 <span class="comment">//displayTitle[7] = lcd_hexchars[i&0x0f];</span>00615 00616 00617 }00618 00619 <span class="keywordflow">break</span>; <span class="comment">// UI_BASS and UI_TREBLE</span>00620 00621 00622 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a8">UI_RECLEVEL</a>:00623 00624 <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>){00625 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00626 uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00627 <span class="keywordflow">if</span> (reclevel++ == 100){00628 reclevel = 100;00629 }00630 <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(SPI_AICTRL1,00631 ((<span class="keywordtype">int</span>)reclevel*32)>>8,((<span class="keywordtype">int</span>)reclevel*32)&0xff);00632 <a class="code" href="board_8h.html#a42">SPIPutChar</a>(0);<a class="code" href="board_8h.html#a41">SPIWait</a>();00633 }00634 00635 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a18">KEY_FARLEFT</a>){00636 uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00637 <span class="keywordflow">if</span> (reclevel-- == 0){00638 reclevel = 0;00639 }00640 <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(SPI_AICTRL1,00641 ((<span class="keywordtype">int</span>)reclevel*32)>>8,((<span class="keywordtype">int</span>)reclevel*32)&0xff);00642 <a class="code" href="board_8h.html#a42">SPIPutChar</a>(0);<a class="code" href="board_8h.html#a41">SPIWait</a>();00643 }00644 }<span class="keywordflow">else</span>{00645 <span class="comment">//Not in recording</span>00646 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00647 <span class="comment">//Enter recording mode</span>00648 <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>00649 }00650 }00651 <span class="keywordflow">break</span>; <span class="comment">// UI_RECLEVEL</span>00652 00653 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a10">UI_STOP</a>:00654 00655 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00656 <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>00657 } 00658 <span class="keywordflow">break</span>; <span class="comment">// UI_STOP</span>00659 00660 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a7">UI_CUE</a>:00661 00662 <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>00663 <span class="keywordflow">if</span> (<a class="code" href="board_8h.html#a15">KEY_FARRIGHT</a>){00664 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>00665 <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>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 <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>00670 } 00671 }00672 00673 <span class="keywordflow">break</span>; <span class="comment">// UI_SKIP</span>00674 00675 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a11">UI_END_OF_MODES</a>:00676 <a class="code" href="player_8c.html#a6">uiMode</a> = <a class="code" href="ui_8h.html#a24a2">UI_TITLE</a>;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?