Skip to content

Commit

Permalink
fix ecg timestamp values not adjusted
Browse files Browse the repository at this point in the history
  • Loading branch information
aditydcp committed Jun 19, 2023
1 parent 2df6034 commit f970487
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ class MainActivity : AppCompatActivity(), GoogleApiClient.ConnectionCallbacks,
this,
R.style.InverseTheme
)
dialog.setTitle(R.string.note_dialog_title)
dialog.setTitle(R.string.filename_dialog_title)
val viewInflated: View = LayoutInflater.from(applicationContext)
.inflate(R.layout.device_id_dialog, null, false)
val input = viewInflated.findViewById<EditText>(R.id.input)
Expand Down Expand Up @@ -1587,7 +1587,7 @@ class MainActivity : AppCompatActivity(), GoogleApiClient.ConnectionCallbacks,
("application=" + "SamplingApp Version: "
+ AppUtils.getVersion(this)) + "\n"
)
out.write("datatype=ECG")
out.write("datatype=ECG\n")
out.write(
"""
stoptime=${stopTime.toString()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import android.util.Log
import android.view.View
import com.androidplot.util.PixelUtils
import com.androidplot.xy.*
import com.example.samplewearmobileapp.Constants.NANO_TO_MICRO_SEC
import com.example.samplewearmobileapp.Constants.N_DOMAIN_LARGE_BOXES
import com.example.samplewearmobileapp.Constants.N_ECG_PLOT_POINTS
import com.example.samplewearmobileapp.Constants.N_LARGE
import com.example.samplewearmobileapp.Constants.N_TOTAL_VISIBLE_ECG_POINTS
import com.example.samplewearmobileapp.utils.AppUtils
import java.util.Date

class QrsPlotter: PlotterListener {
private lateinit var parentActivity: MainActivity
Expand Down Expand Up @@ -245,7 +247,8 @@ class QrsPlotter: PlotterListener {
seriesDataScores.addLast(dataIndex, score)
}
if (timestamp != null) {
seriesTimestamp.addLast(dataIndex, timestamp)
seriesTimestamp.addLast(dataIndex,
(NANO_TO_MICRO_SEC * timestamp).toLong().adjustEpoch())
}
dataIndex++
// Reset the domain boundaries
Expand Down Expand Up @@ -357,5 +360,9 @@ class QrsPlotter: PlotterListener {

companion object {
private const val TAG = "QrsPlotter"

private fun Long.adjustEpoch(): Long {
return this + Date(2000 - 1900, 0, 1).time
}
}
}

0 comments on commit f970487

Please sign in to comment.