mirror of
https://github.com/sinseman44/PyCNC.git
synced 2026-05-06 21:28:12 +00:00
reorganise project
This commit is contained in:
Executable
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
# Hardware limitations config
|
# Hardware limitations config
|
||||||
STEPPER_PULSE_LINGTH_US = 2
|
STEPPER_PULSE_LINGTH_US = 2
|
||||||
STEPPER_MAX_VELOCITY_MM_PER_MIN = 1800 # mm per min
|
STEPPER_MAX_VELOCITY_MM_PER_MIN = 1800 # mm per min
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from coordinates import Coordinates
|
from coordinates import Coordinates
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -32,7 +30,9 @@ class GMachine(object):
|
|||||||
self.reset()
|
self.reset()
|
||||||
hal.init()
|
hal.init()
|
||||||
|
|
||||||
def destroy(self):
|
def release(self):
|
||||||
|
""" Return machine to original position and free all resources.
|
||||||
|
"""
|
||||||
self.home()
|
self.home()
|
||||||
hal.join()
|
hal.join()
|
||||||
|
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
# This implementation allows to use different hardware.
|
||||||
|
# Imported module contains functions for hardware access fo some board/SoC.
|
||||||
|
# List of HAL methods that should be implemented in each module:
|
||||||
|
# def init():
|
||||||
|
# """ Initialize GPIO pins and machine itself, including calibration if
|
||||||
|
# needed. Do not return till all procedure is completed.
|
||||||
|
# """
|
||||||
|
# logging.info("initialize hal")
|
||||||
|
# do_something()
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# def spindle_control(percent):
|
||||||
|
# """ Spindle control implementation.
|
||||||
|
# :param percent: Spindle speed in percent. 0 turns spindle off.
|
||||||
|
# """
|
||||||
|
# logging.info("spindle control: {}%".format(percent))
|
||||||
|
# do_something()
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# def move_linear(delta, velocity):
|
||||||
|
# """ Move head to specified distance with specified speed.
|
||||||
|
# :param delta: Coordinated object, delta position in mm
|
||||||
|
# :param velocity: velocity in mm per min
|
||||||
|
# """
|
||||||
|
# do_something()
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# def join():
|
||||||
|
# """ Wait till motors work.
|
||||||
|
# """
|
||||||
|
# do_something()
|
||||||
|
|
||||||
|
|
||||||
|
# check which module to import
|
||||||
|
try:
|
||||||
|
from hal_raspberry.hal import *
|
||||||
|
except ImportError:
|
||||||
|
print("----- Hardware not detected, using virtual environment -----")
|
||||||
|
print("----- Use M111 command to enable more detailed debug -----")
|
||||||
|
from hal_virtual import *
|
||||||
|
|
||||||
|
# check if all methods that is needed is implemented
|
||||||
|
if 'init' not in locals():
|
||||||
|
raise NotImplementedError("hal.init() not implemented")
|
||||||
|
if 'spindle_control' not in locals():
|
||||||
|
raise NotImplementedError("hal.spindle_control() not implemented")
|
||||||
|
if 'move_linear' not in locals():
|
||||||
|
raise NotImplementedError("hal.move_linear() not implemented")
|
||||||
|
if 'join' not in locals():
|
||||||
|
raise NotImplementedError("hal.join() not implemented")
|
||||||
Executable
@@ -1,13 +1,11 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import rpgpio
|
import rpgpio
|
||||||
|
|
||||||
from pulses import PulseGeneratorLinear
|
from cnc.pulses import PulseGeneratorLinear
|
||||||
from coordinates import Coordinates
|
from cnc.coordinates import Coordinates
|
||||||
from config import *
|
from cnc.config import *
|
||||||
|
|
||||||
# Stepper motors channel for RPIO
|
# Stepper motors channel for RPIO
|
||||||
STEPPER_CHANNEL = 0
|
STEPPER_CHANNEL = 0
|
||||||
@@ -8,7 +8,6 @@ import sys
|
|||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GPIO(object):
|
class GPIO(object):
|
||||||
MODE_OUTPUT = 1
|
MODE_OUTPUT = 1
|
||||||
MODE_INPUT_NOPULL = 2
|
MODE_INPUT_NOPULL = 2
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import mmap
|
import mmap
|
||||||
import struct
|
import struct
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -11,6 +9,7 @@ from coordinates import Coordinates
|
|||||||
It checks PulseGenerator with some tests.
|
It checks PulseGenerator with some tests.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
""" Initialize GPIO pins and machine itself, including calibration if
|
""" Initialize GPIO pins and machine itself, including calibration if
|
||||||
needed. Do not return till all procedure is completed.
|
needed. Do not return till all procedure is completed.
|
||||||
@@ -51,7 +51,7 @@ def main():
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
print("\r\nExiting...")
|
print("\r\nExiting...")
|
||||||
machine.destroy()
|
machine.release()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
import math
|
import math
|
||||||
import logging
|
import logging
|
||||||
@@ -5,7 +5,7 @@ ADDR=pi@192.168.0.208
|
|||||||
if [ ! -z $1 ]; then
|
if [ ! -z $1 ]; then
|
||||||
ADDR=$1
|
ADDR=$1
|
||||||
fi
|
fi
|
||||||
tar -cvjSf $(dirname "$0")/pycnc.tar.bz2 $(dirname "$0")/*.py > /dev/null
|
find . -name "*.py" -o -name "pycnc" | tar -cjf $(dirname "$0")/pycnc.tar.bz2 -T -
|
||||||
sshpass -p${PASS} scp $(dirname "$0")/pycnc.tar.bz2 "${ADDR}:~/pycnc"
|
sshpass -p${PASS} scp $(dirname "$0")/pycnc.tar.bz2 "${ADDR}:~/pycnc"
|
||||||
sshpass -p${PASS} ssh -t ${ADDR} "(cd ~/pycnc && tar xvf pycnc.tar.bz2) > /dev/null" &> /dev/null
|
sshpass -p${PASS} ssh -t ${ADDR} "(cd ~/pycnc && tar xvf pycnc.tar.bz2) > /dev/null" &> /dev/null
|
||||||
sshpass -p${PASS} ssh -t ${ADDR} "sudo pypy ~/pycnc/main.py"
|
sshpass -p${PASS} ssh -t ${ADDR} "sudo pypy ~/pycnc/pycnc"
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
try:
|
|
||||||
from hal_rpi import *
|
|
||||||
except ImportError:
|
|
||||||
print("----- Hardware not detected, using virtual environment -----")
|
|
||||||
print("----- Use M111 command to enable more detailed debug -----")
|
|
||||||
from hal_virtual import *
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import cnc.main
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
cnc.main.main()
|
||||||
|
|
||||||
@@ -5,6 +5,6 @@ ADDR=pi@192.168.0.208
|
|||||||
if [ ! -z $1 ]; then
|
if [ ! -z $1 ]; then
|
||||||
ADDR=$1
|
ADDR=$1
|
||||||
fi
|
fi
|
||||||
sshpass -p${PASS} scp $(dirname "$0")/../rpgpio_private.py "${ADDR}:~"
|
sshpass -p${PASS} scp $(dirname "$0")/../cnc/hal_raspberry/rpgpio_private.py "${ADDR}:~"
|
||||||
sshpass -p${PASS} scp $(dirname "$0")/../rpgpio.py "${ADDR}:~"
|
sshpass -p${PASS} scp $(dirname "$0")/../cnc/hal_raspberry/rpgpio.py "${ADDR}:~"
|
||||||
sshpass -p${PASS} ssh -t ${ADDR} "sudo ~/rpgpio.py"
|
sshpass -p${PASS} ssh -t ${ADDR} "sudo ~/rpgpio.py"
|
||||||
|
|||||||
Reference in New Issue
Block a user