📄 player_8c.html
字号:
00482 <span class="comment">//Not in recording</span>00483 <a class="code" href="display_8c.html#a4">displayStyle</a> = <a class="code" href="display_8h.html#a4">DS_NO_YES</a>;00484 strcpy (displayTitle, <span class="stringliteral">"Record? "</span>);00485 }00486 <span class="keywordflow">break</span>;00487 00488 00489 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a3">UI_SPEC</a>: <span class="comment">// Spectrum analyzer</span>00490 00491 <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>){00492 <a class="code" href="player_8c.html#a6">uiMode</a>++; <span class="comment">//Don't show specana when recording</span>00493 }00494 00495 <a class="code" href="lcd_8h.html#a5">LcdSelectFont</a>(lcdFont_vertical_barchars);00496 <a class="code" href="display_8c.html#a4">displayStyle</a> = <a class="code" href="display_8h.html#a6">DS_RAWTEXT</a>;00497 <a class="code" href="player_8c.html#a11">ScreenSetPlayTime</a>();00498 00499 <span class="comment">// Request to read Spectrum Analyzer register</span>00500 <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(7, 0x18, 0x04);00501 00502 <span class="comment">// Read Spectrum Analyzer registers</span>00503 {00504 <span class="keywordflow">for</span> (i=0;i<8;i++) { <span class="comment">//for each band i in [0..7]</span>00505 <span class="keywordtype">signed</span> <span class="keywordtype">char</span> thisband = <a class="code" href="vs10xx_8h.html#a38">Mp3ReadRegister</a>(6);00506 00507 <span class="comment">/* thisband now has spectrum value 0..63. We adjust it a little</span>00508 <span class="comment"> for best image on the evakit LCD. You also get peak values</span>00509 <span class="comment"> etc from the chip but we don't use them in the evakit screen.</span>00510 <span class="comment"> we use 8 bands, but up to 23 are obtainable from the chip. */</span>00511 00512 thisband &= 63; <span class="comment">/* mask all but level info */</span>00513 thisband >>= 1; <span class="comment">/* LCD resolution is not high */</span>00514 thisband -= 3; <span class="comment">/* base offset */</span> 00515 <span class="keywordflow">if</span> (i==0) thisband -= 2; <span class="comment">/* decrease bass bar level */</span>00516 <span class="keywordflow">if</span> (i==6) thisband += 1; <span class="comment">/* increase treble bar level */</span>00517 <span class="keywordflow">if</span> (i==7) thisband += 1; <span class="comment">/* increase treble bar level */</span>00518 <span class="keywordflow">if</span> (thisband>7) thisband = 7; <span class="comment">/* high limit */</span>00519 <span class="keywordflow">if</span> (thisband<0) thisband =<span class="charliteral">' '</span>; <span class="comment">/* low limit */</span>00520 00521 <a class="code" href="display_8c.html#a1">displayTitle</a>[i+8] = thisband; <span class="comment">//Store to display mem</span>00522 00523 }<span class="comment">//for each band</span>00524 }00525 <span class="keywordflow">break</span>;00526 00527 } <span class="comment">//switch(uiMode) </span>00528 00529 <span class="comment">// Buttons handler</span>00530 <span class="comment">// Perform mode-dependent button handling</span>00531 00532 <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)){00533 <a class="code" href="lcd_8c.html#a4">LcdReset</a>();00534 <a class="code" href="player_8c.html#a6">uiMode</a>++;00535 uiReturnDelay = <a class="code" href="player_8c.html#a2">UI_RETURN_DELAY</a>;00536 }00537 00538 <span class="keywordflow">switch</span>(<a class="code" href="player_8c.html#a6">uiMode</a>){00539 00540 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a2">UI_TITLE</a>:00541 <span class="keywordflow">case</span> <a class="code" href="ui_8h.html#a24a3">UI_SPEC</a>:00542 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>>3)<<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)>>3)+2)<<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>>3)-8)<<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>(SPI_BASS)!=newBassRegister){00639 <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(SPI_BASS,newBassRegister>>8,newBassRegister&0xff);00640 }00641 00642 <span class="comment">//i = newBassRegister;</span>00643 <span class="comment">//displayTitle[4] = lcd_hexchars[i>>12];</span>00644 <span class="comment">//displayTitle[5] = lcd_hexchars[(i>>8)&0x0f];</span>00645 <span class="comment">//displayTitle[6] = lcd_hexchars[(i>>4)&0x0f];</span>00646 <span class="comment">//displayTitle[7] = lcd_hexchars[i&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>(SPI_AICTRL1,00663 ((<span class="keywordtype">int</span>)reclevel*32)>>8,((<span class="keywordtype">int</span>)reclevel*32)&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>(SPI_AICTRL1,00673 ((<span class="keywordtype">int</span>)reclevel*32)>>8,((<span class="keywordtype">int</span>)reclevel*32)&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>){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -