mine_sweeper_speaker.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "mine_sweeper_speaker.h"
  2. #include "../minesweeper.h"
  3. static const float volume = 0.8f;
  4. void mine_sweeper_play_ok_sound(void* context) {
  5. MineSweeperApp* app = context;
  6. UNUSED(app);
  7. if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
  8. furi_hal_speaker_start(NOTE_LOSE, volume);
  9. }
  10. }
  11. void mine_sweeper_play_flag_sound(void* context) {
  12. MineSweeperApp* app = context;
  13. UNUSED(app);
  14. if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
  15. furi_hal_speaker_start(NOTE_FLAG, volume);
  16. }
  17. }
  18. void mine_sweeper_play_oob_sound(void* context) {
  19. MineSweeperApp* app = context;
  20. UNUSED(app);
  21. if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
  22. furi_hal_speaker_start(NOTE_OOB, volume);
  23. }
  24. }
  25. void mine_sweeper_play_win_sound(void* context) {
  26. MineSweeperApp* app = context;
  27. UNUSED(app);
  28. if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
  29. furi_hal_speaker_start(NOTE_WIN, volume);
  30. }
  31. }
  32. void mine_sweeper_play_lose_sound(void* context) {
  33. MineSweeperApp* app = context;
  34. UNUSED(app);
  35. if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
  36. furi_hal_speaker_start(NOTE_LOSE, volume);
  37. }
  38. }
  39. void mine_sweeper_stop_all_sound(void* context) {
  40. MineSweeperApp* app = context;
  41. UNUSED(app);
  42. if(furi_hal_speaker_is_mine()) {
  43. furi_hal_speaker_stop();
  44. furi_hal_speaker_release();
  45. }
  46. }