PiSupply / PaPiRus

Resources for PaPiRus ePaper eInk displays
https://www.pi-supply.com/product/papirus-epaper-eink-screen-hat-for-raspberry-pi/
Other
346 stars 88 forks source link

Looking to convert this to ruby #150

Open EddWills95 opened 6 years ago

EddWills95 commented 6 years ago

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 commented 6 years ago

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

EddWills95 commented 6 years ago

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 commented 6 years ago

@tvoverbeek or @francesco-vannini do you have any tips? Since you have both been playing with PaPiRus a lot more than me recently.

On Tue, Sep 5, 2017 at 11:35 AM, Edd Williams notifications@github.com wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/150#issuecomment-327137834, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCuj3Rh7JDR3agpErLJiVrgW2YE4Ptks5sfSP0gaJpZM4PMSed .

EddWills95 commented 6 years ago

checkout the dev branch i’ve set up.

The problem I was having was converting a picture into proper Hex Bytecode and then writing that to the appropriate file.

Then calling the update function.

I got it to actually put some black dots onto the screen but much beyond that couldn’t get it to work. The byte code always seems scrambled no matter how I tried to call it.

Best of luck and if you have any progress I’ll see what I can do to help. Edd.

On 1 Oct 2017, at 12:06, Mischa Molhoek notifications@github.com wrote:

Hi @EddWills95 https://github.com/eddwills95, can you share the code you have untill now? I might have a look at it to see if I can make it work. i cloned your project papiruby https://github.com/EddWills95/PaPiRuby, but it seems to be an empty shell.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/150#issuecomment-333369196, or mute the thread https://github.com/notifications/unsubscribe-auth/AUH_Ts3bLLlavDsO-i9aiNSS6Po24KRFks5sn3I6gaJpZM4PMSed.

mmolhoek commented 6 years ago

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 commented 6 years ago

Nice one. All the best mate :D

On 1 Oct 2017, at 12:29, Mischa Molhoek notifications@github.com wrote:

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 :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/150#issuecomment-333370308, or mute the thread https://github.com/notifications/unsubscribe-auth/AUH_TnVofzlQVGDZctdClpeNmgWyZA9Uks5sn3ekgaJpZM4PMSed.

shawaj commented 6 years ago

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

EddWills95 commented 6 years ago

Brilliant. Hopefully we can get somewhere with it and take some steps forward with the Ruby RasPi community :)

Edd.

On 1 Oct 2017, at 19:45, Aaron Shaw notifications@github.com wrote:

@EddWills95 https://github.com/eddwills95 @mmolhoek https://github.com/mmolhoek FYI, I have now added this ruby repo to the readme - https://github.com/PiSupply/PaPiRus/blob/master/README.md https://github.com/PiSupply/PaPiRus/blob/master/README.md — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/150#issuecomment-333397560, or mute the thread https://github.com/notifications/unsubscribe-auth/AUH_TgYk2Jopr8IvPAw3peDog3I951Erks5sn93jgaJpZM4PMSed.

mmolhoek commented 6 years ago

HI Aaron,

I think it is a bit to soon to add it to the library, as it is not working yet. I think people expect something working, if you put it in the readme :)

anyway, I am happy to join/help :) lets see if we can get it somewhere, but don't get your hope up to much as I have little time to spent and many projects to spend it on :)

but who knows...

Mischa

On 1 October 2017 at 20:45, Aaron Shaw notifications@github.com wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/150#issuecomment-333397560, or mute the thread https://github.com/notifications/unsubscribe-auth/AACbasS8iIr5gMiZFKtGIvX5Mt7JzImNks5sn93jgaJpZM4PMSed .

shawaj commented 6 years ago

The reason for putting it in the readme is also so others could see it and maybe provide some help :-)

On 2 Oct 2017 12:57, "Mischa Molhoek" notifications@github.com wrote:

HI Aaron,

I think it is a bit to soon to add it to the library, as it is not working yet. I think people expect something working, if you put it in the readme :)

anyway, I am happy to join/help :) lets see if we can get it somewhere, but don't get your hope up to much as I have little time to spent and many projects to spend it on :)

but who knows...

Mischa

On 1 October 2017 at 20:45, Aaron Shaw notifications@github.com wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/150#issuecomment-333397560, or mute the thread https://github.com/notifications/unsubscribe-auth/ AACbasS8iIr5gMiZFKtGIvX5Mt7JzImNks5sn93jgaJpZM4PMSed .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/150#issuecomment-333490969, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCup8OUNaUS535R7lctGrD61D_RGFUks5soLOVgaJpZM4PMSed .

mmolhoek commented 6 years ago

@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 commented 6 years ago

Oh Fantastic !

https://github.com/EddWills95/PaPiRuby/tree/chunky_png

Theres the branch so throw a merge up there :)

On 4 Oct 2017, at 11:00, Mischa Molhoek notifications@github.com wrote:

@EddWills95 https://github.com/eddwills95, I have made a version that works using the chunky_png https://github.com/wvanbergen/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 https://github.com/shawaj , 👍 .

ps: Special thanks to @wvanbergen https://github.com/wvanbergen of chunky_png for his help with the bit shifting 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/150#issuecomment-334107908, or mute the thread https://github.com/notifications/unsubscribe-auth/AUH_TlnqHJ4wAGTWu2_iZzqlfYQHeUNnks5so1chgaJpZM4PMSed.