This commit is contained in:
2025-09-19 09:15:44 +08:00
parent c1d4263473
commit 0540879551
3 changed files with 19 additions and 5 deletions
@@ -12,6 +12,9 @@ typealias WeightCallback = (address: Int, state: Int, weight: Double) -> Unit
object WeightUtil {
private const val TAG = "WeightUtil"
const val STATE_STABLE = SensorScale.STATE_STABLE
const val STATE_UNSTABLE = SensorScale.STATE_UNSTABLE
const val STATE_OVER_WEIGHT = SensorScale.STATE_OVER_WEIGHT
var isConnected = false
var weightFuncMap: MutableMap<String, WeightCallback?>? =
@@ -28,9 +31,9 @@ object WeightUtil {
override fun onGetWeight(address: Int, state: Int, weight: Double) {
super.onGetWeight(address, state, weight)
val stateStr = when (state) {
SensorScale.STATE_STABLE -> "稳定"
SensorScale.STATE_UNSTABLE -> "不稳定"
SensorScale.STATE_OVER_WEIGHT -> "量程溢出"
STATE_STABLE -> "稳定"
STATE_UNSTABLE -> "不稳定"
STATE_OVER_WEIGHT -> "量程溢出"
else -> "$state"
}
val useWeight = (weight*1000).roundedOneDecimalPlace()