mirror of
https://github.com/sinseman44/PyCNC.git
synced 2026-01-12 02:40:04 +00:00
reorganise project
This commit is contained in:
0
cnc/__init__.py
Executable file
0
cnc/__init__.py
Executable file
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Hardware limitations config
|
||||
STEPPER_PULSE_LINGTH_US = 2
|
||||
STEPPER_MAX_VELOCITY_MM_PER_MIN = 1800 # mm per min
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import math
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import re
|
||||
|
||||
from coordinates import Coordinates
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import time
|
||||
import logging
|
||||
|
||||
@@ -32,7 +30,9 @@ class GMachine(object):
|
||||
self.reset()
|
||||
hal.init()
|
||||
|
||||
def destroy(self):
|
||||
def release(self):
|
||||
""" Return machine to original position and free all resources.
|
||||
"""
|
||||
self.home()
|
||||
hal.join()
|
||||
|
||||
50
cnc/hal.py
Normal file
50
cnc/hal.py
Normal file
@@ -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")
|
||||
0
cnc/hal_raspberry/__init__.py
Executable file
0
cnc/hal_raspberry/__init__.py
Executable file
@@ -1,13 +1,11 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
import rpgpio
|
||||
|
||||
from pulses import PulseGeneratorLinear
|
||||
from coordinates import Coordinates
|
||||
from config import *
|
||||
from cnc.pulses import PulseGeneratorLinear
|
||||
from cnc.coordinates import Coordinates
|
||||
from cnc.config import *
|
||||
|
||||
# Stepper motors channel for RPIO
|
||||
STEPPER_CHANNEL = 0
|
||||
@@ -8,7 +8,6 @@ import sys
|
||||
import struct
|
||||
|
||||
|
||||
|
||||
class GPIO(object):
|
||||
MODE_OUTPUT = 1
|
||||
MODE_INPUT_NOPULL = 2
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import mmap
|
||||
import struct
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
@@ -11,6 +9,7 @@ from coordinates import Coordinates
|
||||
It checks PulseGenerator with some tests.
|
||||
"""
|
||||
|
||||
|
||||
def init():
|
||||
""" Initialize GPIO pins and machine itself, including calibration if
|
||||
needed. Do not return till all procedure is completed.
|
||||
@@ -51,7 +51,7 @@ def main():
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
print("\r\nExiting...")
|
||||
machine.destroy()
|
||||
machine.release()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import division
|
||||
import math
|
||||
import logging
|
||||
@@ -5,7 +5,7 @@ ADDR=pi@192.168.0.208
|
||||
if [ ! -z $1 ]; then
|
||||
ADDR=$1
|
||||
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} 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"
|
||||
|
||||
8
hal.py
8
hal.py
@@ -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 *
|
||||
7
pycnc
Executable file
7
pycnc
Executable file
@@ -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
|
||||
ADDR=$1
|
||||
fi
|
||||
sshpass -p${PASS} scp $(dirname "$0")/../rpgpio_private.py "${ADDR}:~"
|
||||
sshpass -p${PASS} scp $(dirname "$0")/../rpgpio.py "${ADDR}:~"
|
||||
sshpass -p${PASS} scp $(dirname "$0")/../cnc/hal_raspberry/rpgpio_private.py "${ADDR}:~"
|
||||
sshpass -p${PASS} scp $(dirname "$0")/../cnc/hal_raspberry/rpgpio.py "${ADDR}:~"
|
||||
sshpass -p${PASS} ssh -t ${ADDR} "sudo ~/rpgpio.py"
|
||||
|
||||
Reference in New Issue
Block a user