From d0b8a78847d9c68a2cb704467e5b6ccfb1ac9d3a Mon Sep 17 00:00:00 2001 From: StevenBuzzi Date: Tue, 3 Mar 2026 17:40:25 +0900 Subject: [PATCH] =?UTF-8?q?Guide=20beam=20packet=20=EC=98=A4=EC=A0=84?= =?UTF-8?q?=EC=86=A1=20=EC=88=98=EC=A0=95=201.=20Engineer;=20Min/Max?= =?UTF-8?q?=EC=97=90=20=ED=91=9C=EA=B8=B0=EB=90=9C=20=EA=B0=92=EC=9D=84=20?= =?UTF-8?q?=EC=A0=84=EC=86=A1=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=202.=20Config;=20Guide=20beam=20Step=EC=97=90=20?= =?UTF-8?q?=EB=A7=9E=EA=B2=8C=20=EC=A0=84=EC=86=A1=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../raman/ui/screens/config/ConfigScreen.kt | 18 ++++++------ .../raman/ui/screens/main/MainViewModel.kt | 28 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/laseroptek/raman/ui/screens/config/ConfigScreen.kt b/app/src/main/java/com/laseroptek/raman/ui/screens/config/ConfigScreen.kt index d8a06cb..4a24381 100644 --- a/app/src/main/java/com/laseroptek/raman/ui/screens/config/ConfigScreen.kt +++ b/app/src/main/java/com/laseroptek/raman/ui/screens/config/ConfigScreen.kt @@ -439,15 +439,15 @@ fun ConfigScreen( mainViewModel.saveGuideBeamToPreference() } - /* - val value = when(guideBeam.toInt()) { - 0 -> 0 - 1 -> guideBeamMin - 10 -> guideBeamMax - else -> (guideBeamMin + (guideBeam.toInt() - 1) * ((guideBeamMax - guideBeamMin) / 9)) + // Guide Beam step mapping (0~10): + // 0 -> fixed 0 + // 1~10 -> min~max range in 10 steps (10 -> max) + val step = guideBeam.toInt().coerceIn(0, 10) + val value = if (step == 0) { + 0 + } else { + guideBeamMin + ((step-1) * (guideBeamMax - guideBeamMin) / 9) } - */ - val value = (guideBeamMin + (guideBeam.toInt() - 1) * ((guideBeamMax - guideBeamMin) / 9)) Timber.d("guideBeam: $value, guideBeamMax: $guideBeamMax, guideBeamMin: $guideBeamMin") mainViewModel.txPacket(READ_WRITE.WRITE, CMD.GUIDE_BEAM, GuideBeam(value = value)) @@ -854,4 +854,4 @@ fun PreviewConfigScreen( mainViewModel = mainViewModel, configViewModel = configViewModel ) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/laseroptek/raman/ui/screens/main/MainViewModel.kt b/app/src/main/java/com/laseroptek/raman/ui/screens/main/MainViewModel.kt index 7638625..b5a5063 100644 --- a/app/src/main/java/com/laseroptek/raman/ui/screens/main/MainViewModel.kt +++ b/app/src/main/java/com/laseroptek/raman/ui/screens/main/MainViewModel.kt @@ -583,22 +583,22 @@ class MainViewModel @Inject constructor( saveGuideBeamMinToPreference() saveGuideBeamMaxToPreference() - // After updating the state, send the packet - val newMin = guideBeamMin.value // get the potentially updated value - val newMax = guideBeamMax.value // get the potentially updated value - val guideBeam = guideBeam.value.toInt() + // Engineer 화면에서는 Min/Max 버튼에 따라 표시된 Min 또는 Max 값을 그대로 송신 + val newMin = guideBeamMin.value + val newMax = guideBeamMax.value + val value = when (state) { + MinMaxUpDownState.MinDown, + MinMaxUpDownState.MinUp, + MinMaxUpDownState.MinLongDown, + MinMaxUpDownState.MinLongUp -> newMin - /* - val value = when(guideBeamValue) { - 0 -> 0 - 1 -> newMin - 10 -> newMax - else -> (newMin + (guideBeamValue - 1) * ((newMax - newMin) / 9)) + MinMaxUpDownState.MaxDown, + MinMaxUpDownState.MaxUp, + MinMaxUpDownState.MaxLongDown, + MinMaxUpDownState.MaxLongUp -> newMax } - */ - val value = (newMin + (guideBeam - 1) * ((newMax - newMin) / 9)) - Timber.d("guideBeam: $value, guideBeam: $guideBeam, guideBeamMax: $newMax, guideBeamMin: $newMin") + Timber.d("Engineer guideBeam tx value: $value, guideBeamMax: $newMax, guideBeamMin: $newMin") txPacket(READ_WRITE.WRITE, CMD.GUIDE_BEAM, GuideBeam(value = value)) } @@ -2286,4 +2286,4 @@ class MainViewModel @Inject constructor( // ONLY do light, non-IO variable initialization here. // DO NOT call load... functions here. } -} \ No newline at end of file +} -- 2.47.3