Weather display
You need: a computer, a Network Repeater, a Weather Station named sky and a Display Module named screen.
Program
Section titled “Program”This is the Weather board starter:
// Starter: Weather board (computer)// Shows the weather on the Display Module "screen" whenever it changes, using the Weather Station "sky".const sky = weather.named("sky")const screen = displays.named("screen")
// A function turns a Weather constant into a friendly sentence.fn describe(now) { if now is Weather.THUNDER { return "Storm! Stay inside." } else if now is Weather.RAIN { return "It's raining." } return "Clear skies."}
on startup { screen.write(describe(sky.weather()))}
on sky.weatherChanged(now, previous) { screen.write(describe(now))}How it works
Section titled “How it works”describeis a function: it takes a weather constant and gives back a sentence withreturn. Both handlers use it, so the sentences are written only once.sky.weather()reads the weather right now. At startup the screen shows it immediately.sky.weatherChanged(now, previous)runs when the weather changes.nowis the new weather, such asWeather.RAIN.screen.write(...)replaces the text on the screen.
Add the time
Section titled “Add the time”A screen has eight lines. Put the day number on the second line:
const sky = weather.named("sky")const screen = displays.named("screen")
on sky.dayStart { screen.setLine(1, "Day " + str(sky.time().day))}You can add these handlers to the starter program. setLine(1, ...) changes only the second line, because lines are
counted from 0.