28 lines
788 B
Kotlin
28 lines
788 B
Kotlin
|
|
import dev.asdf00.visionfive.hc.GlobalDataStore
|
|
import dev.asdf00.visionfive.hc.control.PidController
|
|
import java.util.*
|
|
|
|
|
|
fun main() {
|
|
val pid = PidController()
|
|
var myTime = 0
|
|
while (true) {
|
|
print("provide current temp (at ${
|
|
Calendar.getInstance().also {
|
|
it.set(Calendar.HOUR_OF_DAY, 0)
|
|
it.set(Calendar.MINUTE, 0)
|
|
it.set(Calendar.SECOND, 0)
|
|
it.add(Calendar.MINUTE, myTime)
|
|
}.time
|
|
}): ")
|
|
val t = readln()
|
|
if (t.isEmpty()) {
|
|
break
|
|
}
|
|
val nu = pid.step(t.toDouble(), GlobalDataStore.targetTemp)
|
|
println("setting the valves to ${(nu * 10_000).toInt().toDouble() / 100}%")
|
|
myTime += 2
|
|
}
|
|
println("bye ...")
|
|
} |