Compare commits
No commits in common. "070c7228c3e76960aafc780d498b0de324cb6bca" and "30800059282564e76268ef40aec59b4d983cba35" have entirely different histories.
070c7228c3
...
3080005928
@ -21,6 +21,7 @@ import com.github.mikephil.charting.data.LineDataSet
|
|||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@ -50,8 +51,6 @@ 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?) {
|
||||||
@ -140,7 +139,6 @@ 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 {
|
||||||
@ -154,11 +152,7 @@ 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(
|
val reading = SensorReading(System.currentTimeMillis(), temp, hum)
|
||||||
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")
|
||||||
|
|
||||||
@ -192,7 +186,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
position = XAxis.XAxisPosition.BOTTOM
|
position = XAxis.XAxisPosition.BOTTOM
|
||||||
valueFormatter = object : ValueFormatter() {
|
valueFormatter = object : ValueFormatter() {
|
||||||
override fun getFormattedValue(value: Float): String? {
|
override fun getFormattedValue(value: Float): String? {
|
||||||
return "${value.toInt()}s"
|
val time = Date(value.toLong())
|
||||||
|
val format = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
||||||
|
return format.format(time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
granularity = 1f
|
granularity = 1f
|
||||||
@ -239,11 +235,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tempChart.data = LineData(tempSet)
|
tempChart.data = LineData(tempSet)
|
||||||
tempChart.notifyDataSetChanged()
|
|
||||||
tempChart.invalidate()
|
|
||||||
|
|
||||||
humChart.data = LineData(humSet)
|
humChart.data = LineData(humSet)
|
||||||
humChart.notifyDataSetChanged()
|
tempChart.invalidate()
|
||||||
humChart.invalidate()
|
humChart.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user