Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NodeManager_BMP280_Stamp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SmartHome
NodeManager_BMP280_Stamp
Commits
d296022b
Commit
d296022b
authored
8 years ago
by
user2684
Browse files
Options
Downloads
Patches
Plain Diff
Add option to define which state means for relay open/close #77
parent
9a485cdc
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
NodeManager.cpp
+12
-3
12 additions, 3 deletions
NodeManager.cpp
NodeManager.h
+3
-0
3 additions, 0 deletions
NodeManager.h
README.md
+2
-0
2 additions, 0 deletions
README.md
with
17 additions
and
3 deletions
NodeManager.cpp
+
12
−
3
View file @
d296022b
...
@@ -790,6 +790,9 @@ void SensorDigitalOutput::setInitialValue(int value) {
...
@@ -790,6 +790,9 @@ void SensorDigitalOutput::setInitialValue(int value) {
void
SensorDigitalOutput
::
setPulseWidth
(
int
value
)
{
void
SensorDigitalOutput
::
setPulseWidth
(
int
value
)
{
_pulse_width
=
value
;
_pulse_width
=
value
;
}
}
void
SensorDigitalOutput
::
setOnValue
(
int
value
)
{
_on_value
=
value
;
}
// main task
// main task
void
SensorDigitalOutput
::
onLoop
()
{
void
SensorDigitalOutput
::
onLoop
()
{
...
@@ -812,15 +815,21 @@ void SensorDigitalOutput::onReceive(const MyMessage & message) {
...
@@ -812,15 +815,21 @@ void SensorDigitalOutput::onReceive(const MyMessage & message) {
Serial
.
print
(
F
(
" P="
));
Serial
.
print
(
F
(
" P="
));
Serial
.
println
(
_pulse_width
);
Serial
.
println
(
_pulse_width
);
#endif
#endif
// reverse the value if needed
int
value_to_write
=
value
;
if
(
_on_value
==
LOW
)
{
if
(
value
==
HIGH
)
value_to_write
=
LOW
;
if
(
value
==
LOW
)
value_to_write
=
HIGH
;
}
// set the value
// set the value
digitalWrite
(
_pin
,
value
);
digitalWrite
(
_pin
,
value_to_write
);
_state
=
value
;
if
(
_pulse_width
>
0
)
{
if
(
_pulse_width
>
0
)
{
// if this is a pulse output, restore the value to the original value after the pulse
// if this is a pulse output, restore the value to the original value after the pulse
wait
(
_pulse_width
);
wait
(
_pulse_width
);
digitalWrite
(
_pin
,
value
==
0
?
HIGH
:
LOW
);
digitalWrite
(
_pin
,
value
_to_write
==
0
?
HIGH
:
LOW
);
}
}
// store the current value so it will be sent to the controller
// store the current value so it will be sent to the controller
_state
=
value
;
_value_int
=
value
;
_value_int
=
value
;
}
}
if
(
message
.
getCommand
()
==
C_REQ
)
{
if
(
message
.
getCommand
()
==
C_REQ
)
{
...
...
This diff is collapsed.
Click to expand it.
NodeManager.h
+
3
−
0
View file @
d296022b
...
@@ -578,6 +578,8 @@ class SensorDigitalOutput: public Sensor {
...
@@ -578,6 +578,8 @@ class SensorDigitalOutput: public Sensor {
void
setInitialValue
(
int
value
);
void
setInitialValue
(
int
value
);
// if greater than 0, send a pulse of the given duration in ms and then restore the output back to the original value (default: 0)
// if greater than 0, send a pulse of the given duration in ms and then restore the output back to the original value (default: 0)
void
setPulseWidth
(
int
value
);
void
setPulseWidth
(
int
value
);
// define which value to set to the output when set to on (default: HIGH)
void
setOnValue
(
int
value
);
// define what to do at each stage of the sketch
// define what to do at each stage of the sketch
void
onBefore
();
void
onBefore
();
void
onSetup
();
void
onSetup
();
...
@@ -585,6 +587,7 @@ class SensorDigitalOutput: public Sensor {
...
@@ -585,6 +587,7 @@ class SensorDigitalOutput: public Sensor {
void
onReceive
(
const
MyMessage
&
message
);
void
onReceive
(
const
MyMessage
&
message
);
protected:
protected:
int
_initial_value
=
LOW
;
int
_initial_value
=
LOW
;
int
_on_value
=
HIGH
;
int
_state
=
0
;
int
_state
=
0
;
int
_pulse_width
=
0
;
int
_pulse_width
=
0
;
};
};
...
...
This diff is collapsed.
Click to expand it.
README.md
+
2
−
0
View file @
d296022b
...
@@ -442,6 +442,8 @@ Each sensor class can expose additional methods.
...
@@ -442,6 +442,8 @@ Each sensor class can expose additional methods.
void
setInitialValue
(
int
value
);
void
setInitialValue
(
int
value
);
// if greater than 0, send a pulse of the given duration in ms and then restore the output back to the original value (default: 0)
// if greater than 0, send a pulse of the given duration in ms and then restore the output back to the original value (default: 0)
void
setPulseWidth
(
int
value
);
void
setPulseWidth
(
int
value
);
// define which value to set to the output when set to on (default: HIGH)
void
setOnValue
(
int
value
);
~~~
~~~
#### SensorSwitch / SensorDoor / SensorMotion
#### SensorSwitch / SensorDoor / SensorMotion
...
...
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