优化
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user