55from usb .util import get_string
66from PIL import Image
77from struct import pack
8- from six import ensure_binary
98from six .moves import cStringIO as StringIO
109
1110
@@ -19,66 +18,78 @@ def write_jpg2frame(dev, pic):
1918 tdata = rawdata + b'\xff \x00 ' + pad * b'\x00 '
2019 # Syntax: write(self, endpoint, data, interface = None, timeout = None):
2120 endpoint = 0x02
22- dev .write (endpoint , tdata )
21+ # send to device in packages of = 2^16
22+ psize = 65536
23+ for p in range (int (len (tdata ) / psize )):
24+ pdata = tdata [p * psize :(p + 1 ) * psize ]
25+ dev .write (endpoint , pdata )
2326
2427
2528def get_known_devices ():
2629 # Return a dict of photo frames
2730 dlist = []
2831 # listed as: Name, idVendor, idProduct, [width , height - in pixel if applicable]
2932
30- #0,1 Samsung SPF-75H/76H (23)
33+ # 0,1 Samsung SPF-75H/76H (23)
3134 dlist .append ({'name' : "SPF75H/76H Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x200f , 'width' : 800 , 'height' : 480 })
3235 dlist .append ({'name' : "SPF75H/76H Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x200e })
3336
34- #2,3 Samsung SPF-87H (24)
37+ # 2,3 Samsung SPF-87H (24)
3538 dlist .append ({'name' : "SPF87H Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2034 , 'width' : 800 , 'height' : 480 })
3639 dlist .append ({'name' : "SPF87H Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2033 })
3740
38- #4,5 Samsung SPF-87Hold (25)
41+ # 4,5 Samsung SPF-87Hold (25)
3942 dlist .append ({'name' : "SPF87Hold Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2026 , 'width' : 800 , 'height' : 480 })
4043 dlist .append ({'name' : "SPF87Hold Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2025 })
4144
42- #6,7 Samsung SPF-83H (26)
45+ # 6,7 Samsung SPF-83H (26)
4346 dlist .append ({'name' : "SPF83H Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x200d , 'width' : 800 , 'height' : 600 })
4447 dlist .append ({'name' : "SPF83H Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x200c })
4548
46- #8,9 Samsung SPF-107H (27)
49+ # 8,9 Samsung SPF-107H (27)
4750 dlist .append ({'name' : "SPF107H Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2036 , 'width' : 1024 , 'height' : 600 })
4851 dlist .append ({'name' : "SPF107H Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2035 })
4952
50- #10,11 Samsung SPF-105P (28)
53+ # 10,11 Samsung SPF-105P (28)
5154 dlist .append ({'name' : "SPF105P Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x201b , 'width' : 1024 , 'height' : 600 })
5255 dlist .append ({'name' : "SPF105P Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x201c })
5356
54- #12,13 Samsung SPF-85H/86H (29)
57+ # 12,13 Samsung SPF-85H/86H (29)
5558 dlist .append ({'name' : "SPF85H/86H Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2013 , 'width' : 800 , 'height' : 600 })
5659 dlist .append ({'name' : "SPF85H/86H Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2012 })
5760
58- #14,15 Samsung SPF-72H (210)
61+ # 14,15 Samsung SPF-72H (210)
5962 dlist .append ({'name' : "SPF72H Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x200b , 'width' : 800 , 'height' : 480 })
6063 dlist .append ({'name' : "SPF72H Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x200a })
6164
62- #16,17 Samsung SPF-700T (211)
65+ # 16,17 Samsung SPF-700T (211)
6366 dlist .append ({'name' : "SPF700T Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2050 , 'width' : 800 , 'height' : 600 })
6467 dlist .append ({'name' : "SPF700T Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x204f })
6568
66- #18,19 Samsung SPF-85P/86P (212)
69+ # 18,19 Samsung SPF-85P/86P (212)
6770 dlist .append ({'name' : "SPF85P/86P Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2017 , 'width' : 800 , 'height' : 600 })
6871 dlist .append ({'name' : "SPF85P/86P Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2016 })
6972
70- #20,21 Samsung SPF-107Hold (213)
73+ # 20,21 Samsung SPF-107Hold (213)
7174 dlist .append ({'name' : "SPF107Hold Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2028 , 'width' : 1024 , 'height' : 600 })
7275 dlist .append ({'name' : "SPF107Hold Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2027 })
7376
74- #22,23 Samsung SPF-1000P (214)
77+ # 22,23 Samsung SPF-1000P (214)
7578 dlist .append ({'name' : "SPF1000P Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2040 , 'width' : 1024 , 'height' : 600 })
7679 dlist .append ({'name' : "SPF1000P Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2039 })
7780
78- #24,25 Samsung SPF-800P (215)
81+ # 24,25 Samsung SPF-800P (215)
7982 dlist .append ({'name' : "SPF800P Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2038 , 'width' : 800 , 'height' : 480 })
8083 dlist .append ({'name' : "SPF800P Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x2037 })
8184
85+ # 26,27 Samsung SPF-800W (216)
86+ dlist .append ({'name' : "SPF800W Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x204c , 'width' : 800 , 'height' : 600 })
87+ dlist .append ({'name' : "SPF800W Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x204b })
88+
89+ # 28,29 Samsung SPF-1000W (217)
90+ dlist .append ({'name' : "SPF1000W Mini Monitor" , 'idVendor' : 0x04e8 , 'idProduct' : 0x204e , 'width' : 1024 , 'height' : 768 })
91+ dlist .append ({'name' : "SPF1000W Mass Storage" , 'idVendor' : 0x04e8 , 'idProduct' : 0x204d })
92+
8293 # Amazon Fire 7 (9th Generation 2019)
8394 dlist .append ({'name' : "Amazon Fire 7 Mini Monitor" , 'idVendor' : 0x1949 , 'idProduct' : 0x03C3 , 'width' : 1024 , 'height' : 600 })
8495 dlist .append ({'name' : "Amazon Fire 7 Mass Storage" , 'idVendor' : 0x1949 , 'idProduct' : 0x03C1 })
@@ -115,7 +126,7 @@ def init_device(anzahl, device0, device1):
115126 dev = find_device (anzahl , device0 , device1 )
116127
117128 if dev is not None :
118- ## found it, trying to init it
129+ # found it, trying to init it
119130 print ("[LCD4linux] Find frame device: %s" % dev )
120131 if dev .idProduct == device0 ["idProduct" ]:
121132 print ("[LCD4linux] init Device" )
@@ -128,7 +139,7 @@ def init_device(anzahl, device0, device1):
128139 # may need to burn some time
129140 dev = find_device (anzahl , device0 , device1 )
130141 if dev is not None and dev .idProduct == device0 ["idProduct" ]:
131- #switching successful
142+ # switching successful
132143 break
133144 elif time () - ts > 3 :
134145 print ("[LCD4linux] switching failed. Ending program" )
@@ -195,7 +206,7 @@ def main():
195206 dev = init_device (1 , device0 , device1 )
196207 print ("Frame is in Mini Monitor mode and initialized. Sending pictures now" )
197208 image = Image .open ("mypicture.jpg" )
198- #manipulations to consider:
209+ # manipulations to consider:
199210 # convert
200211 # thumbnail
201212 # rotate
0 commit comments