PyCNC

Форк
0
/
hal.py 
133 строки · 4.4 Кб
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:
4
#    def init():
5
#        """ Initialize GPIO pins and machine itself.
6
#        """
7
#        do_something()
8
#
9
#
10
#    def spindle_control(percent):
11
#        """ Spindle control implementation.
12
#        :param percent: Spindle speed in percent 0..100. 0 turns spindle off.
13
#        """
14
#        do_something()
15
#
16
#
17
#    def fan_control(on_off):
18
#        """
19
#        Cooling fan control.
20
#        :param on_off: boolean value if fan is enabled.
21
#        """
22
#        do_something()
23
#
24
#
25
#    def extruder_heater_control(percent):
26
#        """ Extruder heater control.
27
#        :param percent: heater power in percent 0..100. 0 turns heater off.
28
#        """
29
#        do_something()
30
#
31
#
32
#    def bed_heater_control(percent):
33
#        """ Hot bed heater control.
34
#        :param percent: heater power in percent 0..100. 0 turns heater off.
35
#        """
36
#        do_something()
37
#
38
#
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.
43
#        """
44
#        return measure()
45
#
46
#
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.
51
#        """
52
#        return measure()
53
#
54
#
55
#    def disable_steppers():
56
#        """ Disable all steppers until any movement occurs.
57
#        """
58
#        do_something()
59
#
60
#
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.
68
#        """
69
#        return do_something()
70
#
71
#
72
#    def move(generator):
73
#        """ Move head to according pulses in PulseGenerator.
74
#        :param generator: PulseGenerator object
75
#        """
76
#        do_something()
77
#
78
#
79
#    def join():
80
#        """ Wait till motors work.
81
#        """
82
#        do_something()
83
#
84
#
85
#    def deinit():
86
#        """ De-initialise hal, stop any hardware.
87
#        """
88
#        do_something()
89
#
90
#
91
#    def watchdog_feed():
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.
95
#        """
96
#        do_something()
97

98

99
# check which module to import
100
try:
101
    from cnc.hal_raspberry.hal import *
102
except ImportError:
103
    print("----- Hardware not detected, using virtual environment -----")
104
    print("----- Use M111 command to enable more detailed debug -----")
105
    from cnc.hal_virtual import *
106

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")
134

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.