@@ -10,6 +10,7 @@ const VS1053_CHUNK_SIZE: u8 = 32;
1010// SCI Register
1111const SCI_MODE : u8 = 0x0 ;
1212const SCI_STATUS : u8 = 0x1 ;
13+ #[ allow( dead_code) ]
1314const SCI_BASS : u8 = 0x2 ;
1415const SCI_CLOCKF : u8 = 0x3 ;
1516// const SCI_DECODE_TIME: u8 = 0x4; // current decoded time in full seconds
@@ -25,6 +26,7 @@ const SCI_NUM_REGISTERS: u8 = 0xF;
2526// SCI_MODE bits
2627const SM_SDINEW : u8 = 11 ; // Bitnumber in SCI_MODE always on
2728const SM_RESET : u8 = 2 ; // Bitnumber in SCI_MODE soft reset
29+ #[ allow( dead_code) ]
2830const SM_CANCEL : u8 = 3 ; // Bitnumber in SCI_MODE cancel song
2931 // const SM_TESTS: u8 = 5; // Bitnumber in SCI_MODE for tests
3032const SM_LINE1 : u8 = 14 ; // Bitnumber in SCI_MODE for Line input
@@ -168,12 +170,12 @@ where
168170 fn sdi_send_buffer ( & mut self , mut data : * mut u8 , mut length : usize ) {
169171 let mut chunk_length: usize ; // Length of chunk 32 byte or shorter
170172
171- self . data_mode_on ( ) ;
173+ let _ = self . data_mode_on ( ) ;
172174 while length > 0
173175 // More to do?
174176 {
175- self . await_data_request ( ) ; // Wait for space available
176- // Calculate the chunk length (up to 32 bytes)
177+ let _ = self . await_data_request ( ) ; // Wait for space available
178+ // Calculate the chunk length (up to 32 bytes)
177179 chunk_length = if length > VS1053_CHUNK_SIZE . into ( ) {
178180 VS1053_CHUNK_SIZE . into ( )
179181 } else {
@@ -194,14 +196,15 @@ where
194196 data = data. add ( chunk_length) ;
195197 }
196198 }
197- self . data_mode_off ( ) ;
199+ let _ = self . data_mode_off ( ) ;
198200 }
199201
202+ #[ allow( dead_code) ]
200203 fn sdi_send_fillers ( & mut self , mut length : usize ) {
201- self . data_mode_on ( ) ;
204+ let _ = self . data_mode_on ( ) ;
202205
203206 while length > 0 {
204- self . await_data_request ( ) ; // Wait for space available
207+ let _ = self . await_data_request ( ) ; // Wait for space available
205208
206209 let chunk_length = if length > VS1053_CHUNK_SIZE . into ( ) {
207210 VS1053_CHUNK_SIZE
@@ -220,7 +223,8 @@ where
220223 let end_fill_byte = efb & 0xFF ;
221224 let lsb: u8 = ( end_fill_byte & 0xFF ) as u8 ;
222225 let msb: u8 = ( end_fill_byte >> 8 ) as u8 ;
223- self . spi
226+ let _ = self
227+ . spi
224228 . transaction ( & mut [ Operation :: Write ( & [ msb, lsb] ) ] )
225229 . map_err ( |error| {
226230 log:: warn!(
@@ -231,7 +235,7 @@ where
231235 }
232236 }
233237
234- self . data_mode_off ( ) ;
238+ let _ = self . data_mode_off ( ) ;
235239 }
236240
237241 fn wram_write ( & mut self , address : u16 , data : u16 ) -> Result < ( ) , DSPError > {
@@ -401,23 +405,21 @@ where
401405 }
402406 // yield(); // Allow ESP firmware to do some bookkeeping
403407 }
404- return cnt == 0 ; // Return the result
408+ cnt == 0 // Return the result
405409 }
406410
407411 pub fn set_volume ( & mut self , vol : u8 ) -> Result < ( ) , DSPError > {
408412 // Set volume. Both left and right.
409413 // Input value is 0..100. 100 is the loudest.
410- let ( mut value_l, mut value_r) ; // Values to send to SCI_VOL
414+ let ( mut value_l, mut value_r) = ( vol , vol ) ; // Values to send to SCI_VOL
411415
412416 self . current_volume = vol; // Save for later use
413- value_l = vol;
414- value_r = vol;
415417
416- if self . current_balance < 0 {
417- value_r = max ( 0 , vol. saturating_add ( self . current_balance as u8 ) ) ;
418- } else if self . current_balance > 0 {
419- value_l = max ( 0 , vol . saturating_sub ( self . current_balance as u8 ) ) ;
420- }
418+ match self . current_balance {
419+ balance if balance < 0 => value_r = max ( 0 , vol. saturating_add ( balance . unsigned_abs ( ) ) ) ,
420+ balance if balance > 0 => value_l = max ( 0 , vol . saturating_sub ( balance as u8 ) ) ,
421+ _ => { }
422+ } ;
421423
422424 value_l = map ( value_l. into ( ) , 0 , 100 , 0xFE , 0x00 ) as u8 ; // 0..100% to left channel
423425 value_r = map ( value_r. into ( ) , 0 , 100 , 0xFE , 0x00 ) as u8 ; // 0..100% to right channel
@@ -448,19 +450,21 @@ where
448450 value = ( value << 4 ) | nibble as u16 ; // Shift next nibble in
449451 }
450452 }
451- self . write_register ( true , SCI_BASS , value) ; // Volume left and right
453+ let _ = self . write_register ( true , SCI_BASS , value) ; // Volume left and right
452454 }
453455
454456 pub fn get_volume ( & mut self ) -> u8 {
455457 // Get the current volume setting.
456- return self . current_volume ;
458+ self . current_volume
457459 }
458460
461+ #[ allow( dead_code) ]
459462 fn get_balance ( & mut self ) -> i8 {
460463 // Get the current balance setting.
461- return self . current_balance ;
464+ self . current_balance
462465 }
463466
467+ #[ allow( dead_code) ]
464468 fn start_song ( & mut self ) {
465469 self . sdi_send_fillers ( 10 ) ;
466470 }
@@ -475,7 +479,7 @@ where
475479 let mut remaining = data. len ( ) ;
476480 let mut offset = 0 ;
477481
478- self . data_mode_on ( ) ;
482+ let _ = self . data_mode_on ( ) ;
479483 while remaining > 0 {
480484 let chunk_length = if remaining > chunk_size {
481485 chunk_size
@@ -490,16 +494,17 @@ where
490494 remaining -= chunk_length;
491495 offset += chunk_length;
492496 }
493- self . data_mode_off ( ) ;
497+ let _ = self . data_mode_off ( ) ;
494498 Ok ( ( ) )
495499 }
496500
501+ #[ allow( dead_code) ]
497502 fn stop_song ( & mut self ) {
498503 let mut modereg: u16 ; // Read from mode register
499504
500505 self . sdi_send_fillers ( 2052 ) ;
501506 sleep ( Duration :: from_millis ( 10 ) ) ;
502- self . write_register ( true , SCI_MODE , _bv ! ( SM_SDINEW ) | _bv ! ( SM_CANCEL ) ) ;
507+ let _ = self . write_register ( true , SCI_MODE , _bv ! ( SM_SDINEW ) | _bv ! ( SM_CANCEL ) ) ;
503508 for i in 0 ..=200 {
504509 self . sdi_send_fillers ( 32 ) ;
505510 modereg = self
@@ -517,9 +522,9 @@ where
517522
518523 fn soft_reset ( & mut self ) {
519524 log:: info!( "Performing soft-reset\n " ) ;
520- self . write_register ( true , SCI_MODE , _bv ! ( SM_SDINEW ) | _bv ! ( SM_RESET ) ) ;
525+ let _ = self . write_register ( true , SCI_MODE , _bv ! ( SM_SDINEW ) | _bv ! ( SM_RESET ) ) ;
521526 sleep ( Duration :: from_millis ( 10 ) ) ;
522- self . await_data_request ( ) ;
527+ let _ = self . await_data_request ( ) ;
523528 }
524529
525530 // /**
@@ -552,7 +557,7 @@ where
552557 log:: info!( "--- -----\n " ) ;
553558 for i in 0 ..=SCI_NUM_REGISTERS {
554559 regbuf[ i as usize ] = self
555- . read_register ( i as u8 )
560+ . read_register ( i)
556561 . expect ( "Failed to read_register in print_details()" ) ;
557562 }
558563 for i in 0 ..=SCI_NUM_REGISTERS {
@@ -571,8 +576,8 @@ where
571576 // */
572577 pub fn switch_to_mp3_mode ( & mut self ) {
573578 // You can detect RTMIDI mode after hardware/software reset by checking AUDATA. If you see 44100/44101, RTMIDI has been activated,
574- self . wram_write ( ADDR_REG_GPIO_DDR_RW , 3 ) ; // GPIO DDR = 3
575- self . wram_write ( ADDR_REG_GPIO_ODATA_RW , 0 ) ; // GPIO ODATA = 0
579+ let _ = self . wram_write ( ADDR_REG_GPIO_DDR_RW , 3 ) ; // GPIO DDR = 3
580+ let _ = self . wram_write ( ADDR_REG_GPIO_ODATA_RW , 0 ) ; // GPIO ODATA = 0
576581 sleep ( Duration :: from_millis ( 100 ) ) ;
577582 log:: info!( "Switched to mp3 mode\n " ) ;
578583 self . soft_reset ( ) ;
@@ -619,7 +624,7 @@ where
619624 let status: u16 = self
620625 . read_register ( SCI_STATUS )
621626 . expect ( "Failed to read SCI_STATUS for is_chip_connected()" ) ;
622- return !( status == 0 || status == 0xFFFF ) ;
627+ !( status == 0 || status == 0xFFFF )
623628 }
624629
625630 // /**
@@ -631,7 +636,7 @@ where
631636 let status: u16 = self
632637 . read_register ( SCI_STATUS )
633638 . expect ( "Failed to read SCI_STATUS for get_chip_version()" ) ;
634- return ( status & 0x00F0 ) >> 4 ;
639+ ( status & 0x00F0 ) >> 4
635640 }
636641
637642 // /**
0 commit comments