调试优化

This commit is contained in:
2025-12-11 18:54:57 +08:00
parent 6e318f8c82
commit a0847d21b7
6 changed files with 93 additions and 44 deletions
@@ -113,6 +113,8 @@ class MainScreenPresentation(
registerDataChange()
}
private var isFirstGetWeight = true
fun updateWeight(weight: Double) {
lastWeight = weight * 1000 // 将千克转成克
Timber.tag(TAG)
@@ -121,11 +123,15 @@ class MainScreenPresentation(
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
if (mealPickupMode == 1 && chargeMode == 0) {
//余量计量+计费模式
recognitionWeight = lastWeight
if (weight > 5) {
if (isFirstGetWeight && lastWeight > 5) {
recognitionWeight = lastWeight
isFirstGetWeight = false
}
if (lastWeight > 5) {
//余量计量,有重量的情况下不回到重新识别状态
return
}
isFirstGetWeight = true
}
if (currentStep == 2 && lastWeight <= 5 && isGoStep1) {
//人脸识别过程中,秤上物品拿走
@@ -159,7 +165,16 @@ class MainScreenPresentation(
Timber.tag(TAG).e("updateWeight dinnerType is null")
return
}
calculateNutrition(recognitionWeight - lastWeight)
if (chargeMode == 1) {
//不计费
if (mealPickupMode == 0) {
//即放即取
calculateNutrition(lastWeight)
} else {
//余量计量
calculateNutrition(recognitionWeight - lastWeight)
}
}
}
fun setStepChangeCallback(callback: (Int) -> Unit) {