desc:SOS、高报频率提高一倍

main
xiaowusky 1 year ago
parent 2860630d26
commit b29c8dba44

@ -213,6 +213,8 @@ object ParseHelper {
} else {
warning.gasValue = value
warning.overRange = overRange
warning.thresholdLow = min
warning.thresholdHigh = max
mWarnListener?.invoke(typeEnum.desc, warning)
warningDao.update(warning)
return warning
@ -235,6 +237,8 @@ object ParseHelper {
} else {
warning.gasValue = value
warning.overRange = overRange
warning.thresholdLow = min
warning.thresholdHigh = max
mWarnListener?.invoke(typeEnum.desc, warning)
warningDao.update(warning)
return warning

@ -7,16 +7,18 @@ import com.common.commonlib.utils.LogUtils
object SoundUtils {
private const val TYPE_SOS = 0
private const val TYPE_WARN_HIGHT = 1
private const val TYPE_WARN_HIGH = 1
private const val TYPE_WARN_LOW = 2
private val soundMap = hashMapOf<Int, Boolean>(
TYPE_SOS to false,
TYPE_WARN_LOW to false,
TYPE_WARN_HIGHT to false
TYPE_WARN_HIGH to false
)
private const val DELAY_FREQUENCY_HIGH = 250
private const val DELAY_FREQUENCY_LOW = 600
private var soundPlaying = false
private var currentPlayingDelay = 500
private var currentPlayingDelay = DELAY_FREQUENCY_HIGH
private var soundThread: HandlerThread? = null
private var soundHandler: Handler? = null
var gpioValue = 0
@ -29,11 +31,11 @@ object SoundUtils {
}
fun warnSound(isHigh: Boolean) {
playSoundIo(if (isHigh) TYPE_WARN_HIGHT else TYPE_WARN_LOW)
playSoundIo(if (isHigh) TYPE_WARN_HIGH else TYPE_WARN_LOW)
}
fun warnSoundClose() {
stopSoundIo(TYPE_WARN_HIGHT)
stopSoundIo(TYPE_WARN_HIGH)
stopSoundIo(TYPE_WARN_LOW)
}
@ -56,10 +58,10 @@ object SoundUtils {
}
private fun getDelayTime(soundMap: HashMap<Int, Boolean>): Int {
if (soundMap[TYPE_SOS] == true || soundMap[TYPE_WARN_HIGHT] == true) {
return 500
if (soundMap[TYPE_SOS] == true || soundMap[TYPE_WARN_HIGH] == true) {
return DELAY_FREQUENCY_HIGH
} else if (soundMap[TYPE_WARN_LOW] == true) {
return 700
return DELAY_FREQUENCY_LOW
}
return 0
}
@ -69,17 +71,17 @@ object SoundUtils {
soundPlaying = true
while (soundPlaying) {
gpioValue = if (gpioValue > 0) 0 else 1
LogUtils.w("cyy gpioValue ${gpioValue}, delay = $currentPlayingDelay")
GPIOUtils.setGpioValue(140, gpioValue)
Thread.sleep(currentPlayingDelay.toLong())
checkStatus()
LogUtils.w("cyy gpioValue ${gpioValue}, delay = $currentPlayingDelay, soundPlaying = $soundPlaying")
}
GPIOUtils.setGpioValue(140, 0)
}
private fun checkStatus() {
val finalStatus =
(soundMap[TYPE_SOS] == true && soundMap[TYPE_WARN_LOW] == true && soundMap[TYPE_WARN_HIGHT] == true)
(soundMap[TYPE_SOS] == true || soundMap[TYPE_WARN_LOW] == true || soundMap[TYPE_WARN_HIGH] == true)
if (!finalStatus) {
soundPlaying = false
} else {

Loading…
Cancel
Save