File tree Expand file tree Collapse file tree 1 file changed +27
-5
lines changed Expand file tree Collapse file tree 1 file changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -298,13 +298,35 @@ impl TryFrom<u8> for TuneIndex {
298
298
}
299
299
}
300
300
301
- // this is a mock that does nothing yet, but should become a direct translation
302
- // of the C original. This was done to avoid compiling `os_io_seproxyhal.c` which
303
- // includes many other things
301
+ // Direct translation of the C original. This was done to
302
+ // avoid compiling `os_io_seproxyhal.c` which includes many other things
304
303
#[ no_mangle]
305
304
extern "C" fn io_seproxyhal_play_tune ( tune_index : u8 ) {
306
- let index = TuneIndex :: try_from ( tune_index) ;
307
- if index. is_err ( ) {
305
+ let mut buffer = [ 0u8 ; 4 ] ;
306
+ let mut spi_buffer = [ 0u8 ; 128 ] ;
307
+
308
+ if tune_index >= NB_TUNES {
309
+ return ;
310
+ }
311
+
312
+ let sound_setting =
313
+ unsafe { os_setting_get ( OS_SETTING_PIEZO_SOUND . into ( ) , core:: ptr:: null_mut ( ) , 0 ) } ;
314
+
315
+ if ( ( sound_setting & 2 ) == 1 ) && ( tune_index < TUNE_TAP_CASUAL ) {
308
316
return ;
309
317
}
318
+
319
+ if ( ( sound_setting & 1 ) == 1 ) && ( tune_index >= TUNE_TAP_CASUAL ) {
320
+ return ;
321
+ }
322
+
323
+ if seph:: is_status_sent ( ) {
324
+ seph:: seph_recv ( & mut spi_buffer, 0 ) ;
325
+ }
326
+
327
+ buffer[ 0 ] = SEPROXYHAL_TAG_PLAY_TUNE as u8 ;
328
+ buffer[ 1 ] = 0 ;
329
+ buffer[ 2 ] = 1 ;
330
+ buffer[ 3 ] = tune_index;
331
+ seph:: seph_send ( & buffer) ;
310
332
}
You can’t perform that action at this time.
0 commit comments