Skip to content

Commit

Permalink
Add changes from @mikhailmihalkov adding support for Portrait 3
Browse files Browse the repository at this point in the history
See f9289c4#commitcomment-83310649
for mikhails comment, the source code is attached to the next comment.
  • Loading branch information
Jeinzi committed Sep 9, 2022
1 parent 900935a commit 296a59b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 27 deletions.
7 changes: 4 additions & 3 deletions file2graphtec
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import usb1
#

device_list = [
(0x0b4d, 0x1121), # Silhouette Cameo
(0x0b4d, 0x1123), # Silhouette Portrait
(0x0b4d, 0x1132) # Silhouette Portrait 2
# (0x0b4d, 0x1121), # Silhouette Cameo
# (0x0b4d, 0x1123), # Silhouette Portrait
# (0x0b4d, 0x1132), # Silhouette Portrait 2
(0x0b4d, 0x113a)

This comment has been minimized.

Copy link
@Jeinzi

Jeinzi Sep 9, 2022

Author Owner

@mikhailmihalkov Is there a problem with the other device IDs? It should still work with them included, or doesn't it?

This comment has been minimized.

Copy link
@mikhailmihalkov

mikhailmihalkov Sep 9, 2022

The problem is not in the ID for portrait 3 (0x0b4d, 0x113a) but at the beginning of cutting where the description of functions goes.... I commented on these lines...

]

def open_graphtec_device(ctx):
Expand Down
27 changes: 22 additions & 5 deletions g2g_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import os
import string
import time

from tkinter import *
from tkinter import filedialog
Expand Down Expand Up @@ -38,7 +39,7 @@
cutter_shared_name_text = ''

offset = (4,0.5)
border = (1,1)
border = (2,2)
matrix = (1,0,0,1)
speed = [2,2]
force = [8,30]
Expand Down Expand Up @@ -141,13 +142,13 @@ def main_program():
g.set(speed=s, force=f)
for x in lines:
g.line(*x)
g.closed_path(border_path)
#g.closed_path(border_path)
else:
for (s,f) in zip(speed,force):
g.set(speed=s, force=f)
for s in strokes:
g.closed_path(s)
g.closed_path(border_path)
#g.closed_path(border_path)

This comment has been minimized.

Copy link
@Jeinzi

Jeinzi Sep 9, 2022

Author Owner

@mikhailmihalkov Is there an important reason why you removed the border path? Does it work with it included?

This comment has been minimized.

Copy link
@mikhailmihalkov

mikhailmihalkov Sep 9, 2022

Yes, it works in any position... Turned off for convenience


g.end()

Expand Down Expand Up @@ -192,7 +193,23 @@ def Send_to_Cutter():
if os.name=='nt':
os.system("copy /B \"%s\" \"%s\"" % (src, dst))
else:
print(src)
print(dst)
print("1 cat %s > %s" % (src, dst))
os.system("cat %s > %s" % (src, dst))
"""
time.sleep(5.1)
print("2 cat %s > %s" % (src, dst))
os.system("cat %s > %s" % (src, dst))
time.sleep(5.1)
print("3 cat %s > %s" % (src, dst))
os.system("cat %s > %s" % (src, dst))
time.sleep(5.1)
print("4 cat %s > %s" % (src, dst))
os.system("cat %s > %s" % (src, dst))
"""


def get_input_filename():
input_filename=tkinter.filedialog.askopenfilename(title='Select paste mask Gerber file', filetypes=[('Gerber File', '*.g*'),("All files", "*.*")] )
Expand All @@ -218,7 +235,7 @@ def default_offset_str():
offset_str.set("4.0,0.5")

def default_border_str():
border_str.set("1,1")
border_str.set("2,2")

def default_matrix_str():
matrix_str.set("1,0,0,1")
Expand Down Expand Up @@ -327,7 +344,7 @@ def default_cut_mode_str():
if not offset_text:
offset_text="4.0,0.5"
if not border_text:
border_text="1,1"
border_text="2,2"
if not matrix_text:
matrix_text="1,0,0,1"
if not speed_text:
Expand Down
10 changes: 7 additions & 3 deletions gerber2graphtec
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ import string
#

offset = (4,0.5)
border = (1,1)
border = (0,0)
matrix = (1,0,0,1)
speed = [2,2]
force = [8,30]
cut_mode = 0
input_filename = ''
media_size = (12,11)
#media_size = (12,11)
media_size = (11.7,8.3)
theta = 0

def floats(s):
Expand Down Expand Up @@ -110,6 +111,7 @@ g = graphtec.graphtec()

