Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SmartHome
NodeManager_BME280_EasyPCB
Commits
7ad3d6c5
Commit
7ad3d6c5
authored
May 23, 2017
by
user2684
Browse files
Add option to retrieve the latest value of a sensor #104
parent
cec50cca
Changes
3
Hide whitespace changes
Inline
Side-by-side
NodeManager.cpp
View file @
7ad3d6c5
...
@@ -152,6 +152,9 @@ void Sensor::setForceUpdate(int value) {
...
@@ -152,6 +152,9 @@ void Sensor::setForceUpdate(int value) {
void
Sensor
::
setValueType
(
int
value
)
{
void
Sensor
::
setValueType
(
int
value
)
{
_value_type
=
value
;
_value_type
=
value
;
}
}
int
Sensor
::
getValueType
()
{
return
_value_type
;
}
void
Sensor
::
setFloatPrecision
(
int
value
)
{
void
Sensor
::
setFloatPrecision
(
int
value
)
{
_float_precision
=
value
;
_float_precision
=
value
;
}
}
...
@@ -178,6 +181,15 @@ void Sensor::setInterruptPin(int value) {
...
@@ -178,6 +181,15 @@ void Sensor::setInterruptPin(int value) {
int
Sensor
::
getInterruptPin
()
{
int
Sensor
::
getInterruptPin
()
{
return
_interrupt_pin
;
return
_interrupt_pin
;
}
}
int
Sensor
::
getValueInt
()
{
return
_last_value_int
;
}
float
Sensor
::
getValueFloat
()
{
return
_last_value_float
;
}
char
*
Sensor
::
getValueString
()
{
return
_last_value_string
;
}
// present the sensor to the gateway and controller
// present the sensor to the gateway and controller
void
Sensor
::
presentation
()
{
void
Sensor
::
presentation
()
{
...
...
NodeManager.h
View file @
7ad3d6c5
...
@@ -345,6 +345,7 @@ class Sensor {
...
@@ -345,6 +345,7 @@ class Sensor {
void
setForceUpdate
(
int
value
);
void
setForceUpdate
(
int
value
);
// the value type of this sensor (default: TYPE_INTEGER)
// the value type of this sensor (default: TYPE_INTEGER)
void
setValueType
(
int
value
);
void
setValueType
(
int
value
);
int
getValueType
();
// for float values, set the float precision (default: 2)
// for float values, set the float precision (default: 2)
void
setFloatPrecision
(
int
value
);
void
setFloatPrecision
(
int
value
);
// optionally sleep interval in milliseconds before sending each message to the radio network (default: 0)
// optionally sleep interval in milliseconds before sending each message to the radio network (default: 0)
...
@@ -362,6 +363,10 @@ class Sensor {
...
@@ -362,6 +363,10 @@ class Sensor {
// manually turn the power off
// manually turn the power off
void
powerOff
();
void
powerOff
();
#endif
#endif
// get the latest recorded value from the sensor
int
getValueInt
();
float
getValueFloat
();
char
*
getValueString
();
// define what to do at each stage of the sketch
// define what to do at each stage of the sketch
virtual
void
before
();
virtual
void
before
();
virtual
void
presentation
();
virtual
void
presentation
();
...
...
README.md
View file @
7ad3d6c5
...
@@ -343,12 +343,16 @@ The following methods are available for all the sensors:
...
@@ -343,12 +343,16 @@ The following methods are available for all the sensors:
~~~
c
~~~
c
// where the sensor is attached to (default: not set)
// where the sensor is attached to (default: not set)
void
setPin
(
int
value
);
void
setPin
(
int
value
);
int
getPin
();
// child_id of this sensor (default: not set)
// child_id of this sensor (default: not set)
void
setChildId
(
int
value
);
void
setChildId
(
int
value
);
int
getChildId
();
// presentation of this sensor (default: S_CUSTOM)
// presentation of this sensor (default: S_CUSTOM)
void
setPresentation
(
int
value
);
void
setPresentation
(
int
value
);
int
getPresentation
();
// type of this sensor (default: V_CUSTOM)
// type of this sensor (default: V_CUSTOM)
void
setType
(
int
value
);
void
setType
(
int
value
);
int
getType
();
// description of the sensor (default: '')
// description of the sensor (default: '')
void
setDescription
(
char
*
value
);
void
setDescription
(
char
*
value
);
// set this to true if you want destination node to send ack back to this node (default: false)
// set this to true if you want destination node to send ack back to this node (default: false)
...
@@ -365,10 +369,14 @@ The following methods are available for all the sensors:
...
@@ -365,10 +369,14 @@ The following methods are available for all the sensors:
void
setForceUpdate
(
int
value
);
void
setForceUpdate
(
int
value
);
// the value type of this sensor (default: TYPE_INTEGER)
// the value type of this sensor (default: TYPE_INTEGER)
void
setValueType
(
int
value
);
void
setValueType
(
int
value
);
int
getValueType
();
// for float values, set the float precision (default: 2)
// for float values, set the float precision (default: 2)
void
setFloatPrecision
(
int
value
);
void
setFloatPrecision
(
int
value
);
// optionally sleep interval in milliseconds before sending each message to the radio network (default: 0)
// optionally sleep interval in milliseconds before sending each message to the radio network (default: 0)
void
setSleepBetweenSend
(
int
value
);
void
setSleepBetweenSend
(
int
value
);
// set the interrupt pin the sensor is attached to so its loop() will be executed only upon that interrupt (default: -1)
void
setInterruptPin
(
int
value
);
int
getInterruptPin
();
#if POWER_MANAGER == 1
#if POWER_MANAGER == 1
// to save battery the sensor can be optionally connected to two pins which will act as vcc and ground and activated on demand
// to save battery the sensor can be optionally connected to two pins which will act as vcc and ground and activated on demand
void
setPowerPins
(
int
ground_pin
,
int
vcc_pin
,
long
wait
=
0
);
void
setPowerPins
(
int
ground_pin
,
int
vcc_pin
,
long
wait
=
0
);
...
@@ -379,6 +387,10 @@ The following methods are available for all the sensors:
...
@@ -379,6 +387,10 @@ The following methods are available for all the sensors:
// manually turn the power off
// manually turn the power off
void
powerOff
();
void
powerOff
();
#endif
#endif
// get the latest value from the sensor
int
getValueInt
();
float
getValueFloat
();
char
*
getValueString
();
~~~
~~~
### Sensor's specific configuration
### Sensor's specific configuration
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment