Only show a limited number of items in the calibration chart
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
parent
d2b5520cdd
commit
f9bf12b18b
3 changed files with 11 additions and 4 deletions
|
@ -12,6 +12,7 @@ class CalibrationActivity : BaseSensorActivity() {
|
||||||
private lateinit var calibrationValue: TextView
|
private lateinit var calibrationValue: TextView
|
||||||
private lateinit var chart: LineChart
|
private lateinit var chart: LineChart
|
||||||
private var data = ArrayList<Entry>()
|
private var data = ArrayList<Entry>()
|
||||||
|
private var valueIndex = 0f
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -26,9 +27,15 @@ class CalibrationActivity : BaseSensorActivity() {
|
||||||
|
|
||||||
override fun sensorValueReceived(magneticFieldStrength: Float) {
|
override fun sensorValueReceived(magneticFieldStrength: Float) {
|
||||||
calibrationValue.text = getString(R.string.calibration_value, magneticFieldStrength)
|
calibrationValue.text = getString(R.string.calibration_value, magneticFieldStrength)
|
||||||
data.add(Entry(data.size.toFloat(), magneticFieldStrength))
|
|
||||||
val dataSet = LineDataSet(data, "Test")
|
|
||||||
|
data.add(Entry(valueIndex, magneticFieldStrength))
|
||||||
|
data = ArrayList(data.takeLast(500))
|
||||||
|
|
||||||
|
val dataSet = LineDataSet(data, "Magnetic Field Strength")
|
||||||
chart.data = LineData(dataSet)
|
chart.data = LineData(dataSet)
|
||||||
chart.invalidate()
|
chart.invalidate()
|
||||||
|
|
||||||
|
valueIndex++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,7 @@ class ReceiveActivity : BaseSensorActivity() {
|
||||||
}
|
}
|
||||||
receiveValue.text = payload
|
receiveValue.text = payload
|
||||||
|
|
||||||
// TODO: CRC show and calculate if it's correct
|
|
||||||
if (packet.size >= 4 + (8 * payloadLength) + 8) {
|
if (packet.size >= 4 + (8 * payloadLength) + 8) {
|
||||||
// CRC Check
|
// CRC Check
|
||||||
val receivedCrc = listToInteger(packet.take(4 + (8 * payloadLength) + 8).takeLast(8))
|
val receivedCrc = listToInteger(packet.take(4 + (8 * payloadLength) + 8).takeLast(8))
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<string name="home_calibration_description">For finding the best spot to put your phone on, to get the best transmission, you can start the calibration process by clicking the following button.</string>
|
<string name="home_calibration_description">For finding the best spot to put your phone on, to get the best transmission, you can start the calibration process by clicking the following button.</string>
|
||||||
<string name="receive_button_label">Receive</string>
|
<string name="receive_button_label">Receive</string>
|
||||||
<string name="calibrate_button_label">Calibrate</string>
|
<string name="calibrate_button_label">Calibrate</string>
|
||||||
<string name="calibration_description">Open up the website and start the calibration mode. Put your Smartphone on different locations on the sending device and note the value below. The location with the highest value is the most optimal for data transmission.</string>
|
<string name="calibration_description">Open up the website and start the calibration mode.\nPut your Smartphone on different locations on the sending device and note the value below.\nThe location with the highest value is the most optimal for data transmission.</string>
|
||||||
<string name="receive_description">Currently listening for transmissions.\nThe text that was received so far is displayed below.</string>
|
<string name="receive_description">Currently listening for transmissions.\nThe text that was received so far is displayed below.</string>
|
||||||
<string name="restart_description">To start listening to a new message click the following button.</string>
|
<string name="restart_description">To start listening to a new message click the following button.</string>
|
||||||
<string name="restart_button_label">Restart</string>
|
<string name="restart_button_label">Restart</string>
|
||||||
|
|
Reference in a new issue