ESP3D
3.0
Firmware for ESP boards connected to 3D Printer
devices_services.cpp
Go to the documentation of this file.
1
/*
2
devices_services.cpp - devices services functions class
3
4
Copyright (c) 2014 Luc Lebosse. All rights reserved.
5
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
10
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
#include "../../include/esp3d_config.h"
22
#ifdef CONNECTED_DEVICES_FEATURE
23
#include "
devices_services.h
"
24
#include "../../core/settings_esp3d.h"
25
#include "../../core/esp3doutput.h"
26
27
#ifdef DISPLAY_DEVICE
28
#include "../display/display.h"
29
#endif //DISPLAY_DEVICE
30
#ifdef DHT_DEVICE
31
#include "../dht/dht.h"
32
#endif //DHT_DEVICE
33
#ifdef BUZZER_DEVICE
34
#include "../buzzer/buzzer.h"
35
#endif //BUZZER_DEVICE
36
#ifdef RECOVERY_FEATURE
37
#include "../recovery/recovery_service.h"
38
#endif //RECOVERY_FEATURE
39
#ifdef CAMERA_DEVICE
40
#include "../camera/camera.h"
41
#endif //CAMERA_DEVICE
42
#ifdef SD_DEVICE
43
#include "../filesystem/esp_sd.h"
44
#endif //SD_DEVICE
45
46
bool
DevicesServices::_started =
false
;
47
48
DevicesServices::DevicesServices
()
49
{
50
}
51
DevicesServices::~DevicesServices
()
52
{
53
end
();
54
}
55
56
bool
DevicesServices::begin
()
57
{
58
bool
res =
true
;
59
_started =
false
;
60
#ifdef SD_DEVICE
61
if
(!
ESP_SD::begin
()) {
62
log_esp3d
(
"Error sd intialization failed"
);
63
res =
false
;
64
}
65
#endif //SD_DEVICE
66
#ifdef DISPLAY_DEVICE
67
if
(!
esp3d_display
.
begin
()) {
68
log_esp3d
(
"Error starting display device"
);
69
res =
false
;
70
}
71
#endif //DISPLAY_DEVICE
72
#ifdef DHT_DEVICE
73
if
(!
esp3d_DHT
.
begin
()) {
74
log_esp3d
(
"Error starting DHT device"
);
75
res =
false
;
76
}
77
#endif //DHT_DEVICE
78
#ifdef BUZZER_DEVICE
79
if
(!
esp3d_buzzer
.
begin
()) {
80
log_esp3d
(
"Error starting buzzer device"
);
81
res =
false
;
82
}
83
#endif //BUZZER_DEVICE
84
#ifdef RECOVERY_FEATURE
85
if
(!
recovery_service
.
begin
()) {
86
log_esp3d
(
"Error starting recovery service"
);
87
res =
false
;
88
}
89
#endif //RECOVERY_FEATURE
90
#ifdef CAMERA_DEVICE
91
if
(!
esp3d_camera
.
initHardware
()) {
92
log_esp3d
(
"Error camera intialization failed"
);
93
res =
false
;
94
}
95
#endif //CAMERA_DEVICE
96
if
(!res) {
97
end
();
98
}
99
_started = res;
100
return
_started;
101
}
102
void
DevicesServices::end
()
103
{
104
if
(!_started) {
105
return
;
106
}
107
_started =
false
;
108
#ifdef SD_DEVICE
109
ESP_SD::end
();
110
#endif //SD_DEVICE
111
#ifdef CAMERA_DEVICE
112
esp3d_camera
.
stopHardware
();
113
#endif //CAMERA_DEVICE
114
#ifdef RECOVERY_FEATURE
115
recovery_service
.
end
();
116
#endif //RECOVERY_FEATURE
117
#ifdef BUZZER_DEVICE
118
esp3d_buzzer
.
end
();
119
#endif //BUZZER_DEVICE
120
#ifdef DISPLAY_DEVICE
121
esp3d_display
.
end
();
122
#endif //DISPLAY_DEVICE
123
#ifdef DHT_DEVICE
124
esp3d_DHT
.
end
();
125
#endif //DHT_DDEVICE
126
}
127
128
void
DevicesServices::handle
()
129
{
130
if
(_started) {
131
#ifdef DISPLAY_DEVICE
132
esp3d_display
.
handle
();
133
#endif //DISPLAY_DEVICE
134
#ifdef DHT_DEVICE
135
esp3d_DHT
.
handle
();
136
#endif //DHT_DEVICE
137
#ifdef BUZZER_DEVICE
138
esp3d_buzzer
.
handle
();
139
#endif //BUZZER_DEVICE
140
#ifdef RECOVERY_FEATURE
141
recovery_service
.
handle
();
142
#endif //RECOVERY_FEATURE
143
#ifdef SD_DEVICE
144
ESP_SD::handle
();
145
#endif //SD_DEVICE
146
}
147
}
148
149
#endif //#CONNECTED_DEVICES_FEATURE
DHT::handle
void handle()
RecoveryService::handle
void handle()
RecoveryService::begin
bool begin()
Camera::stopHardware
bool stopHardware()
Display::end
void end()
DevicesServices::end
static void end()
Definition:
devices_services.cpp:102
DHT::end
void end()
Display::begin
bool begin()
BuzzerDevice::handle
void handle()
esp3d_DHT
DHT esp3d_DHT
ESP_SD::begin
static bool begin()
ESP_SD::handle
static void handle()
Definition:
esp_sd.cpp:62
DHT::begin
bool begin()
devices_services.h
DevicesServices::begin
static bool begin()
Definition:
devices_services.cpp:56
BuzzerDevice::end
void end()
DevicesServices::DevicesServices
DevicesServices()
Definition:
devices_services.cpp:48
log_esp3d
#define log_esp3d(format,...)
Definition:
debug_esp3d.h:29
BuzzerDevice::begin
bool begin()
DevicesServices::~DevicesServices
~DevicesServices()
Definition:
devices_services.cpp:51
recovery_service
RecoveryService recovery_service
esp3d_display
Display esp3d_display
Display::handle
void handle()
esp3d_camera
Camera esp3d_camera
Camera::initHardware
bool initHardware(bool forceinit=false)
RecoveryService::end
void end()
DevicesServices::handle
static void handle()
Definition:
devices_services.cpp:128
esp3d_buzzer
BuzzerDevice esp3d_buzzer
ESP_SD::end
static void end()
esp3d
src
modules
devices
devices_services.cpp
Generated by
1.8.17