diff --git a/app/src/main/java/com/casic/app/safetreecontroller/extensions/ByteArray.kt b/app/src/main/java/com/casic/app/safetreecontroller/extensions/ByteArray.kt
index b1cf8ae..521ed15 100644
--- a/app/src/main/java/com/casic/app/safetreecontroller/extensions/ByteArray.kt
+++ b/app/src/main/java/com/casic/app/safetreecontroller/extensions/ByteArray.kt
@@ -32,15 +32,31 @@
* [1, 0, 0, 0, 13, 14]
* */
//负值需要计算补码
- val x = this[1] and 0xFF.toByte()
- val y = this[2] and 0xFF.toByte()
- val z = this[3] and 0xFF.toByte()
+ val x = if (this[1] < 0) {
+ this[1].toInt() and 0xFF
+ } else {
+ this[1].toInt()
+ }
+ val y = if (this[2] < 0) {
+ this[2].toInt() and 0xFF
+ } else {
+ this[2].toInt()
+ }
+ val z = if (this[3] < 0) {
+ this[3].toInt() and 0xFF
+ } else {
+ this[3].toInt()
+ }
return (x * 65536 + y * 256 + z)
}
fun ByteArray.handleCpuTemperature(): Float {
//[1, -128, 24]
val x = this[0] and 0xFF.toByte()
- val y = this[1] and 0xFF.toByte()
+ val y = if (this[1] < 0) {
+ this[1].toInt() and 0xFF
+ } else {
+ this[1].toInt()
+ }
return (x * 256 + y) / 10f
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/safetreecontroller/extensions/ByteArray.kt b/app/src/main/java/com/casic/app/safetreecontroller/extensions/ByteArray.kt
index b1cf8ae..521ed15 100644
--- a/app/src/main/java/com/casic/app/safetreecontroller/extensions/ByteArray.kt
+++ b/app/src/main/java/com/casic/app/safetreecontroller/extensions/ByteArray.kt
@@ -32,15 +32,31 @@
* [1, 0, 0, 0, 13, 14]
* */
//负值需要计算补码
- val x = this[1] and 0xFF.toByte()
- val y = this[2] and 0xFF.toByte()
- val z = this[3] and 0xFF.toByte()
+ val x = if (this[1] < 0) {
+ this[1].toInt() and 0xFF
+ } else {
+ this[1].toInt()
+ }
+ val y = if (this[2] < 0) {
+ this[2].toInt() and 0xFF
+ } else {
+ this[2].toInt()
+ }
+ val z = if (this[3] < 0) {
+ this[3].toInt() and 0xFF
+ } else {
+ this[3].toInt()
+ }
return (x * 65536 + y * 256 + z)
}
fun ByteArray.handleCpuTemperature(): Float {
//[1, -128, 24]
val x = this[0] and 0xFF.toByte()
- val y = this[1] and 0xFF.toByte()
+ val y = if (this[1] < 0) {
+ this[1].toInt() and 0xFF
+ } else {
+ this[1].toInt()
+ }
return (x * 256 + y) / 10f
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_base_settings.xml b/app/src/main/res/layout/fragment_base_settings.xml
index a61dd66..229a59d 100644
--- a/app/src/main/res/layout/fragment_base_settings.xml
+++ b/app/src/main/res/layout/fragment_base_settings.xml
@@ -212,6 +212,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/dp_55"
android:layout_marginHorizontal="@dimen/dp_20"
+ android:layout_marginBottom="@dimen/dp_10"
android:text="更新WiFi配置" />
-
-
+
+
\ No newline at end of file