ESP3D
3.0
Firmware for ESP boards connected to 3D Printer
boot_delay.cpp
Go to the documentation of this file.
1
/*
2
boot_delay.cpp - boot delay 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
#include "
boot_delay.h
"
23
#include "../../core/settings_esp3d.h"
24
#include "../../core/esp3doutput.h"
25
26
BootDelay::BootDelay
()
27
{
28
_started =
false
;
29
_startdelay = 0;
30
_totalduration = 0;
31
}
32
BootDelay::~BootDelay
()
33
{
34
end
();
35
}
36
37
bool
BootDelay::started
()
38
{
39
return
_started;
40
}
41
42
bool
BootDelay::begin
()
43
{
44
_totalduration =
Settings_ESP3D::read_uint32
(
ESP_BOOT_DELAY
);
45
log_esp3d
(
"Boot delay %d"
, _totalduration);
46
if
(_totalduration >
Settings_ESP3D::get_max_int32_value
(
ESP_BOOT_DELAY
)) {
47
_totalduration =
Settings_ESP3D::get_default_int32_value
(
ESP_BOOT_DELAY
);
48
log_esp3d
(
"Boot delay modified %d"
, _totalduration);
49
}
50
_started =
true
;
51
ESP3DGlobalOutput::display_progress
(0);
52
if
(_totalduration > 0) {
53
_startdelay = millis();
54
handle
();
55
}
56
ESP3DGlobalOutput::display_progress
(100);
57
log_esp3d
(
"Boot delay done"
);
58
return
_started;
59
}
60
void
BootDelay::end
()
61
{
62
}
63
64
void
BootDelay::handle
()
65
{
66
uint8_t lastpercent = 0;
67
uint32_t lastSent = millis();
68
while
((millis() - _startdelay) < _totalduration) {
69
//to avoid overfload 2x/sec is enough for progression
70
if
((millis() - lastSent) > 500) {
71
lastSent = millis();
72
uint8_t p = (100*(millis() - _startdelay))/_totalduration;
73
if
(p != lastpercent) {
74
lastpercent=p;
75
ESP3DGlobalOutput::display_progress
(p);
76
}
77
}
78
Hal::wait
(10);
79
}
80
}
Hal::wait
static void wait(uint32_t milliseconds)
Definition:
hal.cpp:226
BootDelay::~BootDelay
~BootDelay()
Definition:
boot_delay.cpp:32
Settings_ESP3D::get_default_int32_value
static uint32_t get_default_int32_value(int pos)
Definition:
settings_esp3d.cpp:342
Settings_ESP3D::get_max_int32_value
static uint32_t get_max_int32_value(int pos)
Definition:
settings_esp3d.cpp:416
boot_delay.h
BootDelay::end
void end()
Definition:
boot_delay.cpp:60
BootDelay::started
bool started()
Definition:
boot_delay.cpp:37
BootDelay::handle
void handle()
Definition:
boot_delay.cpp:64
BootDelay::begin
bool begin()
Definition:
boot_delay.cpp:42
ESP3DGlobalOutput::display_progress
static void display_progress(uint8_t v)
Definition:
esp3doutput.cpp:436
log_esp3d
#define log_esp3d(format,...)
Definition:
debug_esp3d.h:29
Settings_ESP3D::read_uint32
static uint32_t read_uint32(int pos, bool *haserror=NULL)
Definition:
settings_esp3d.cpp:919
ESP_BOOT_DELAY
#define ESP_BOOT_DELAY
Definition:
settings_esp3d.h:63
BootDelay::BootDelay
BootDelay()
Definition:
boot_delay.cpp:26
esp3d
src
modules
boot_delay
boot_delay.cpp
Generated by
1.8.17