Масштаб графиков

This commit is contained in:
Vineyro 2023-10-03 16:42:36 +07:00
parent 69c770de63
commit 0133326481
5 changed files with 22 additions and 5 deletions

View File

@ -13,8 +13,8 @@ android {
applicationId "llc.arma.ble" applicationId "llc.arma.ble"
minSdk 24 minSdk 24
targetSdk 33 targetSdk 33
versionCode 6 versionCode 7
versionName "1.2.6" versionName "1.2.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables { vectorDrawables {

View File

@ -25,6 +25,7 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.core.content.ContextCompat
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat import androidx.core.view.WindowCompat
import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.google.accompanist.permissions.ExperimentalPermissionsApi

View File

@ -48,7 +48,7 @@ class BleListContract {
data class Filter( data class Filter(
val name: String = "", val name: String = "",
val mac: String = "", val mac: String = "",
val rssi: ClosedFloatingPointRange<Float> = (-100f)..(-30f), val rssi: ClosedFloatingPointRange<Float> = (-100f)..(-10f),
val bleType: BleInfo.Type? = null val bleType: BleInfo.Type? = null
) )

View File

@ -244,8 +244,8 @@ fun Filter(
onValueChange = { onValueChange = {
onEvent(BleListContract.Event.OnRssiRangeChanged(it)) onEvent(BleListContract.Event.OnRssiRangeChanged(it))
}, },
valueRange = (-100f)..(-30f), valueRange = (-100f)..(-10f),
steps = 69, steps = 89,
colors = SliderDefaults.colors( colors = SliderDefaults.colors(
activeTickColor = MaterialTheme.colorScheme.primary, activeTickColor = MaterialTheme.colorScheme.primary,
inactiveTickColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.38f) inactiveTickColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.38f)

View File

@ -105,6 +105,8 @@ class ReadAccelerometerHistoryCallback(
private val resultTemperaturePackage: MutableList<Float> = mutableListOf() private val resultTemperaturePackage: MutableList<Float> = mutableListOf()
private val result = mutableListOf<List<UByte>>()
var expectedDataSize: Int? = null var expectedDataSize: Int? = null
override fun onCharacteristicRead( override fun onCharacteristicRead(
@ -152,6 +154,8 @@ class ReadAccelerometerHistoryCallback(
} else { } else {
Log.d("expected data size", value.get2byteUIntAt(0).toString())
val writeData = mutableListOf( val writeData = mutableListOf(
1.toByte(), 1.toByte(),
0.toByte(), 0.toByte(),
@ -169,6 +173,8 @@ class ReadAccelerometerHistoryCallback(
if(value[0] == 250.toByte()){ if(value[0] == 250.toByte()){
result.add(value.toUByteArray().toList())
bleMeasureInterval = value.get4byteUIntAt(4).toLong() bleMeasureInterval = value.get4byteUIntAt(4).toLong()
bleLastMeasureTime = value.get4byteUIntAt(8).toLong() bleLastMeasureTime = value.get4byteUIntAt(8).toLong()
bleRealTime = value.get4byteUIntAt(12).toLong() bleRealTime = value.get4byteUIntAt(12).toLong()
@ -178,12 +184,17 @@ class ReadAccelerometerHistoryCallback(
val nextPackageDataCount = value.get2byteUIntAt(2) val nextPackageDataCount = value.get2byteUIntAt(2)
val temperatureDataArray = value.toUByteArray().asList().subList(16, value.size) val temperatureDataArray = value.toUByteArray().asList().subList(16, value.size)
resultTemperaturePackage.addAll( resultTemperaturePackage.addAll(
temperatureDataArray.chunked(2).map { temperatureDataArray.chunked(2).map {
it.toUByteArray().toByteArray().get2byteShortAt().toFloat() it.toUByteArray().toByteArray().get2byteShortAt().toFloat()
}.toMutableList() }.toMutableList()
) )
Log.d("received data size", (temperatureDataArray.chunked(2).size).toString())
Log.d("next data size", nextPackageDataCount.toString())
expectedDataSize = nextPackageDataCount.toInt() + resultTemperaturePackage.size expectedDataSize = nextPackageDataCount.toInt() + resultTemperaturePackage.size
onResult(Result.success(ProgressState.Progress(0f / expectedDataSize!!.toFloat()))) onResult(Result.success(ProgressState.Progress(0f / expectedDataSize!!.toFloat())))
@ -223,6 +234,8 @@ class ReadAccelerometerHistoryCallback(
if (value[0] == 251.toByte()) { if (value[0] == 251.toByte()) {
result.add(value.toUByteArray().toList())
val nextPackageDataCount = value.get2byteUIntAt(2) val nextPackageDataCount = value.get2byteUIntAt(2)
val temperatureDataArray = value.toUByteArray().toList().subList(4, value.size) val temperatureDataArray = value.toUByteArray().toList().subList(4, value.size)
@ -232,6 +245,9 @@ class ReadAccelerometerHistoryCallback(
} }
) )
Log.d("received data size", (temperatureDataArray.chunked(2).size).toString())
Log.d("next data size", nextPackageDataCount.toString())
onResult(Result.success(ProgressState.Progress(resultTemperaturePackage.size.toFloat() / expectedDataSize!!.toFloat()))) onResult(Result.success(ProgressState.Progress(resultTemperaturePackage.size.toFloat() / expectedDataSize!!.toFloat())))
if (nextPackageDataCount != 0.toUInt()) { if (nextPackageDataCount != 0.toUInt()) {