--[[
  @package   eg4-crank-ui-2
  @file      sound.lua
  @brief     Functions to play navigation sounds
]]

local info = {}

---
--- @brief  Play click sound
---
function cb_click()
  if not sbmodule then return end
  if get_touch_screen_click() == 0 then return end
  sbmodule.playClick()
end

---
--- @brief  Play error sound
---
function cb_error_tone()
  if not sbmodule then return end
  sbmodule.playError()
end

---
--- @brief  Play beep sound
---
function cb_beep()
  if not sbmodule then return end
  sbmodule.playBeep()
end

---
--- @brief  Stop playing current sound
---
function cb_play_stop()
  if not sbmodule then return end
  if not info.in_progress then return end
  info.in_progress = nil
  sbmodule.playStop()
end


---
--- @brief  Play remove USB sound
---
function cb_play_remove_usb()
  if not sbmodule then return end
  sbmodule.playRemoveUSB()
  info.in_progress = true
end
