JuliaBerry / SenseHat.jl

Julia package for the Raspberry Pi Sense HAT
Other
15 stars 12 forks source link

Roadmap #1

Open simonbyrne opened 7 years ago

simonbyrne commented 7 years ago

LED

Sensors

Kind of complex:

Should make use of Rotations.jl:

Ellipse0934 commented 6 years ago

I want to start working on the pixel font. How exactly will we store it ? Each character needs to be mapped to an 8x8 RGB565 Matrix. We'll easily get 100+ characters. What is the correct way to store data like this in a package ? Each mapping will look like JULIA_LOGO in src/led_extra.jl. I can do the entire printable ASCII set by 10th.

aviks commented 6 years ago

I'd say we should store the images as FixedPointNumber arrays. And then store these images into a Dict.

simonbyrne commented 6 years ago

If there is no antialiasing, it might be easiest to store each character as a BitMatrix, so the whole thing would be a Dict{Char, BitMatrix}.

Ellipse0934 commented 6 years ago

Right now if we have a 8x8 matrix of RGB which we want to display on the SenseHat led screen we must transpose it to view correctly. Why should a user be responsible for doing this every time ? Instead how about using led_display(x::Array{RGB565}(8,8)) as the main display function which will transpose x then display it.

simonbyrne commented 6 years ago

Yeah, I agree it's not ideal. Unfortunately it's due to how the buffer is laid out in memory. But this is a problem for all images.

We could have led_matrix() return a PermuteDimsArray?

Ellipse0934 commented 6 years ago

We could have led_matrix() return a PermuteDimsArray?

I don't understand what you mean by that.

simonbyrne commented 6 years ago

e.g. it would give what PermuteDimsArray(led_matrix(), (2,1)) currently does.

Ellipse0934 commented 6 years ago

Yes, that makes sense. Or we could hide the implementation details altogether and simply provide two functions: setDisplay() and getDisplay(). The simpler the library is the better due to the intended audience. I'll see what Python does tomorrow. In the meantime I would really appreciate if you could take the time to review PR #4.

simonbyrne commented 6 years ago

I personally really, really like being able to just assign pixels and have it change immediately.

Ellipse0934 commented 6 years ago

PermutedDimsArray makes perfect sense. However I would still like set_pixel() and set_display() functions. That way let these functions manage the flipping and rotation views. Let the led_matrix() stay for advanced users. led_matrix() = PermutedDimsArray(Mmap.mmap(....), (2,1)) seems to work fine.

simonbyrne commented 6 years ago

One idea I was thinking of was to allow optional arguments to led_matrix specifying the rotation/flipping. The downside is this would be type unstable, but with the constant propagation in 0.7 hopefully this won't be an issue.

Ellipse0934 commented 6 years ago

We can do that. Has there been any progress with the IMU sensor?

simonbyrne commented 6 years ago

No

simonbyrne commented 6 years ago

I should perhaps expand on that.

If you are interested in reading from the IMU, then perhaps the easiest option is to wrap https://github.com/RPi-Distro/RTIMULib (which I think is what Python uses).

Alternatively, you should be able to use the smbus interface, but this would require writing your own calibration and state tracker (RTIMULib uses a Kalman filter).

Ellipse0934 commented 5 years ago

Along with the PermutedDimsArray we need a rotation/flipping. How can one create a rotated reference for a 2-D array ? Essentially PermutedDimsArray but for rotr90. If A = [1 2; 3 4] then B = [3 1; 4 2], A and B need to be linked memory wise. The reason for this is that everyone has their own sense-hat orientation. I would bet that most people use it upside down as it is away from the hdmi connector that way.

simonbyrne commented 5 years ago

You can flip by creating a view with a reverse range, e.g.

@view LED[8:-1:1, :]

If I have my group theory right, I think all we need is flipping and permute dims, as we can get rotations from those: e.g. rotate 90 left would be:

LEDPC = @view PermutedDimsArray(LED, (2,1))[8:-1:1, :]
simonbyrne commented 5 years ago

It would be even better if we could use ImageAxes.jl somehow, as that has this sort of handling built in (though not this particular use case...)

Ellipse0934 commented 5 years ago

I only added orientation in PR #8. I didn't see any usefulness in flipping. Should I add it ?