run on oses without /proc/cpuinfo and fix lines width

This commit is contained in:
Nikolay Khabarov
2017-07-09 03:19:04 +03:00
parent fdd2c4b059
commit 129d26ed5e
4 changed files with 31 additions and 26 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -1,4 +1,4 @@
# ------------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Hardware config.
# Maximum velocity for each axis in millimeter per minute.
@@ -23,9 +23,9 @@ STEPPER_INVERTED_Y = False
STEPPER_INVERTED_Z = False
STEPPER_INVERTED_E = True
# Invert zero end stops switches. By default(False) low level on input pin means
# that axis in zero position. For inverted(True) end stops, high level means
# zero position.
# Invert zero end stops switches. By default(False) low level on input pin
# means that axis in zero position. For inverted(True) end stops, high level
# means zero position.
ENDSTOP_INVERTED_X = True
ENDSTOP_INVERTED_Y = True
ENDSTOP_INVERTED_Z = True
@@ -49,7 +49,7 @@ BED_PID = {"P": 5.06820175723,
"I": 0.0476413193519,
"D": 4.76413193519}
# ------------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Pins configuration.
STEPPER_STEP_PIN_X = 16
@@ -73,7 +73,7 @@ ENDSTOP_PIN_X = 12
ENDSTOP_PIN_Y = 6
ENDSTOP_PIN_Z = 5
# ------------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Behavior config
# Run command immediately after receiving and stream new pulses, otherwise
@@ -82,7 +82,8 @@ ENDSTOP_PIN_Z = 5
# enough for streaming pulses(faster then real time).
INSTANT_RUN = True
# If this parameter is False, error will be raised on command with velocity more
# than maximum velocity specified here. If this parameter is True, velocity
# Would be decreased(proportional for all axises) to fit the maximum velocity.
# If this parameter is False, error will be raised on command with velocity
# more than maximum velocity specified here. If this parameter is True,
# velocity would be decreased(proportional for all axises) to fit the maximum
# velocity.
AUTO_VELOCITY_ADJUSTMENT = True

View File

@@ -241,8 +241,8 @@ class GMachine(object):
def safe_zero(self, x=True, y=True, z=True):
""" Move head to zero position safely.
:param x: boolean, move X axis to zero
:param y: boolean, move X axis to zero
:param z: boolean, move X axis to zero
:param y: boolean, move Y axis to zero
:param z: boolean, move Z axis to zero
"""
if x and not y:
self._move_linear(Coordinates(-self._position.x, 0, 0, 0),

View File

@@ -12,21 +12,25 @@ import ctypes
RPI1_PERI_BASE = 0x20000000
RPI2_3_PERI_BASE = 0x3F000000
# detect board version
with open("/proc/cpuinfo", "r") as f:
d = f.read()
r = re.search("^Revision\s+:\s+(.+)$", d, flags=re.MULTILINE)
h = re.search("^Hardware\s+:\s+(.+)$", d, flags=re.MULTILINE)
RPI_1_REVISIONS = ['0002', '0003', '0004', '0005', '0006', '0007', '0008',
'0009', '000d', '000e', '000f', '0010', '0011', '0012',
'0013', '0014', '0015', '900021', '900032']
if h is None:
raise ImportError("This is not raspberry pi board.")
elif r.group(1) in RPI_1_REVISIONS:
PERI_BASE = RPI1_PERI_BASE
elif "BCM2" in h.group(1):
PERI_BASE = RPI2_3_PERI_BASE
else:
raise ImportError("Unknown board.")
try:
with open("/proc/cpuinfo", "r") as f:
d = f.read()
r = re.search("^Revision\s+:\s+(.+)$", d, flags=re.MULTILINE)
h = re.search("^Hardware\s+:\s+(.+)$", d, flags=re.MULTILINE)
RPI_1_REVISIONS = ['0002', '0003', '0004', '0005', '0006', '0007',
'0008', '0009', '000d', '000e', '000f', '0010',
'0011', '0012', '0013', '0014', '0015', '900021',
'900032']
if h is None:
raise ImportError("This is not raspberry pi board.")
elif r.group(1) in RPI_1_REVISIONS:
PERI_BASE = RPI1_PERI_BASE
elif "BCM2" in h.group(1):
PERI_BASE = RPI2_3_PERI_BASE
else:
raise ImportError("Unknown board.")
except IOError:
raise ImportError("/proc/cpuinfo not found. Not Linux device?")
PAGE_SIZE = 4096
GPIO_REGISTER_BASE = 0x200000
GPIO_INPUT_OFFSET = 0x34