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
22c25826
Commit
22c25826
authored
Apr 04, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LightGcode implementation which stores as little as possible
parent
817d4a9d
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
449 additions
and
20 deletions
+449
-20
gcoder.py
printrun/gcoder.py
+384
-1
gcoder_line.pyx
printrun/gcoder_line.pyx
+64
-18
pronsole.py
printrun/pronsole.py
+1
-1
No files found.
printrun/gcoder.py
View file @
22c25826
This diff is collapsed.
Click to expand it.
printrun/gcoder_line.pyx
View file @
22c25826
...
...
@@ -14,7 +14,7 @@
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
from libc.stdlib cimport malloc, free
from libc.stdint cimport uint32_t
from libc.stdint cimport uint
8_t, uint
32_t
from libc.string cimport strlen, strncpy
cdef char* copy_string(object value):
...
...
@@ -26,23 +26,23 @@ cdef char* copy_string(object value):
return array
cdef enum BitPos:
pos_
x =
1 << 0
pos_
y =
1 << 1
pos_
z =
1 << 2
pos_
e
= 1 << 3
pos_
f
= 1 << 4
pos_
i
= 1 << 5
pos_
j
= 1 << 6
pos_
is_move =
1 << 7
pos_
relative =
1 << 8
pos_
relative_e =
1 << 9
pos_
extruding =
1 << 10
pos_
current_x =
1 << 11
pos_
current_y
= 1 << 12
pos_current_
z
= 1 << 13
pos_current_
tool =
1 << 14
pos_
raw =
1 << 15
pos_c
ommand =
1 << 16
pos_
raw =
1 << 0
pos_
command =
1 << 1
pos_
is_move =
1 << 2
pos_
x
= 1 << 3
pos_
y
= 1 << 4
pos_
z
= 1 << 5
pos_
e
= 1 << 6
pos_
f =
1 << 7
pos_
i =
1 << 8
pos_
j =
1 << 9
pos_
relative =
1 << 10
pos_
relative_e =
1 << 11
pos_
extruding
= 1 << 12
pos_current_
x
= 1 << 13
pos_current_
y =
1 << 14
pos_
current_z =
1 << 15
pos_c
urrent_tool =
1 << 16
pos_gcview_end_vertex = 1 << 17
# WARNING: don't use bits 24 to 31 as we store current_tool there
...
...
@@ -208,3 +208,49 @@ cdef class GLine:
# if self._command != NULL: free(self._command)
self._command = copy_string(value)
self._status = set_has_var(self._status, pos_command)
cdef class GLightLine:
cdef char* _raw
cdef char* _command
cdef uint8_t _status
__slots__ = ()
def __cinit__(self):
self._status = 0
self._raw = NULL
self._command = NULL
def __init__(self, line):
self.raw = line
def __dealloc__(self):
if self._raw != NULL: free(self._raw)
if self._command != NULL: free(self._command)
property raw:
def __get__(self):
if has_var(self._status, pos_raw): return self._raw
else: return None
def __set__(self, value):
# WARNING: memory leak could happen here, as we don't do the following :
# if self._raw != NULL: free(self._raw)
self._raw = copy_string(value)
self._status = set_has_var(self._status, pos_raw)
property command:
def __get__(self):
if has_var(self._status, pos_command): return self._command
else: return None
def __set__(self, value):
# WARNING: memory leak could happen here, as we don't do the following :
# if self._command != NULL: free(self._command)
self._command = copy_string(value)
self._status = set_has_var(self._status, pos_command)
property is_move:
def __get__(self):
if has_var(self._status, pos_is_move): return True
else: return False
def __set__(self, value):
if value: self._status = set_has_var(self._status, pos_is_move)
else: self._status = unset_has_var(self._status, pos_is_move)
printrun/pronsole.py
View file @
22c25826
...
...
@@ -1143,7 +1143,7 @@ class pronsole(cmd.Cmd):
def
load_gcode
(
self
,
filename
,
layer_callback
=
None
,
gcode
=
None
):
if
gcode
is
None
:
self
.
fgcode
=
gcoder
.
GCode
(
deferred
=
True
)
self
.
fgcode
=
gcoder
.
Light
GCode
(
deferred
=
True
)
else
:
self
.
fgcode
=
gcode
self
.
fgcode
.
prepare
(
open
(
filename
,
"rU"
),
...
...
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