1
# This implementation allows to use different hardware.
2
# Imported module contains functions for hardware access fo some board/SoC.
3
# List of HAL methods that should be implemented in each module:
5
# """ Initialize GPIO pins and machine itself.
10
# def spindle_control(percent):
11
# """ Spindle control implementation.
12
# :param percent: Spindle speed in percent 0..100. 0 turns spindle off.
17
# def fan_control(on_off):
20
# :param on_off: boolean value if fan is enabled.
25
# def extruder_heater_control(percent):
26
# """ Extruder heater control.
27
# :param percent: heater power in percent 0..100. 0 turns heater off.
32
# def bed_heater_control(percent):
33
# """ Hot bed heater control.
34
# :param percent: heater power in percent 0..100. 0 turns heater off.
39
# def get_extruder_temperature():
40
# """ Measure extruder temperature.
41
# Can raise OSError or IOError on any issue with sensor.
42
# :return: temperature in Celsius.
47
# def get_bed_temperature():
48
# """ Measure bed temperature.
49
# Can raise OSError or IOError on any issue with sensor.
50
# :return: temperature in Celsius.
55
# def disable_steppers():
56
# """ Disable all steppers until any movement occurs.
61
# def calibrate(x, y, z):
62
# """ Move head to home position till end stop switch will be triggered.
63
# Do not return till all procedures are completed.
64
# :param x: boolean, True to calibrate X axis.
65
# :param y: boolean, True to calibrate Y axis.
66
# :param z: boolean, True to calibrate Z axis.
67
# :return: boolean, True if all specified end stops were triggered.
69
# return do_something()
73
# """ Move head to according pulses in PulseGenerator.
74
# :param generator: PulseGenerator object
80
# """ Wait till motors work.
86
# """ De-initialise hal, stop any hardware.
92
# """ Feed hardware watchdog. This method should be called at least
93
# once in 15 seconds. Also, this method can do no operation in hal
94
# implementation and there will not be emergency stop for heaters.
99
# check which module to import
101
from cnc.hal_raspberry.hal import *
103
print("----- Hardware not detected, using virtual environment -----")
104
print("----- Use M111 command to enable more detailed debug -----")
105
from cnc.hal_virtual import *
107
# check if all methods that is needed is implemented
108
if 'init' not in locals():
109
raise NotImplementedError("hal.init() not implemented")
110
if 'spindle_control' not in locals():
111
raise NotImplementedError("hal.spindle_control() not implemented")
112
if 'fan_control' not in locals():
113
raise NotImplementedError("hal.fan_control() not implemented")
114
if 'extruder_heater_control' not in locals():
115
raise NotImplementedError("hal.extruder_heater_control() not implemented")
116
if 'bed_heater_control' not in locals():
117
raise NotImplementedError("hal.bed_heater_control() not implemented")
118
if 'get_extruder_temperature' not in locals():
119
raise NotImplementedError("hal.get_extruder_temperature() not implemented")
120
if 'get_bed_temperature' not in locals():
121
raise NotImplementedError("hal.get_bed_temperature() not implemented")
122
if 'disable_steppers' not in locals():
123
raise NotImplementedError("hal.disable_steppers() not implemented")
124
if 'calibrate' not in locals():
125
raise NotImplementedError("hal.calibrate() not implemented")
126
if 'move' not in locals():
127
raise NotImplementedError("hal.move() not implemented")
128
if 'join' not in locals():
129
raise NotImplementedError("hal.join() not implemented")
130
if 'deinit' not in locals():
131
raise NotImplementedError("hal.deinit() not implemented")
132
if 'watchdog_feed' not in locals():
133
raise NotImplementedError("hal.watchdog_feed() not implemented")