Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
3de92320
Commit
3de92320
authored
Jun 29, 2011
by
Keegi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command "set" to store persistent variables for preferences
parent
e3dabb54
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
80 deletions
+176
-80
pronsole.py
pronsole.py
+175
-74
pronterface.py
pronterface.py
+1
-6
No files found.
pronsole.py
View file @
3de92320
...
@@ -19,6 +19,52 @@ except:
...
@@ -19,6 +19,52 @@ except:
def
dosify
(
name
):
def
dosify
(
name
):
return
os
.
path
.
split
(
name
)[
1
]
.
split
(
"."
)[
0
][:
8
]
+
".g"
return
os
.
path
.
split
(
name
)[
1
]
.
split
(
"."
)[
0
][:
8
]
+
".g"
class
Settings
:
#def _temperature_alias(self): return {"pla":210,"abs":230,"off":0}
#def _temperature_validate(self,v):
# if v < 0: raise ValueError("You cannot set negative temperatures. To turn the hotend off entirely, set its temperature to 0.")
#def _bedtemperature_alias(self): return {"pla":60,"abs":110,"off":0}
def
_baudrate_list
(
self
):
return
[
"2400"
,
"9600"
,
"19200"
,
"38400"
,
"57600"
,
"115200"
]
def
__init__
(
self
):
# defaults here.
# the initial value determines the type
self
.
port
=
""
self
.
baudrate
=
0
self
.
temperature_pla
=
210.0
self
.
temperature_abs
=
230.0
self
.
bedtemp_pla
=
60.0
self
.
bedtemp_abs
=
110.0
self
.
x_feedrate
=
3000.0
self
.
y_feedrate
=
3000.0
self
.
z_feedrate
=
200.0
self
.
e_feedrate
=
300.0
def
_set
(
self
,
key
,
value
):
try
:
value
=
getattr
(
self
,
"_
%
s_alias"
%
key
)()[
value
]
except
KeyError
:
pass
except
AttributeError
:
pass
try
:
getattr
(
self
,
"_
%
s_validate"
%
key
)(
value
)
except
AttributeError
:
pass
setattr
(
self
,
key
,
type
(
getattr
(
self
,
key
))(
value
))
try
:
getattr
(
self
,
"_
%
s_cb"
%
key
)(
key
,
value
)
except
AttributeError
:
pass
return
value
def
_tabcomplete
(
self
,
key
):
try
:
return
getattr
(
self
,
"_
%
s_list"
%
key
)()
except
AttributeError
:
pass
try
:
return
getattr
(
self
,
"_
%
s_alias"
%
key
)()
.
keys
()
except
AttributeError
:
pass
return
[]
class
pronsole
(
cmd
.
Cmd
):
class
pronsole
(
cmd
.
Cmd
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -41,12 +87,23 @@ class pronsole(cmd.Cmd):
...
@@ -41,12 +87,23 @@ class pronsole(cmd.Cmd):
self
.
tempreadings
=
""
self
.
tempreadings
=
""
self
.
macros
=
{}
self
.
macros
=
{}
self
.
processing_rc
=
False
self
.
processing_rc
=
False
self
.
lastport
=
(
None
,
None
)
self
.
settings
=
Settings
()
self
.
settings
.
_port_list
=
self
.
scanserial
self
.
settings
.
_temperature_abs_cb
=
self
.
set_temp_preset
self
.
settings
.
_temperature_pla_cb
=
self
.
set_temp_preset
self
.
settings
.
_bedtemp_abs_cb
=
self
.
set_temp_preset
self
.
settings
.
_bedtemp_pla_cb
=
self
.
set_temp_preset
self
.
monitoring
=
0
self
.
monitoring
=
0
self
.
feedxy
=
3000
self
.
feedz
=
200
self
.
feede
=
300
def
set_temp_preset
(
self
,
key
,
value
):
if
not
key
.
startswith
(
"bed"
):
self
.
temps
[
"pla"
]
=
str
(
self
.
settings
.
temperature_pla
)
self
.
temps
[
"abs"
]
=
str
(
self
.
settings
.
temperature_abs
)
print
"Hotend temperature presets updated, pla:
%
s, abs:
%
s"
%
(
self
.
temps
[
"pla"
],
self
.
temps
[
"abs"
])
else
:
self
.
bedtemps
[
"pla"
]
=
str
(
self
.
settings
.
bedtemp_pla
)
self
.
bedtemps
[
"abs"
]
=
str
(
self
.
settings
.
bedtemp_abs
)
print
"Bed temperature presets updated, pla:
%
s, abs:
%
s"
%
(
self
.
bedtemps
[
"pla"
],
self
.
bedtemps
[
"abs"
])
def
scanserial
(
self
):
def
scanserial
(
self
):
"""scan for available ports. return a list of device names."""
"""scan for available ports. return a list of device names."""
...
@@ -81,7 +138,7 @@ class pronsole(cmd.Cmd):
...
@@ -81,7 +138,7 @@ class pronsole(cmd.Cmd):
if
(
len
(
line
.
split
())
==
2
and
line
[
-
1
]
!=
" "
)
or
(
len
(
line
.
split
())
==
1
and
line
[
-
1
]
==
" "
):
if
(
len
(
line
.
split
())
==
2
and
line
[
-
1
]
!=
" "
)
or
(
len
(
line
.
split
())
==
1
and
line
[
-
1
]
==
" "
):
return
[
i
for
i
in
self
.
macros
.
keys
()
if
i
.
startswith
(
text
)]
return
[
i
for
i
in
self
.
macros
.
keys
()
if
i
.
startswith
(
text
)]
elif
(
len
(
line
.
split
())
==
3
or
(
len
(
line
.
split
())
==
2
and
line
[
-
1
]
==
" "
)):
elif
(
len
(
line
.
split
())
==
3
or
(
len
(
line
.
split
())
==
2
and
line
[
-
1
]
==
" "
)):
return
[
"/D"
,
"/S"
]
+
self
.
completenames
(
text
)
return
[
i
for
i
in
[
"/D"
,
"/S"
]
+
self
.
completenames
(
text
)
if
i
.
startswith
(
text
)]
else
:
else
:
return
[]
return
[]
...
@@ -183,6 +240,45 @@ class pronsole(cmd.Cmd):
...
@@ -183,6 +240,45 @@ class pronsole(cmd.Cmd):
else
:
else
:
print
"Macro '"
+
macro_name
+
"' is not defined"
print
"Macro '"
+
macro_name
+
"' is not defined"
def
set
(
self
,
var
,
str
):
try
:
t
=
type
(
getattr
(
self
.
settings
,
var
))
value
=
self
.
settings
.
_set
(
var
,
str
)
if
not
self
.
processing_rc
:
self
.
save_in_rc
(
"set "
+
var
,
"set
%
s
%
s"
%
(
var
,
value
))
except
AttributeError
:
print
"Unknown variable '
%
s'"
%
var
except
ValueError
as
ve
:
print
"Bad value for variable '
%
s', expecting"
%
var
,
str
(
t
)[
1
:
-
1
],
"(
%
s)"
%
ve
.
args
[
0
]
def
do_set
(
self
,
argl
):
args
=
argl
.
split
(
None
,
1
)
if
len
(
args
)
<
1
:
for
k
in
[
kk
for
kk
in
dir
(
self
.
settings
)
if
not
kk
.
startswith
(
"_"
)]:
print
"
%
s =
%
s"
%
(
k
,
str
(
getattr
(
self
.
settings
,
k
)))
return
value
=
getattr
(
self
.
settings
,
args
[
0
])
if
len
(
args
)
<
2
:
try
:
print
"
%
s =
%
s"
%
(
args
[
0
],
getattr
(
self
.
settings
,
args
[
0
]))
except
AttributeError
:
print
"Unknown variable '
%
s'"
%
args
[
0
]
return
self
.
set
(
args
[
0
],
args
[
1
])
def
help_set
(
self
):
print
"Set variable: set <variable> <value>"
print
"Show variable: set <variable>"
print
"'set' without arguments displays all variables"
def
complete_set
(
self
,
text
,
line
,
begidx
,
endidx
):
if
(
len
(
line
.
split
())
==
2
and
line
[
-
1
]
!=
" "
)
or
(
len
(
line
.
split
())
==
1
and
line
[
-
1
]
==
" "
):
return
[
i
for
i
in
dir
(
self
.
settings
)
if
not
i
.
startswith
(
"_"
)
and
i
.
startswith
(
text
)]
elif
(
len
(
line
.
split
())
==
3
or
(
len
(
line
.
split
())
==
2
and
line
[
-
1
]
==
" "
)):
return
[
i
for
i
in
self
.
settings
.
_tabcomplete
(
line
.
split
()[
1
])
if
i
.
startswith
(
text
)]
else
:
return
[]
def
postloop
(
self
):
def
postloop
(
self
):
self
.
p
.
disconnect
()
self
.
p
.
disconnect
()
cmd
.
Cmd
.
postloop
(
self
)
cmd
.
Cmd
.
postloop
(
self
)
...
@@ -263,10 +359,10 @@ class pronsole(cmd.Cmd):
...
@@ -263,10 +359,10 @@ class pronsole(cmd.Cmd):
def
do_connect
(
self
,
l
):
def
do_connect
(
self
,
l
):
a
=
l
.
split
()
a
=
l
.
split
()
p
=
self
.
scanserial
()
p
=
self
.
scanserial
()
port
=
self
.
lastport
[
0
]
port
=
self
.
settings
.
port
if
(
port
is
None
or
port
not
in
p
)
and
len
(
p
)
>
0
:
if
(
port
==
""
or
port
not
in
p
)
and
len
(
p
)
>
0
:
port
=
p
[
0
]
port
=
p
[
0
]
baud
=
self
.
lastport
[
1
]
or
115200
baud
=
self
.
settings
.
baudrate
or
115200
if
(
len
(
a
)
>
0
):
if
(
len
(
a
)
>
0
):
port
=
a
[
0
]
port
=
a
[
0
]
if
(
len
(
a
)
>
1
):
if
(
len
(
a
)
>
1
):
...
@@ -274,12 +370,17 @@ class pronsole(cmd.Cmd):
...
@@ -274,12 +370,17 @@ class pronsole(cmd.Cmd):
baud
=
int
(
a
[
1
])
baud
=
int
(
a
[
1
])
except
:
except
:
print
"Bad baud value '"
+
a
[
1
]
+
"' ignored"
print
"Bad baud value '"
+
a
[
1
]
+
"' ignored"
if
len
(
p
)
==
0
and
port
is
None
:
if
len
(
p
)
==
0
and
not
port
:
print
"No serial ports detected - please specify a port"
print
"No serial ports detected - please specify a port"
return
return
if
len
(
a
)
==
0
:
if
len
(
a
)
==
0
:
print
"No port specified - connecting to
%
s at
%
dbps"
%
(
port
,
baud
)
print
"No port specified - connecting to
%
s at
%
dbps"
%
(
port
,
baud
)
self
.
lastport
=
(
port
,
baud
)
if
port
!=
self
.
settings
.
port
:
self
.
settings
.
port
=
port
self
.
save_in_rc
(
"set port"
,
"set port
%
s"
%
port
)
if
baud
!=
self
.
settings
.
baudrate
:
self
.
settings
.
baudrate
=
baud
self
.
save_in_rc
(
"set baudrate"
,
"set baudrate
%
d"
%
baud
)
self
.
p
.
connect
(
port
,
baud
)
self
.
p
.
connect
(
port
,
baud
)
def
help_connect
(
self
):
def
help_connect
(
self
):
...
@@ -658,16 +759,16 @@ class pronsole(cmd.Cmd):
...
@@ -658,16 +759,16 @@ class pronsole(cmd.Cmd):
axis
=
"E"
axis
=
"E"
l
=
l
.
split
()
l
=
l
.
split
()
if
(
l
[
0
]
.
lower
()
==
"x"
):
if
(
l
[
0
]
.
lower
()
==
"x"
):
feed
=
self
.
feedxy
feed
=
self
.
settings
.
x_feedrate
axis
=
"X"
axis
=
"X"
elif
(
l
[
0
]
.
lower
()
==
"y"
):
elif
(
l
[
0
]
.
lower
()
==
"y"
):
feed
=
self
.
feedxy
feed
=
self
.
settings
.
y_feedrate
axis
=
"Y"
axis
=
"Y"
elif
(
l
[
0
]
.
lower
()
==
"z"
):
elif
(
l
[
0
]
.
lower
()
==
"z"
):
feed
=
self
.
feedz
feed
=
self
.
settings
.
z_feedrate
axis
=
"Z"
axis
=
"Z"
elif
(
l
[
0
]
.
lower
()
==
"e"
):
elif
(
l
[
0
]
.
lower
()
==
"e"
):
feed
=
self
.
feed
e
feed
=
self
.
settings
.
e_feedrat
e
axis
=
"E"
axis
=
"E"
else
:
else
:
print
"Unknown axis."
print
"Unknown axis."
...
...
pronterface.py
View file @
3de92320
...
@@ -44,12 +44,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
...
@@ -44,12 +44,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
statuscheck
=
False
self
.
statuscheck
=
False
self
.
tempreport
=
""
self
.
tempreport
=
""
self
.
monitor
=
0
self
.
monitor
=
0
self
.
feedxy
=
3000
self
.
feedz
=
200
self
.
feede
=
300
self
.
paused
=
False
self
.
paused
=
False
self
.
temps
=
{
"pla"
:
"210"
,
"abs"
:
"230"
,
"off"
:
"0"
}
self
.
bedtemps
=
{
"pla"
:
"60"
,
"abs"
:
"110"
,
"off"
:
"0"
}
xcol
=
(
245
,
245
,
108
)
xcol
=
(
245
,
245
,
108
)
ycol
=
(
180
,
180
,
255
)
ycol
=
(
180
,
180
,
255
)
zcol
=
(
180
,
255
,
180
)
zcol
=
(
180
,
255
,
180
)
...
@@ -89,7 +84,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
...
@@ -89,7 +84,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
customdict
=
{}
customdict
=
{}
try
:
try
:
execfile
(
"custombtn.txt"
,
customdict
)
execfile
(
"custombtn.txt"
,
customdict
)
self
.
custombuttons
=
customdict
[
"btns"
]
self
.
custombuttons
+
=
customdict
[
"btns"
]
except
:
except
:
pass
pass
self
.
popmenu
()
self
.
popmenu
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment