View Single Post
Old 04-24-2012, 12:59 AM   #1
jmseight
Zealot
jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'jmseight knows the difference between 'who' and 'whom'
 
Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
eMonitor for Story HD - eReader as additional PC screen

[UPDATE] Newest version with several fixes - Please use version 5s.

Hi,

I modified the gtk version of the eMonitor program originally by kranu for Kindle to work on iRiver Story HD.
https://www.mobileread.com/forums/sho...d.php?t=148581

The SHD has 768x1024 display, and gives a much better experience than K3G.
This version has the screen rotated 90deg, and the Pixbuf made into grayscale. I also reduced the quality of the JPG to 50 to reduce refresh time.

You need to get Python 2.7.1, and PyGTK on the PC. The script runs on the PC.
No modification is required on the SHD. From the browser, just go to http://pc_ip_address:8000 (example: http://192.168.1.8:8000).
Please see the original thread for more details.

I test it on Windows 7 and works very well.

Please see the attached.

Code:
#!/usr/bin/python
#eMonitor by Kranu
#Version 2 (9-1-2011)

#modified by jmseight for iRiver Story HD (4-24-2012)
#  Rotate screen 90 deg
#  Made into grayscale image (original is color)
#  Reduce quality for faster load
#  Set to Story HD resolution


#Tested on Windows 7 x64, Python 2.7.2, wxPython 2.8
#For more information, see: http://goo.gl/rJoLp

#+---2-16-2012---+
#This is the same as v2
#Just using pygtk instead of wxWidgets. 
#Tested on Ubuntu

#BEGIN SETUP

#HTTP Server
port=8000              #port of http server (http://127.0.0.1:8000/)

#capture region
#l,t=(1680,1050-800)
l,t=(0,0)              #left and right offset from primary monitor
w,h=(1024,768)          #width and height of capture region
fn ='shot.jpg'         #file name of screenshot
quality = "50"

#//END SETUP

import pygtk, gtk, socket
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

class serv(BaseHTTPRequestHandler):
  def do_GET(self):
    self.send_response(200)
    if self.path.startswith('/'+fn):
      self.send_header('Content-type','image/jpeg')
      self.end_headers()
  
      screenshot =  gtk.gdk.Pixbuf.rotate_simple(
						gtk.gdk.Pixbuf.get_from_drawable(
							gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, w, h),
							gtk.gdk.get_default_root_window(),
							gtk.gdk.colormap_get_system(),
							l, l, 0, 0, w, h),
						gtk.gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE
					)

      screenshot.saturate_and_pixelate(screenshot, 0.0, False)
	  
      screenshot.save(fn, "jpeg", {"quality": quality})

      f=open(fn,'rb')
      self.wfile.write(f.read())
    else:
      self.send_header('Content-type','text/html')
      self.end_headers()
      self.wfile.write('<!doctype html>'\
        '<html lang="en">'\
        '<head>'\
        '<title>eMonitor by Kranu</title>'\
        '</head>'\
        '<body style="margin:0px;">'\
        '<img id="pic" src="'+fn+'" style="float:left;width:100%;height:100%;">'\
        '<script type="text/javascript">'\
        'document.getElementById("pic").onload=function() {'\
        '  document.getElementById("pic").src="'+fn+'?"+(new Date()).getTime();'\
        '}'\
        '</script>'\
        '</body>'\
        '</html>')
try:
  print 'eMonitor by Kranu'

  #Amazon's website is used here for its reliablity. Feel free to change it.
  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  s.connect(("amazon.com",80))

  print 'Starting.. ',
  server=HTTPServer(('',port),serv)
  print 'Press Ctrl+C to stop'
  print

  print 'On your Story HD, visit http://'+s.getsockname()[0]+':'+str(port)+'/'

  server.serve_forever()
except KeyboardInterrupt:
  print 'Stopping.. ',
  server.socket.close()
  print 'Have a nice day!'
Attached Files
File Type: zip SHD_webserver_v2.zip (1.5 KB, 523 views)

Last edited by jmseight; 04-26-2012 at 11:43 PM.
jmseight is offline   Reply With Quote