H/P 연결할 때마다 Lifetime 기준값이 1씩 증가하는 버그 수정

This commit is contained in:
StevenBuzzi
2026-03-17 17:16:28 +09:00
parent babd667c5f
commit b52ddb5c4d
3 changed files with 19 additions and 53 deletions

View File

@@ -58,7 +58,7 @@ fun LifeTimeView(
Spacer(modifier = Modifier.height(2.px.dp)) Spacer(modifier = Modifier.height(2.px.dp))
// Temp 0..7 // Temp 0..7
for (i in 0..lifeTimeTypes.size -1) { for (i in 0..lifeTimeTypes.size - 1) {
val value = when (i) { val value = when (i) {
0 -> lifeTime.lamp 0 -> lifeTime.lamp
1 -> lifeTime.hp5x5 1 -> lifeTime.hp5x5

View File

@@ -392,10 +392,13 @@ class PresetViewModel @Inject constructor(
val newRepetitionIndex = repetitionList.value.indexOf(repetition).takeIf { it != -1 } ?: 0 val newRepetitionIndex = repetitionList.value.indexOf(repetition).takeIf { it != -1 } ?: 0
val newRepetition = if (isUp == UpDownState.Up) { val newRepetition = if (isUp == UpDownState.Up) {
// Original logic: repetitionIndex < PulseDurations.size -1 (Likely a typo, should be Repetitions.size) // Original logic: repetitionIndex < PulseDurations.size -1 (Likely a typo, should be Repetitions.size)
if (newRepetitionIndex < repetitionList.value.size - 1) repetitionList.value[newRepetitionIndex + 1] else repetition if(newRepetitionIndex < repetitionList.value.size - 1) repetitionList.value[newRepetitionIndex + 1]
} else { else repetition
}
else {
// Original logic: repetitionIndex > 1 // Original logic: repetitionIndex > 1
if (newRepetitionIndex > 0) repetitionList.value[newRepetitionIndex - 1] else repetition if (newRepetitionIndex > 0) repetitionList.value[newRepetitionIndex - 1]
else repetition
} }
val updatedPreset = currentList[index].copy(repetition = newRepetition) val updatedPreset = currentList[index].copy(repetition = newRepetition)

View File

@@ -1106,7 +1106,7 @@ class MainViewModel @Inject constructor(
CMD.LASER_STATUS -> { CMD.LASER_STATUS -> {
val l = packet.data.toLaserStatus() val l = packet.data.toLaserStatus()
setLaserStatus(l.copy()) setLaserStatus(l.copy())
// on receuve laser on (or interval) increase count and save to pref. // on receive laser on (or interval) increase count and save to pref.
// Laser On 패킷만 counting 하도록 변경 (2개 패킷 모두 수신 됨) // Laser On 패킷만 counting 하도록 변경 (2개 패킷 모두 수신 됨)
if (_laserStatus.value.laserStatus == LASER_STATUS.LASER_ON /* || l.laserStatus == LASER_STATUS.INTERVAL */) { if (_laserStatus.value.laserStatus == LASER_STATUS.LASER_ON /* || l.laserStatus == LASER_STATUS.INTERVAL */) {
playBeepSound() playBeepSound()
@@ -1117,6 +1117,9 @@ class MainViewModel @Inject constructor(
increaseLampCount() increaseLampCount()
saveLampCountToPreference() saveLampCountToPreference()
Timber.d("Laser shot: lampCount=${_lampCount.value}, laserCount=${_laserCount.value} " +
"handPieceType=${handPiece.value.type}, hpCount=${hpCount.value}")
val repetitionIndex = repetitionAngle.value.degreeToStep(totalSteps = repetitionList.value.size) val repetitionIndex = repetitionAngle.value.degreeToStep(totalSteps = repetitionList.value.size)
val repetition = repetitionList.value[repetitionIndex] val repetition = repetitionList.value[repetitionIndex]
Timber.d("repetition: ${repetition}") Timber.d("repetition: ${repetition}")
@@ -1185,58 +1188,18 @@ class MainViewModel @Inject constructor(
setEnergyControl(EnergyControl(0x03, 0x00)) setEnergyControl(EnergyControl(0x03, 0x00))
setEnergyMeasured(EnergyMeasured(0x04, 0x00, 0x00)) setEnergyMeasured(EnergyMeasured(0x04, 0x00, 0x00))
// hand piece 별 count 증가 val connectedHandPieceLifeTime = when (h.type) {
when (h.type) { 1 -> lifeTime.value.hp5x5
1 -> { // hp 5x5 2 -> lifeTime.value.hp7x7
setLifeTime( 3 -> lifeTime.value.hp10x10
_lifeTime.value.copy( 4 -> lifeTime.value.hp12x12
hp5x5 = _lifeTime.value.hp5x5 + 1 5 -> lifeTime.value.hp3x15
)
)
saveLifeTimeToPreference()
Timber.d("_lifeTime (hp5x5): ${_lifeTime}")
}
2 -> {
setLifeTime(
_lifeTime.value.copy(
hp7x7 = _lifeTime.value.hp7x7 + 1
)
)
saveLifeTimeToPreference()
Timber.d("_lifeTime (hp7x7): ${_lifeTime}")
}
3 -> {
setLifeTime(
_lifeTime.value.copy(
hp10x10 = _lifeTime.value.hp10x10 + 1
)
)
saveLifeTimeToPreference()
Timber.d("_lifeTime (hp10x10): ${_lifeTime}")
}
4 -> {
setLifeTime(
_lifeTime.value.copy(
hp12x12 = _lifeTime.value.hp12x12 + 1
)
)
saveLifeTimeToPreference()
Timber.d("_lifeTime (hp12x12): ${_lifeTime}")
}
5 -> {
setLifeTime(
_lifeTime.value.copy(
hp3x15 = _lifeTime.value.hp3x15 + 1
)
)
saveLifeTimeToPreference()
Timber.d("_lifeTime (hp3x15): ${_lifeTime}")
}
else -> { else -> {
Timber.d("unknwon hand piece type: ${h.type}") Timber.d("Unknown Hand-piece type: ${h.type}")
return@launch return@launch
} }
} }
Timber.d("HAND_PIECE lifetime: type=${h.type}, value=${connectedHandPieceLifeTime}, hpCount=${hpCount.value}")
// hand piece가 변경 시점 에서, pref 테이블 값을 -> energyTable 로 로딩 // hand piece가 변경 시점 에서, pref 테이블 값을 -> energyTable 로 로딩
loadFluenceTable(handPiece.value.type) loadFluenceTable(handPiece.value.type)