g.set(media_size=media_size)
g.set(offset=(offset[0]+border[0]+0.5,offset[1]+border[1]+0.5))

g.set(matrix=matrix)

g.start()
Expand All @@ -126,14 +128,15 @@ border_path = [
(-border[0], max_y+border[1])
]


if cut_mode==0:
lines = optimize.optimize(strokes, border)
for (s,f) in zip(speed,force):
g.set(speed=s, force=f)
for x in lines:
g.line(*x)
if border[0]!=0 or border[1]!=0:
g.closed_path(border_path)
g.closed_path(border_path)
else:
for (s,f) in zip(speed,force):
g.set(speed=s, force=f)
Expand All @@ -142,4 +145,5 @@ else:
if border[0]!=0 or border[1]!=0:
g.closed_path(border_path)


g.end()
34 changes: 18 additions & 16 deletions graphtec.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self):
self.scale = 2.54*200
self.offset = (4.0,0.5)
self.matrix = (1,0,0,1)
self.media_size = (12,11) # default of 12x11 inches
self.media_size = (11.7,8.3) # default of 12x11 inches

def emit(self, s):
self.fd.write(s)
Expand All @@ -23,32 +23,34 @@ def start(self):
page = ["media_size", int(self.scale*self.media_size[0]), int(self.scale*self.media_size[1])]
margintop = 500 # margins in device units
marginright = 320
self.emit("\x1b\x04") # initialize plotte
self.emit("\x1b\x05") # status request
#self.emit("\x1b\x04") # initialize plotte

This comment has been minimized.

Copy link
@mikhailmihalkov

mikhailmihalkov Sep 9, 2022

First place

This comment has been minimized.

Copy link
@mikhailmihalkov

mikhailmihalkov Sep 9, 2022

With this function turned on, the portrait 3 does not cut but becomes in the file transfer mode and stands (freezes

#self.emit("\x1b\x05") # status request
#receive() "0\x03"
self.emit("TT\x03") # home the cutter
self.emit("FG\x03") # query version
#self.emit("TT\x03") # home the cutter!!

This comment has been minimized.

Copy link
@mikhailmihalkov

mikhailmihalkov Sep 9, 2022

Second place and so on...

#self.emit("FG\x03") # query version!!
#receive() "CAMEO V1.10 \x03"
self.emit("FW" + papertype + "\x03")
#self.emit("FW" + papertype + "\x03") #!!
self.emit("FC18\x03")
self.emit("FY" + trackenhancing + "\x03")
self.emit("FN" + orientation + "\x03")
self.emit("FE0\x03")
self.emit("FY" + trackenhancing + "\x03") #!!--
self.emit("FN" + "0" + "\x03") #--------------------
#self.emit("FE0\x03") #!!
self.emit("TB71\x03")
#receive() " 0, 0\x03"
self.emit("FA\x03") # begin page definition
self.emit("FU" + str(page[2] - margintop) + "," + str(page[1] - marginright) + "\x03")
self.emit("FM1\x03") # ??
self.emit("TB50,1\x03") # ??
#self.emit("FA\x03") # begin page definition
self.emit("FU" + str(page[2] - margintop) + "," + str(page[1] - marginright) + "\x03") #калибровка
self.emit("FM0\x03") # ??
self.emit("TB50,0\x03") # ??------------------------------------
self.emit("FO" + str(page[2] - margintop) + "\x03") # feed command?
self.emit("&100,100,100,\\0,0,") # ??
self.emit("Z" + str(page[1]) + "," + str(page[2]) + ",L0,")

def end(self):
self.emit("&1,1,1,TB50,0\x03")
self.emit("FO0\x03") # feed the page out
self.emit("H,") # halt?

#self.emit("FO0\x03") # feed the page out
#self.emit("H.") # halt?
self.emit("L0.\\0,0.")
self.emit("M0,0.FN0")

This comment has been minimized.

Copy link
@Jeinzi

Jeinzi Sep 9, 2022

Author Owner

Where did you get those new commands (M0, L0) from?
Did you capture them in the log files you posted? Or did some other project document them?

This comment has been minimized.

Copy link
@Jeinzi

Jeinzi Sep 9, 2022

Author Owner

This comment has been minimized.

Copy link
@mikhailmihalkov

mikhailmihalkov Sep 9, 2022

These commands were taken from Yusb intercept in data transfer between Silhouette Studio and Portrait 3 pmonta/gerber2graphtec#21


def transform(self, x, y):
tx = self.matrix[0]*x + self.matrix[1]*y + self.offset[0]
ty = self.matrix[2]*x + self.matrix[3]*y + self.offset[1]
Expand Down

0 comments on commit 296a59b

Please sign in to comment.