fixing timestamp
This commit is contained in:
parent
6cdf83a3cc
commit
b6bd946d9a
@ -51,6 +51,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private lateinit var tempCircle: TextView
|
private lateinit var tempCircle: TextView
|
||||||
private lateinit var humCircle: TextView
|
private lateinit var humCircle: TextView
|
||||||
|
|
||||||
|
private var startTime: Long = 0L
|
||||||
|
|
||||||
private val isTesting = true
|
private val isTesting = true
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -139,6 +141,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
bluetoothSocket?.inputStream ?: return
|
bluetoothSocket?.inputStream ?: return
|
||||||
}
|
}
|
||||||
val reader = BufferedReader(InputStreamReader(inputStream))
|
val reader = BufferedReader(InputStreamReader(inputStream))
|
||||||
|
startTime = System.currentTimeMillis()
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
@ -152,7 +155,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val hum = parts[1].toFloatOrNull()
|
val hum = parts[1].toFloatOrNull()
|
||||||
|
|
||||||
if (temp != null && hum != null) {
|
if (temp != null && hum != null) {
|
||||||
val reading = SensorReading(System.currentTimeMillis(), temp, hum)
|
val reading = SensorReading(
|
||||||
|
secSinceStart = (System.currentTimeMillis() - startTime) / 1000,
|
||||||
|
temperature = temp,
|
||||||
|
humidity = hum
|
||||||
|
)
|
||||||
sensorHistory.add(reading)
|
sensorHistory.add(reading)
|
||||||
Log.d(tag, "Store: $reading")
|
Log.d(tag, "Store: $reading")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user