Fix graph view
This commit is contained in:
parent
ab1046fd61
commit
067b5e94eb
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<value>
|
||||
<entry key="app">
|
||||
<State />
|
||||
</entry>
|
||||
</value>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectMigrations">
|
||||
<option name="MigrateToGradleLocalJavaHome">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -13,8 +13,8 @@ android {
|
|||
applicationId "llc.arma.ble"
|
||||
minSdk 26
|
||||
targetSdk 34
|
||||
versionCode 22
|
||||
versionName "1.3.2"
|
||||
versionCode 23
|
||||
versionName "1.3.3"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import llc.arma.ble.app.ui.screen.inspection.accelerometer.view.AccelScaleEdit
|
|||
import llc.arma.ble.app.ui.screen.inspection.accelerometer.view.AccelSpectreEdit
|
||||
import llc.arma.ble.app.ui.screen.inspection.accelerometer.view.AccelViewEdit
|
||||
import llc.arma.ble.app.ui.screen.inspection.accelerometer.view.AccelerometerSpectre
|
||||
import llc.arma.ble.app.ui.screen.inspection.accelerometer.view.AccelerometerAccel
|
||||
import llc.arma.ble.app.ui.screen.inspection.accelerometer.view.AccelerometerRealtime
|
||||
import llc.arma.ble.app.ui.screen.inspection.accelerometer.view.AccelerometerHistory
|
||||
import llc.arma.ble.app.ui.screen.inspection.accelerometer.view.DisplayState
|
||||
import llc.arma.ble.app.ui.screen.inspection.accelerometer.view.HistoryEdit
|
||||
|
|
@ -94,7 +94,7 @@ fun AccelerometerScreen(
|
|||
|
||||
if (currentState is AccelerometerContract.State.Display) {
|
||||
bottomDialog.show {
|
||||
AccelerometerAccel(
|
||||
AccelerometerRealtime(
|
||||
ble = currentState.accelerometer.info,
|
||||
accelMode = currentState.accelViewMode,
|
||||
fftAxis = currentState.fftAxis,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package llc.arma.ble.app.ui.screen.inspection.accelerometer.view
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
|
|
@ -47,7 +48,7 @@ import llc.arma.ble.domain.usecase.FftViewMode
|
|||
import llc.arma.ble.domain.usecase.GetAccelerometerMeasureBySerialFlow
|
||||
|
||||
@Composable
|
||||
fun AccelerometerAccel(
|
||||
fun AccelerometerRealtime(
|
||||
ble: BleInfo,
|
||||
accelScale: AccelScale,
|
||||
accelMode: AccelViewMode,
|
||||
|
|
@ -196,55 +197,10 @@ fun Display(
|
|||
|
||||
val lastMeasure = state.measureHistory.lastOrNull()
|
||||
|
||||
if(lastMeasure is Ble.Accelerometer.RealtimePoint.Common) {
|
||||
Log.d("mode", lastMeasure.toString())
|
||||
|
||||
when(state.mode){
|
||||
ROTATIONS -> {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
|
||||
|
||||
Text(text = "Ось Y: ${lastMeasure.y}")
|
||||
|
||||
Column(
|
||||
modifier = Modifier.weight(1f),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
|
||||
Text(text = "Ось X: ${lastMeasure.x}")
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Angle(
|
||||
angle = lastMeasure.x,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
Text(text = "Ось Z:")
|
||||
Chart(
|
||||
chart = lineChart,
|
||||
chartModelProducer = zProducer,
|
||||
startAxis = startAxis(),
|
||||
bottomAxis = bottomAxis(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f),
|
||||
autoScaleUp = AutoScaleUp.None,
|
||||
diffAnimationSpec = tween(0),
|
||||
chartScrollSpec = rememberChartScrollSpec(
|
||||
initialScroll = InitialScroll.End,
|
||||
autoScrollCondition = AutoScrollCondition.OnModelSizeIncreased,
|
||||
autoScrollAnimationSpec = tween(0)
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
ANGLE -> {
|
||||
when(lastMeasure){
|
||||
is Ble.Accelerometer.RealtimePoint.Angle -> {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
|
|
@ -300,8 +256,76 @@ fun Display(
|
|||
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
is Ble.Accelerometer.RealtimePoint.Rotation -> {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
|
||||
|
||||
Text(text = "Ось Y: ${lastMeasure.tmp}")
|
||||
|
||||
Column(
|
||||
modifier = Modifier.weight(1f),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
|
||||
Text(text = "Ось X: ${lastMeasure.angle}")
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Angle(
|
||||
angle = lastMeasure.angle,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
Text(text = "Ось Z:")
|
||||
Chart(
|
||||
chart = lineChart,
|
||||
chartModelProducer = zProducer,
|
||||
startAxis = startAxis(),
|
||||
bottomAxis = bottomAxis(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f),
|
||||
autoScaleUp = AutoScaleUp.None,
|
||||
diffAnimationSpec = tween(0),
|
||||
chartScrollSpec = rememberChartScrollSpec(
|
||||
initialScroll = InitialScroll.End,
|
||||
autoScrollCondition = AutoScrollCondition.OnModelSizeIncreased,
|
||||
autoScrollAnimationSpec = tween(0)
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
is Ble.Accelerometer.RealtimePoint.Vibration -> {
|
||||
Column {
|
||||
|
||||
Text(text = "Вибрация:")
|
||||
|
||||
Chart(
|
||||
chart = lineChart,
|
||||
chartModelProducer = xProducer,
|
||||
startAxis = startAxis(),
|
||||
bottomAxis = bottomAxis(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f),
|
||||
autoScaleUp = AutoScaleUp.None,
|
||||
diffAnimationSpec = tween(0),
|
||||
chartScrollSpec = rememberChartScrollSpec(
|
||||
initialScroll = InitialScroll.End,
|
||||
autoScrollCondition = AutoScrollCondition.OnModelSizeIncreased,
|
||||
autoScrollAnimationSpec = tween(0)
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
is Ble.Accelerometer.RealtimePoint.Common -> {
|
||||
Column() {
|
||||
|
||||
Text(text = "Ось X:")
|
||||
|
|
@ -360,35 +384,8 @@ fun Display(
|
|||
)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
Column {
|
||||
|
||||
Text(text = "Вибрация:")
|
||||
|
||||
Chart(
|
||||
chart = lineChart,
|
||||
chartModelProducer = xProducer,
|
||||
startAxis = startAxis(),
|
||||
bottomAxis = bottomAxis(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f),
|
||||
autoScaleUp = AutoScaleUp.None,
|
||||
diffAnimationSpec = tween(0),
|
||||
chartScrollSpec = rememberChartScrollSpec(
|
||||
initialScroll = InitialScroll.End,
|
||||
autoScrollCondition = AutoScrollCondition.OnModelSizeIncreased,
|
||||
autoScrollAnimationSpec = tween(0)
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
null -> {}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
package llc.arma.ble.data
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Application
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.core.app.ActivityCompat
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
|
@ -95,7 +91,9 @@ fun getAccelerometerHistory(
|
|||
|
||||
while (nextPackageDataCount.toInt() != 0) {
|
||||
|
||||
val temperatureDataArray = if (value[0] == 250.toByte()) {
|
||||
Log.d("dataTable", "next package fata size $nextPackageDataCount")
|
||||
|
||||
val packageDataArray = if (value[0] == 250.toByte()) {
|
||||
|
||||
bleMeasureInterval = value.get4byteUIntAt(4).toLong()
|
||||
bleLastMeasureTime = value.get4byteUIntAt(8).toLong()
|
||||
|
|
@ -104,6 +102,14 @@ fun getAccelerometerHistory(
|
|||
lastMeasureSystemTime =
|
||||
System.currentTimeMillis() - ((bleRealTime - bleLastMeasureTime) * 1_000)
|
||||
|
||||
Log.d("dataTable",
|
||||
"bleMeasureInterval $bleMeasureInterval " +
|
||||
"bleLastMeasureTime $bleLastMeasureTime " +
|
||||
"bleRealTime $bleRealTime " +
|
||||
"lastMeasureSystemTime $lastMeasureSystemTime " +
|
||||
"data size ${value.toUByteArray().asList().subList(16, value.size).size}"
|
||||
)
|
||||
|
||||
value.toUByteArray().asList().subList(16, value.size)
|
||||
|
||||
} else {
|
||||
|
|
@ -116,7 +122,7 @@ fun getAccelerometerHistory(
|
|||
nextPackageDataCount = value.get2byteUIntAt(2)
|
||||
|
||||
resultPackage.addAll(
|
||||
temperatureDataArray.chunked(2).map {
|
||||
packageDataArray.chunked(2).map {
|
||||
it.toUByteArray().toByteArray().get2byteShortAt().toFloat()
|
||||
}.toMutableList()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package llc.arma.ble.data
|
||||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
|
|
|||
Loading…
Reference in New Issue