Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looking to convert this to ruby #150

Open
EddWills95 opened this issue Sep 4, 2017 · 12 comments
Open

Looking to convert this to ruby #150

EddWills95 opened this issue Sep 4, 2017 · 12 comments

Comments

@EddWills95
Copy link

EddWills95 commented Sep 4, 2017

Want to give the ruby crew some love on the rapsberry pi, i'm trying to have crack at a port

I'm stuck trying to convert an image to the bytecode that gets put inside the /dev/epd/LE/display_inverse file
If anyone knows of an effective way to do this in ruby it'd be great to get me on the way. Been struggling for a few days now.
File.readbin doesn't spit out the right thing for the screen to read it. I get random bits of text in there, parens and all sorts.

I think the key to this is what the .tobyte() method is doing. If anyone could point me in the right direction as to how i could replicate that in ruby it'd be great.

@shawaj
Copy link
Member

shawaj commented Sep 5, 2017

So you're trying to port the whole thing including the code at repaper/gratis repo to Ruby or just this python library?

@EddWills95
Copy link
Author

EddWills95 commented Sep 5, 2017

Just the python library. I think i'd go a bit mad trying to do the whole EPD library ;) I just think it'd be really cool to integrate this into a small rails app on the pi.

I feel like i'm close.
I can manipulate the image using MiniMagick (change to greyscale, bitdepth and the size). Save that file and then read it back in (not elegant at the moment. would just like to see it working)
File.binread(img_file)
gets me in the ball park of hexadecimal bytes. Then its just a question of writing those bytes to the file and then sending the command file the "U" Command.

I've had some luck with this but for some reason ruby scrambles some of the data when it comes in and while it does get the screen to print something its just random dots all over the place.

an extract of the File.binread:

#&')*)\x19\x1F-0-(0%()(\xFF\xDB\x00C\x01\a\a\a\n\b\n\x13\n\n\x13(\x1A\x16\x1A((((((((((((((((((((((((((((((((((((((((((((((((((\xFF\xC0\x00\

So i'm not too sure whats going on here.

Update: I think i've cleaned up the binary hexadecimal to a decent level, now struggling to write it to the file. (Update: File size issue.)

@shawaj
Copy link
Member

shawaj commented Sep 6, 2017 via email

@EddWills95
Copy link
Author

EddWills95 commented Oct 1, 2017 via email

@mmolhoek
Copy link
Contributor

mmolhoek commented Oct 1, 2017

yes, a saw the dev branch after commenting :), so removed my comment, but you saw it anyway :)

in the coming days/weeks I will be busy with my own PaPiRus (got the 2.0 and 2.7" screen)

As I am more accustomed to ruby then python, I would love to see a ruby library for controlling the PaPiRus.

Anyway, I'll create PR's if i have something to contribute :)

@EddWills95
Copy link
Author

EddWills95 commented Oct 1, 2017 via email

@shawaj
Copy link
Member

shawaj commented Oct 1, 2017

@EddWills95 @mmolhoek FYI, I have now added this ruby repo to the readme - https://github.com/PiSupply/PaPiRus/blob/master/README.md

@EddWills95
Copy link
Author

EddWills95 commented Oct 1, 2017 via email

@mmolhoek
Copy link
Contributor

mmolhoek commented Oct 2, 2017 via email

@shawaj
Copy link
Member

shawaj commented Oct 2, 2017 via email

@mmolhoek
Copy link
Contributor

mmolhoek commented Oct 4, 2017

@EddWills95,
I have made a version that works using the chunky_png library.
Could you create a chunky_png branch on your repo? then I will create a PR with this setup.
Please explain in the README of master that people can hop to the chunky_png branch to see the display in action :)

I still want to play with a version that uses Image Magick, as chunky_png has limited drawing tools, but that is for another day.
At least now there is something working available that other people can play with.

I commented the code, so you should be able to see what's going on.

@shawaj , 👍 .

ps: Special thanks to @wvanbergen of chunky_png for his help with the bit shifting 👍

@EddWills95
Copy link
Author

EddWills95 commented Oct 4, 2017 via email

@tvoverbeek tvoverbeek mentioned this issue Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants