Enforce standby when lamp lifetime exceeded #37
@@ -35,6 +35,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
||||||
import com.laseroptek.raman.const.LaserParameter
|
import com.laseroptek.raman.const.LaserParameter
|
||||||
|
import com.laseroptek.raman.const.LASER_STATUS
|
||||||
import com.laseroptek.raman.const.LaserStatusType
|
import com.laseroptek.raman.const.LaserStatusType
|
||||||
import com.laseroptek.raman.const.MAX_LASER_COUNT
|
import com.laseroptek.raman.const.MAX_LASER_COUNT
|
||||||
import com.laseroptek.raman.const.PresetButtonType
|
import com.laseroptek.raman.const.PresetButtonType
|
||||||
@@ -92,10 +93,18 @@ fun HomeScreen(
|
|||||||
|
|
||||||
val presetList by mainViewModel.presetList.collectAsState()
|
val presetList by mainViewModel.presetList.collectAsState()
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(lampCount, lifeTime.lamp, laserStatus.laserStatus) {
|
||||||
Timber.d("LaunchedEffect - HomeScreen")
|
Timber.d("LaunchedEffect - HomeScreen")
|
||||||
focusManager.clearFocus(force = true) // Hide the keyboard
|
focusManager.clearFocus(force = true) // Hide the keyboard
|
||||||
|
|
||||||
|
// Ensure the system returns to StandBy when lamp thresholds are exceeded
|
||||||
|
val lampLifetimeLimit = lifeTime.lamp
|
||||||
|
val reachedLifetimeLimit = lampLifetimeLimit > 0 && lampCount >= lampLifetimeLimit
|
||||||
|
if (reachedLifetimeLimit && laserStatus.laserStatus != LASER_STATUS.STAND_BY) {
|
||||||
|
Timber.d("HomeScreen load - forcing StandBy state due to lamp count limit")
|
||||||
|
mainViewModel.txLaserStatusEntry(LASER_STATUS.STAND_BY)
|
||||||
|
}
|
||||||
|
|
||||||
Timber.d("Attempted to hide keyboard on EngineerScreen launch")
|
Timber.d("Attempted to hide keyboard on EngineerScreen launch")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,6 +491,18 @@ fun HomeScreen(
|
|||||||
return@StandByButton
|
return@StandByButton
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val lampLifetimeLimit = lifeTime.lamp
|
||||||
|
if (lampLifetimeLimit > 0 && lampCount >= lampLifetimeLimit) {
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
"Lamp lifetime limit reached",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
return@StandByButton
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
val hpCount = mainViewModel.getHPCount()
|
val hpCount = mainViewModel.getHPCount()
|
||||||
if (hpCount < 1) {
|
if (hpCount < 1) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
|
|||||||
Reference in New Issue
Block a user