fixing timestamp

This commit is contained in:
smayzy 2025-04-22 15:18:19 +02:00
parent 6cdf83a3cc
commit b6bd946d9a

View File

@ -51,6 +51,8 @@ class MainActivity : AppCompatActivity() {
private lateinit var tempCircle: TextView
private lateinit var humCircle: TextView
private var startTime: Long = 0L
private val isTesting = true
override fun onCreate(savedInstanceState: Bundle?) {
@ -139,6 +141,7 @@ class MainActivity : AppCompatActivity() {
bluetoothSocket?.inputStream ?: return
}
val reader = BufferedReader(InputStreamReader(inputStream))
startTime = System.currentTimeMillis()
while (true) {
try {
@ -152,7 +155,11 @@ class MainActivity : AppCompatActivity() {
val hum = parts[1].toFloatOrNull()
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)
Log.d(tag, "Store: $reading")