fix(shelf): 实现负漂移抑制以提高重量显示准确性
- 在ShelfV3Activity中针对-5克以内的负读数做归零处理,避免误导显示 - 修改获取重量逻辑,保证显示重量与真实重量区分 - 在ShelfV3Adapter中对空秤零点附近的小负重量做归零处理 - 优化重量单位显示逻辑,根据负漂移抑制后的值显示克或千克 - 更新local.properties中SDK路径配置
This commit is contained in:
@@ -155,8 +155,10 @@ class ShelfV3Activity : BaseActivity() {
|
|||||||
binding.tvVegTypeName.text = model.vegTypeName
|
binding.tvVegTypeName.text = model.vegTypeName
|
||||||
val weightG = model.weight ?: 0.0
|
val weightG = model.weight ?: 0.0
|
||||||
realWeight = (weightG * 1000.0).toInt()
|
realWeight = (weightG * 1000.0).toInt()
|
||||||
|
// 负漂移抑制:-5克以内的负读数显示时归零(realWeight 保持真实值)
|
||||||
|
val displayWeight = if (realWeight in -5..0) 0 else realWeight
|
||||||
binding.tvFoodWeight.text = if (weightG >= 1.0) "%.3f千克".format(weightG)
|
binding.tvFoodWeight.text = if (weightG >= 1.0) "%.3f千克".format(weightG)
|
||||||
else "${realWeight}克"
|
else "${displayWeight}克"
|
||||||
startTime = System.currentTimeMillis()
|
startTime = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,8 +356,10 @@ class ShelfV3Activity : BaseActivity() {
|
|||||||
val intervalTime = System.currentTimeMillis() - startTime
|
val intervalTime = System.currentTimeMillis() - startTime
|
||||||
val weight = event.weight
|
val weight = event.weight
|
||||||
log("格口${shelfModel?.slotNo}获取重量:${weight}克,间隔:${intervalTime}ms")
|
log("格口${shelfModel?.slotNo}获取重量:${weight}克,间隔:${intervalTime}ms")
|
||||||
binding.tvFoodWeight.text = if (weight < 1000) "${weight}克"
|
// 负漂移抑制:-5克以内的负读数显示时归零
|
||||||
else "%.3f千克".format(weight / 1000.0)
|
val displayWeight = if (weight in -5..0) 0 else weight
|
||||||
|
binding.tvFoodWeight.text = if (displayWeight < 1000) "${displayWeight}克"
|
||||||
|
else "%.3f千克".format(displayWeight / 1000.0)
|
||||||
startTime = System.currentTimeMillis()
|
startTime = System.currentTimeMillis()
|
||||||
window.decorView.postDelayed({ Loading.dismiss() }, 1000)
|
window.decorView.postDelayed({ Loading.dismiss() }, 1000)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,10 +43,12 @@ class ShelfV3Adapter(list: MutableList<SlotModel>) :
|
|||||||
binding.tvShelfName.text = item.slotNo.padStart(2, '0')
|
binding.tvShelfName.text = item.slotNo.padStart(2, '0')
|
||||||
|
|
||||||
val weightG = item.weight ?: 0.0
|
val weightG = item.weight ?: 0.0
|
||||||
|
// 负漂移抑制:空秤零点可能出现 -5克以内的负读数,显示时归零
|
||||||
|
val displayG = if (weightG in -0.005..0.0) 0.0 else weightG
|
||||||
binding.tvFoodWeight.run {
|
binding.tvFoodWeight.run {
|
||||||
setTextColor(getColor(R.color.food_weight_orange))
|
setTextColor(getColor(R.color.food_weight_orange))
|
||||||
text = if (abs(weightG) >= 1.0) "%.3f千克".format(weightG)
|
text = if (abs(displayG) >= 1.0) "%.3f千克".format(displayG)
|
||||||
else "${(weightG * 1000.0).toInt()}克"
|
else "${(displayG * 1000.0).toInt()}克"
|
||||||
}
|
}
|
||||||
|
|
||||||
val isBlank = item.materName.isNullOrBlank()
|
val isBlank = item.materName.isNullOrBlank()
|
||||||
|
|||||||
+2
-2
@@ -4,5 +4,5 @@
|
|||||||
# Location of the SDK. This is only used by Gradle.
|
# Location of the SDK. This is only used by Gradle.
|
||||||
# For customization when using a Version Control System, please read the
|
# For customization when using a Version Control System, please read the
|
||||||
# header note.
|
# header note.
|
||||||
#Fri Jun 26 09:17:18 CST 2026
|
#Thu Jul 02 16:04:28 CST 2026
|
||||||
sdk.dir=D\:\\Android\\sdk
|
sdk.dir=C\:\\Users\\MZF\\AppData\\Local\\Android\\Sdk
|
||||||
|
|||||||
Reference in New Issue
Block a user