From 0bb484ae4569b13f66edc654abe4f0c6f7ef6eb0 Mon Sep 17 00:00:00 2001 From: jjangddu Date: Wed, 24 Jun 2026 09:14:32 +0900 Subject: [PATCH] =?UTF-8?q?feat(posture):=20Poll=20Interval=20=EC=8A=AC?= =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=8D=94=20+=20default=2010s=20=E2=86=92=203?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 증상: 자세 갱신이 10초마다라 너무 느림. 빠르게 테스트하고 싶음. 수정: 1) GreenZoneConstants.posturePollIntervalMs (default 3000ms) 신규 - polling loop 의 delay(10000) → delay(GreenZoneConstants.posturePollIntervalMs) - 슬라이더 변경 즉시 다음 iteration 부터 적용 2) PiezoMonitoring dev settings: Poll Interval 슬라이더 추가 - 위치: Lying Duration 슬라이더 바로 아래 - 범위: 1초 ~ 15초 (연속) - 표시: "X.X초" - 변경 시 GreenZoneConstants 에 즉시 반영 default 변경: 10초 → 3초. - mtb 한 cycle ≈ 400ms, 3초 polling = device 활동 ≈ 13% (가벼움) - 1초까지 줄여도 캐싱/throttle 충돌 거의 없음 (canSendMaa 500ms gate) BLE 부담 vs 응답성 trade-off: | interval | 1시간 device 사용 | 자세 변화 최대 지연 | | 1초 | ~24분 (40%) | ~1초 | | 3초 | ~8분 (13%) | ~3초 | | 5초 | ~5분 (8%) | ~5초 | | 10초 | ~2.5분 (4%) | ~10초 | 낙상 예방엔 1-3초가 적정. 평상시 사용엔 5-10초. Co-Authored-By: Claude Opus 4.7 --- .../managers/GreenZoneConstants.kt | 3 +++ .../views/monitoring/PiezoMonitoringView.kt | 25 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/medilightv2android/managers/GreenZoneConstants.kt b/app/src/main/java/com/example/medilightv2android/managers/GreenZoneConstants.kt index cfc1f9a..330bf2b 100644 --- a/app/src/main/java/com/example/medilightv2android/managers/GreenZoneConstants.kt +++ b/app/src/main/java/com/example/medilightv2android/managers/GreenZoneConstants.kt @@ -31,6 +31,9 @@ object GreenZoneConstants { /** Posture pitch 임계값 (deg). |pitch| > 이 값 → LYING, ≤ 이 값 → NON_LYING. dev 모드에서 조정 가능. */ @Volatile var pitchLyingThreshold: Float = 25f + /** Posture polling 간격 (ms). PiezoMonitoring 에서 mtb 보내는 주기. dev 모드에서 조정 가능. */ + @Volatile var posturePollIntervalMs: Long = 3000L + // ═══════════════════════════════════════════════════════════ // 신호 범위 // ═══════════════════════════════════════════════════════════ diff --git a/app/src/main/java/com/example/medilightv2android/ui/views/monitoring/PiezoMonitoringView.kt b/app/src/main/java/com/example/medilightv2android/ui/views/monitoring/PiezoMonitoringView.kt index 5f95080..4e5673b 100644 --- a/app/src/main/java/com/example/medilightv2android/ui/views/monitoring/PiezoMonitoringView.kt +++ b/app/src/main/java/com/example/medilightv2android/ui/views/monitoring/PiezoMonitoringView.kt @@ -694,7 +694,7 @@ fun PiezoMonitoringView(appState: AppState) { } else { Log.d("ImuDbg", "skip (connected=$isConnected measuring=$isMeasuring auto=$isAutoMeasuring spot=$isSpotInProgress)") } - kotlinx.coroutines.delay(10000) + kotlinx.coroutines.delay(GreenZoneConstants.posturePollIntervalMs) } } @@ -1853,6 +1853,29 @@ fun PiezoMonitoringView(appState: AppState) { steps = 0, colors = SliderDefaults.colors(thumbColor = MlPrimary, activeTrackColor = MlPrimary) ) + + // Posture polling 주기 (자세 갱신 빈도) + var pollIntervalVal by remember { + mutableStateOf(GreenZoneConstants.posturePollIntervalMs / 1000f) + } + Row(verticalAlignment = Alignment.CenterVertically) { + Text("Poll Interval", fontSize = labelSize, fontWeight = FontWeight.SemiBold) + Spacer(modifier = Modifier.width(8.dp)) + Text("%.1f초".format(pollIntervalVal), + fontSize = 13.sp, fontWeight = FontWeight.Bold, color = MlPrimary) + Spacer(modifier = Modifier.weight(1f)) + Text("자세 갱신 주기", fontSize = 10.sp, color = MlSecondaryText) + } + Slider( + value = pollIntervalVal, + onValueChange = { + pollIntervalVal = it + GreenZoneConstants.posturePollIntervalMs = (it * 1000).toLong() + }, + valueRange = 1f..15f, // 1초 ~ 15초 + steps = 0, + colors = SliderDefaults.colors(thumbColor = MlPrimary, activeTrackColor = MlPrimary) + ) } HorizontalDivider(modifier = Modifier.padding(vertical = dividerPadding))