-
Notifications
You must be signed in to change notification settings - Fork 0
/
LaserControl.cpp
104 lines (86 loc) · 1.83 KB
/
LaserControl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//
//
//
#include "Marlin.h"
#include "LaserControl.h"
bool _isON;
void LaserControlClass::init()
{
dac.init(DAC_I2C_ADRESS, 100);
dac.setVoltage(uint16_t(0));
for (int i = 0; i < 3; i++) {
pinMode(_startSequence[i],OUTPUT);
digitalWrite(_startSequence[i],HIGH);
}
digitalWrite(ModuleRelaisPower, HIGH);
}
bool LaserControlClass::Start() {
if (!_isON) {
// sortie driver à zéro
dac.setPower(uint16_t(0));
for (int i = 0; i < 3; i++) {
digitalWrite(_startSequence[i], LOW);
delay(Laser_Delai_Sequence);
}
delay(500);
_isON = true;
}
return true;
}
bool LaserControlClass::Stop() {
if (_isON) {
dac.setPower(uint16_t(0));
for (int i = 0; i < 3; i++) {
digitalWrite(_stopSequence[i],HIGH);
delay(Laser_Delai_Sequence);
}
_isON = false;
}
return true;
}
bool LaserControlClass::EmergencyStop() {
if (_isON) {
dac.setVoltage(uint16_t(0));
for (int i = 0; i < 2; i++) {
digitalWrite(_stopSequence[i], HIGH);
}
_isON = false;
}
return true;
}
void LaserControlClass::setPower(uint16_t value) {
if (!_isON) return;
if (value == dac.getPower()) return;
dac.setPower(value);
return;
}
void LaserControlClass::setMaxPower(uint16_t value) {
if (value < 100 && value > 0) {
dac.setMaxPower(value);
}
}
uint16_t LaserControlClass::getRealPower() {
return dac.getRealPower();
}
uint16_t LaserControlClass::getMaxPower() {
return dac.getMaxPower();
}
uint16_t LaserControlClass::getPower() {
return dac.getPower();
}
void LaserControlClass::setLevel(uint16_t value) {
if (!_isON) return;
if (value == dac.getLevel()) return;
dac.setLevel(value);
return;
}
uint16_t LaserControlClass::getLevel() {
return dac.getLevel();
}
bool LaserControlClass::isON() {
return _isON;
}
float LaserControlClass::getTemp() {
return Thermistor.getTemp(Laser_Temp_PIN);
}
LaserControlClass LaserControl;