NiLuJe / FBInk

FrameBuffer eInker, a small tool & library to print text & images to an eInk Linux framebuffer
https://www.mobileread.com/forums/showthread.php?t=299110
GNU General Public License v3.0
332 stars 23 forks source link

Does not work on non-interactive shell #32

Closed parkerlreed closed 5 years ago

parkerlreed commented 5 years ago

It fails to clear the screen and hangs at the end (leaving the connection open)

Works fine when in interactive. Kindle 4 non-touch

[parker@stealth ~]$ ssh root@192.168.86.125 fbink -c
root@192.168.86.125's password: 
[FBInk] Enabled Legacy einkfb Kindle quirks
[FBInk] Clock tick frequency appears to be 100 Hz
[FBInk] Screen density set to 167 dpi
[FBInk] Variable fb info: 600x800, 8bpp @ rotation: 0 (Upright, 0°)
[FBInk] Fontsize set to 16x16 (IBM base glyph size: 8x8)
[FBInk] Line length: 37 cols, Page size: 50 rows
[FBInk] Fixed fb info: ID is "eink_fb", length of fb mem: 966656 bytes & line length: 600 bytes
[FBInk] Pen colors set to #000000 -> #FFFFFF for the foreground and #FFFFFF -> #000000 for the background
NiLuJe commented 5 years ago

Yeah, it's expecting to read from stdin when stdin is not a tty.

You'll have to pass an empty string if you want a clear over a non-interactive shell.

NiLuJe commented 5 years ago

(I'm away for a week, so this is an AFAIR answer for now ;)).

parkerlreed commented 5 years ago

And just like that, you bring the idea to life :D

https://www.youtube.com/watch?v=p3Jv77gtLNk

parkerlreed commented 5 years ago

Here's the code (I added c to clear the screen)

from tkinter import *
import paramiko

hostname = '192.168.86.125'
password = 'password'
username = 'root'

root = Tk()

def key(event):
    stdin, stdout, stderr = ssh.exec_command("echo '' | fbink -c")

def onLeftDrag(event):
    stdin, stdout, stderr = ssh.exec_command("echo '' | fbink -g file=/mnt/us/circle.png,x=" + str(event.x) + ",y=" + str(event.y) + " -x 0 -y 0")

frame = Frame(root, width=600, height=800)
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.connect(hostname, username=username, password=password)
stdin, stdout, stderr = ssh.exec_command("echo '' | fbink -c")

frame.focus_set()
frame.bind('<B1-Motion>', onLeftDrag)
frame.bind('<c>', key)
frame.pack()

root.mainloop()

ssh.close()
NiLuJe commented 5 years ago

I'll take a closer look at it when I get back next week, because it probably shouldn't hang with no input, at the very least ;)

On Mon, Feb 25, 2019, 06:51 parkerlreed notifications@github.com wrote:

Here's the code (I addec c to clear the screen)

from tkinter import * import paramiko

hostname = '192.168.86.125' password = 'password' username = 'root'

root = Tk()

def key(event): stdin, stdout, stderr = ssh.exec_command("echo '' | fbink -c")

def onLeftDrag(event): stdin, stdout, stderr = ssh.exec_command("echo '' | fbink -g file=/mnt/us/circle.png,x=" + str(event.x) + ",y=" + str(event.y) + " -x 0 -y 0")

frame = Frame(root, width=600, height=800) ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.connect(hostname, username=username, password=password) stdin, stdout, stderr = ssh.exec_command("echo '' | fbink -c")

frame.focus_set() frame.bind('', onLeftDrag) frame.bind('', key) frame.pack()

root.mainloop()

ssh.close()

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NiLuJe/FBInk/issues/32#issuecomment-466880714, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG1Zh5tgyJa2jaaYl3A0IvJu1qXp7x9ks5vQ3nrgaJpZM4bOEcA .

NiLuJe commented 5 years ago

Note that you could also go with the Python bindings for this sort of stuff ;).

I'd even recommend using A2 updates for stuff like that to make it slightly more reactive, but you currently can't with the image drawing API, I need to tweak that to make it possible ;).

On Mon, Feb 25, 2019, 12:11 NiLuJe ninuje@gmail.com wrote:

I'll take a closer look at it when I get back next week, because it probably shouldn't hang with no input, at the very least ;)

On Mon, Feb 25, 2019, 06:51 parkerlreed notifications@github.com wrote:

Here's the code (I addec c to clear the screen)

from tkinter import * import paramiko

hostname = '192.168.86.125' password = 'password' username = 'root'

root = Tk()

def key(event): stdin, stdout, stderr = ssh.exec_command("echo '' | fbink -c")

def onLeftDrag(event): stdin, stdout, stderr = ssh.exec_command("echo '' | fbink -g file=/mnt/us/circle.png,x=" + str(event.x) + ",y=" + str(event.y) + " -x 0 -y 0")

frame = Frame(root, width=600, height=800) ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.connect(hostname, username=username, password=password) stdin, stdout, stderr = ssh.exec_command("echo '' | fbink -c")

frame.focus_set() frame.bind('', onLeftDrag) frame.bind('', key) frame.pack()

root.mainloop()

ssh.close()

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NiLuJe/FBInk/issues/32#issuecomment-466880714, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG1Zh5tgyJa2jaaYl3A0IvJu1qXp7x9ks5vQ3nrgaJpZM4bOEcA .

NiLuJe commented 5 years ago

Okay, the stdin / non-interactive SSH session issue should (mostly) be fixed. For your specific use-cases, no need to pass an empty string anymore :).

And I just added support for specifying a waveform mode when printing an image ;).

That'll make it into 1.12.0, which I'll be releasing later tonight.

Thanks!

parkerlreed commented 5 years ago

:D just got around to testing it IMG_20190416_144510

Didn't need the echo. Cheers!

NiLuJe commented 5 years ago

Fantastic, thanks for the confirmation ;).

parkerlreed commented 5 years ago

Quick question. Let's just say someone killed a lot of unnecessary processes and wants to throw an image on the display...

image

fbink still works but I lose rotation (since that was being handled by the main application)

I don't see a rotate option in fbink. Is this possible?

parkerlreed commented 5 years ago
echo 14 3 > /proc/eink_fb/update_display

Mostly works but has some weird artifacting towards the top of the image

NiLuJe commented 5 years ago

I don't remember if there's a /sys/class/graphics/fb0/rotate on the K4, and whether it behaves sanely ;).

Otherwise, it's done via ioctl, cf. rota.c in utils ;).

NiLuJe commented 5 years ago

It may be weirder on the K4, because it's using a legacy einkfb shim, while actually being mxcfb under the hood...

NiLuJe commented 5 years ago

i.e., instead of/in addition to the standard Linux fb ioctl, there's the einkfb one here, which apparently matches what you did via procfs.

I've never played with rotation on Kindle, as it's always been sane (i.e., origin at (0, 0) on the top-left) in my usual use cases ;).

I can just say that the K4 may be quirkier than other Kindles in that respect, because of the einkfb-on-top-of-mxcfb thing (as it's essentially a Kindle Touch masquerading as a Kindle 3).

NiLuJe commented 5 years ago

I wouldn't even know how to mess rotation up, as I don't think the framework touches it, since I'm fairly sure I print stuff with the framework down during MRPI sessions...