Commit 916d890a authored by David's avatar David

Added the final countdown

parent 680161fe
......@@ -83,7 +83,8 @@ dependencies {
implementation 'com.github.Hopding:JRPiCam:1.1.1'
//Some extra java time classes that are potentially useful
implementation 'org.threeten:threeten-extra:1.5.0'
//Gonna use the DarkSky forecast info
implementation 'tk.plogitech:darksky-forecast-api-jackson:1.3.1',
'org.slf4j:jul-to-slf4j:1.7.25'
......
......@@ -17,12 +17,14 @@ import javafx.scene.shape.Rectangle
import javafx.scene.text.Text
import javafx.util.Duration
import mu.KotlinLogging
import org.threeten.extra.PeriodDuration
import tornadofx.*
import java.nio.file.Paths
import java.time.Clock
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.util.*
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.TimeUnit
import kotlin.random.Random
......@@ -84,6 +86,37 @@ class TickerView : View() {
override fun onDock() {
val DEGREE = "\u00b0"
//TODO: this stuff super needs to be in a controller
val quittinText = Text("14 Days 24 Hours 59 minutes 59 seconds remain.")
quittinText.layoutY = 20.0
quittinText.style {
fill = c("red")
}
val quittinTime = object : TickerEntry<Text>(title = "The Final Countdown", content = quittinText, reschedule = true) {
private val lastDay = LocalDateTime.of(2019, 4, 12, 16, 0)
override fun updateObservable(): Completable? {
return Observable.interval(0, 1, TimeUnit.SECONDS)
.observeOn(Schedulers.computation())
.map {
//Calculate the duration until last day
PeriodDuration.between(LocalDateTime.now(), lastDay)
}
.doOnNextFx {
val p = it.period
val d = it.duration
val hours = d.toHours()
val mins = d.toMinutes() % 60
val secs = d.seconds % 60
//val millis = d.nano / 1000000
content.text = "%d days, %02d hours, %02d minutes, %02d seconds remain.".format(p.days, hours, mins, secs)
}
.ignoreElements()
}
}
val currentTime = object : TickerEntry<Text>(title = "Time", content = createText("88:88:88"), reschedule = true) {
private val secondClock = Clock.tickSeconds(ZoneId.systemDefault())
private val formatter = DateTimeFormatter.ofPattern("HH:mm:ss")
......@@ -126,7 +159,8 @@ class TickerView : View() {
val entries = listOf(
currentTime,
cpuTemp
cpuTemp,
quittinTime
)
entries.forEach {
......@@ -170,10 +204,17 @@ class MarqueeView : View() {
startAnimation() //Fire up the animation process
}
//TODO: this should be in a controller
fun enqueueTickEntry(entry: TickerEntry<Node>) {
queuedTicks.add(entry)
}
fun dequeueTickEntry(entry: TickerEntry<Node>) {
//Find the queued tick, and set it's repeat to false
if (queuedTicks.contains(entry)) { //Not really a good way to do this
}
}
//Fire up the animation process for the ticker
private fun startAnimation() {
//If it's already cleared, don't keep checking
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment