Skip to content

Commit b0bb07b

Browse files
committed
update
1 parent 62ffb4d commit b0bb07b

File tree

5 files changed

+21
-41
lines changed

5 files changed

+21
-41
lines changed

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ SenseHat.jl requires the Raspbian `sense-hat` package:
1010

1111
## LED matrix
1212

13-
The main interface is the `led_matrix()` function, which creates an 8×8 array of RGB values (from [ColorTypes.jl](https://github.com/JuliaGraphics/ColorTypes.jl)) which is memory-mapped to the frame buffer of the LED matrix.
13+
The main interface is the `led_matrix()` function, which creates an 8×8 array of RGB
14+
values (from [ColorTypes.jl](https://github.com/JuliaGraphics/ColorTypes.jl)) which is
15+
memory-mapped to the frame buffer of the LED matrix. `led_clear()` is a convenience
16+
function for resetting the LED matrix to black.
1417

1518
using SenseHat
1619
using ColorTypes
@@ -19,26 +22,31 @@ The main interface is the `led_matrix()` function, which creates an 8×8 ar
1922

2023
LED[:] = SenseHat.JULIA_LOGO
2124
sleep(3)
22-
LED[:] = RGB(0,0,0)
25+
led_clear()
2326

2427
## Joystick
2528

26-
In the `Stick` module there is `readstick()` which will block until the joystick is manipulated, returning a `StickEvent`:
29+
In the `Stick` module there is `readstick()` which will block until the joystick is
30+
manipulated, returning a `StickEvent`:
2731

2832
using SenseHat
2933

3034
e = readstick()
3135

32-
For asynchronous use, `sticktask()` will create a `Task` for producing `StickEvent`s, e.g.
36+
For querying within a loop, `sticktask()` will create a `Task` that produces `StickEvent`s. Use
37+
with `@schedule` for asynchronous use, e.g.
3338

3439
using SenseHat
3540

3641
@schedule for e in sticktask()
3742
println(e)
3843
end
3944

40-
will create a new task that prints the event, then and add it to the scheduler. See the help for `StickEvent` and `sticktask` for more details.
45+
will create a new task that prints the event, then and add it to the scheduler. See the
46+
help for `StickEvent` and `sticktask` for more details.
4147

4248
## Sensors
4349

44-
Coming soon: in the meantime, you can use the [python library](https://pythonhosted.org/sense-hat/) via [PyCall.jl](https://github.com/JuliaPy/PyCall.jl).
50+
`humidity()`, `temperature()` and `pressure()` will read values from the corresponding sensors.
51+
52+
The inertial measurement unit (IMU) is not yet supported, but is coming soon. In the meantime, you can use the [python library](https://pythonhosted.org/sense-hat/) via [PyCall.jl](https://github.com/JuliaPy/PyCall.jl).

src/SenseHat.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__precompile__()
22
module SenseHat
33

4-
export led_matrix, RGB565,
4+
export led_matrix, RGB565, led_clear,
55
Stick, StickEvent, sticktask, readstick,
66
pressure, temperature, humidity
77

src/led.jl

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module LED
22

33
import ..ioctl
44

5-
export led_matrix, RGB565
5+
export led_matrix, RGB565, led_clear
66

77
using ColorTypes, FixedPointNumbers
88

@@ -18,7 +18,7 @@ function _led_fb_device()
1818
end
1919
catch e
2020
end
21-
error("Sense Hat not found.")
21+
error("Sense Hat device not found.")
2222
end
2323

2424
const LED_FB_DEVICE_PATH = _led_fb_device()
@@ -127,30 +127,9 @@ end
127127
setgamma(table::AbstractVector) = setgamma(convert(Vector{U5}, table))
128128

129129

130-
131-
132-
"""
133-
led_display(X)
134-
135-
Display an image `X` on the SenseHat LED matrix.
136-
137-
`X` should be an 8×8 matrix of colors (see the ColorTypes.jl package).
138-
139-
See also:
140-
* `rotl90`, `rotr90` and `rot180` for rotating the image.
141-
* `flipdim` for reflecting the image.
142-
* `led_clear` for clearing the LED matrix.
143-
"""
144130
function led_display(X)
145131
Base.depwarn("`led_display(X)` has been deprecated, use `led_matrix()[:] = X` instead.", :led_display)
146-
size(X) == (8,8) || throw(DimensionMismatch("Can only display 8x8 images"))
147-
open(LED_FB_DEVICE, "w") do fb
148-
for j = 1:8
149-
for i = 1:8
150-
write(fb, convert(RGB565, X[i,j]).data)
151-
end
152-
end
153-
end
132+
led_matrix()[:] = X
154133
end
155134

156135
"""
@@ -159,14 +138,7 @@ end
159138
Sets the SenseHat LED matrix to all black.
160139
"""
161140
function led_clear()
162-
Base.depwarn("`led_clear()` has been deprecated, use `led_matrix()[:] = SenseHat.RGB565(0,0,0)` instead.", :led_display)
163-
open(LED_FB_DEVICE, "w") do fb
164-
for j = 1:8
165-
for i = 1:8
166-
write(fb, UInt16(0))
167-
end
168-
end
169-
end
141+
led_matrix()[:] = SenseHat.RGB565(0,0,0)
170142
end
171143

172144
end # module

src/led_extra.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ const JULIA_LOGO = begin
1414
z R R G G P P z;
1515
R r r R P p p P;
1616
R r r R P p p P;
17-
z R R z z P P z] |> rotl90 |> X -> flipdim(X,1)
17+
z R R z z P P z]' # transpose to correct orientation
1818
end

test/led.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ const LED = led_matrix()
77

88
LED[:] = SenseHat.JULIA_LOGO
99
sleep(3)
10-
LED[:] = RGB(0,0,0)
10+
led_clear()

0 commit comments

Comments
 (0)