Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qthing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
qthing
Commits
984c66b5
Commit
984c66b5
authored
6 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Make status LED configurable (disabled by default)
parent
0848b552
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
main/io.cpp
+14
-2
14 additions, 2 deletions
main/io.cpp
main/qthing.h
+3
-0
3 additions, 0 deletions
main/qthing.h
with
17 additions
and
2 deletions
main/io.cpp
+
14
−
2
View file @
984c66b5
...
...
@@ -16,7 +16,10 @@
#define IO_TAG "IO"
#define ESP_INTR_FLAG_DEFAULT 0
#define STATUS_LED_PIN GPIO_NUM_2
bool
status_led_enabled
=
false
;
bool
status_led_negated
=
false
;
gpio_num_t
status_led_gpio
;
#define DEBOUNCE_MILLIS 10
const
TickType_t
debounce_delay_ticks
=
std
::
max
(
DEBOUNCE_MILLIS
/
portTICK_PERIOD_MS
,
(
TickType_t
)
1
);
...
...
@@ -140,8 +143,17 @@ void add_button(gpio_num_t gpio, std::string topic, std::string message) {
add_button
(
gpio
,
[
topic
,
message
](){
publish_message
(
topic
,
message
);
});
}
void
enable_status_led
(
gpio_num_t
gpio
,
bool
negated
)
{
gpio_init_output
(
gpio
,
true
);
status_led_gpio
=
gpio
;
status_led_enabled
=
true
;
status_led_negated
=
negated
;
}
void
set_status_led
(
uint32_t
level
)
{
ESP_ERROR_CHECK
(
gpio_set_level
(
STATUS_LED_PIN
,
level
));
if
(
status_led_enabled
)
{
ESP_ERROR_CHECK
(
gpio_set_level
(
status_led_gpio
,
level
^
status_led_negated
));
}
}
void
gpio_init_output
(
gpio_num_t
gpio_num
,
uint32_t
level
)
{
...
...
This diff is collapsed.
Click to expand it.
main/qthing.h
+
3
−
0
View file @
984c66b5
...
...
@@ -35,6 +35,9 @@ typedef struct {
typedef
std
::
function
<
void
(
ota_event_t
)
>
ota_event_callback_t
;
// core
void
enable_status_led
(
gpio_num_t
gpio
=
GPIO_NUM_2
,
bool
negated
=
false
);
// network
void
enable_wlan
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment