-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from SquidSinker/SS/example
Add example for environment sensors!
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# ## Environmental sensors with the SenseHat | ||
# ### Reads and displays temperature, humidity and pressure. | ||
|
||
using SenseHat | ||
|
||
# Create channel to store stick events | ||
c = Channel{StickEvent}(32) | ||
@async while true | ||
# Push every event into the channel | ||
put!(c, readstick()) | ||
end | ||
|
||
while true | ||
# Retrieve events from channel | ||
ev = take!(c) | ||
if ev.direc == SenseHat.Stick.MIDDLE && ev.state == SenseHat.Stick.PRESS | ||
# Flash the Julia logo on the display | ||
LED[:] = SenseHat.JULIA_LOGO; sleep(1); led_clear() | ||
# Display atmospheric pressure | ||
show_message(string("P R E S S U R E:", round(Int, pressure()), "mb"), 0.08, colorant"purple") | ||
# Display temperature | ||
show_message(string("T E M P E R A T U R E:", round(Int, temperature()), "C"), 0.08, colorant"red") | ||
# Display humidity | ||
show_message(string("H U M I D I T Y:", round(Int, humidity()), "%"), 0.08, colorant"blue") | ||
end | ||
end |