Compare commits
1 Commits
feature/IS
...
feature/IS
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fc9640e38 |
@@ -35,7 +35,6 @@ 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
|
||||||
@@ -93,18 +92,10 @@ fun HomeScreen(
|
|||||||
|
|
||||||
val presetList by mainViewModel.presetList.collectAsState()
|
val presetList by mainViewModel.presetList.collectAsState()
|
||||||
|
|
||||||
LaunchedEffect(lampCount, lifeTime.lamp, laserStatus.laserStatus) {
|
LaunchedEffect(Unit) {
|
||||||
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,18 +482,6 @@ 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(
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ fun DcdSettingPopup(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxHeight()
|
.fillMaxHeight()
|
||||||
.size(40.px.dp, 210.px.dp),
|
.size(40.px.dp, 210.px.dp),
|
||||||
chargeRate = gasChargeRate.toInt()
|
chargeRate = gasChargeRate
|
||||||
)
|
)
|
||||||
|
|
||||||
// Icon
|
// Icon
|
||||||
|
|||||||
@@ -28,14 +28,26 @@ import com.laseroptek.raman.ui.screens.main.MainViewModel
|
|||||||
import com.laseroptek.raman.utils.DefaultDispatcherProvider
|
import com.laseroptek.raman.utils.DefaultDispatcherProvider
|
||||||
import com.laseroptek.raman.utils.ext.px
|
import com.laseroptek.raman.utils.ext.px
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
import kotlin.math.abs
|
||||||
|
import kotlin.math.ceil
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun GradientSlider(
|
fun GradientSlider(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
chargeRate: Int = 0, // Value from (0 .. 100)
|
chargeRate: Float = 0f,
|
||||||
) {
|
) {
|
||||||
val chargeIndex = ((chargeRate.coerceIn(0, 100) + 4) / 5).toInt() // 0..19
|
val normalizedRate = chargeRate.coerceIn(0f, 100f)
|
||||||
|
val bucket = normalizedRate / 5f
|
||||||
|
val remainder = normalizedRate % 5f
|
||||||
|
val isExactMultiple = abs(remainder) < 0.0001f
|
||||||
|
|
||||||
|
val chargeIndex = when {
|
||||||
|
normalizedRate == 0f -> -1
|
||||||
|
isExactMultiple -> (bucket - 1f).toInt().coerceAtLeast(-1)
|
||||||
|
else -> (ceil(bucket.toDouble()).toInt() - 1)
|
||||||
|
}.coerceIn(-1, 19)
|
||||||
|
|
||||||
Timber.d("chargeRate: $chargeRate, chargeIndex: $chargeIndex")
|
Timber.d("chargeRate: $chargeRate, chargeIndex: $chargeIndex")
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
@@ -103,6 +115,6 @@ fun GradientSliderPreview(
|
|||||||
//mainViewModel = mainViewModel
|
//mainViewModel = mainViewModel
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(40.px.dp, 210.px.dp),
|
.size(40.px.dp, 210.px.dp),
|
||||||
chargeRate = 20
|
chargeRate = 20f
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user