26 lines
564 B
Text
26 lines
564 B
Text
|
|
-- DreamStack Streaming Clock
|
||
|
|
-- Streams time signals every second.
|
||
|
|
-- Only hours, minutes, seconds are exposed (tick is internal).
|
||
|
|
--
|
||
|
|
-- Run with:
|
||
|
|
-- dreamstack stream examples/streaming-clock.ds --port 3002
|
||
|
|
|
||
|
|
let tick = 0
|
||
|
|
let seconds = tick % 60
|
||
|
|
let minutes = (tick / 60) % 60
|
||
|
|
let hours = (tick / 3600) % 24
|
||
|
|
|
||
|
|
stream clock on "ws://localhost:9100/peer/clock" {
|
||
|
|
mode: signal,
|
||
|
|
output: hours, minutes, seconds
|
||
|
|
}
|
||
|
|
|
||
|
|
every 1000 -> tick += 1
|
||
|
|
|
||
|
|
view clock =
|
||
|
|
column [
|
||
|
|
text "🕐 Streaming Clock"
|
||
|
|
text "{hours}:{minutes}:{seconds}"
|
||
|
|
text "tick: {tick}"
|
||
|
|
]
|