|
MyLD2410 Library
|
Classes | |
| struct | SensorData |
| struct | ValuesArray |
Public Types | |
| enum | Response { FAIL = 0 , ACK , DATA } |
Public Member Functions | |
| MyLD2410 (Stream &serial, bool debug=false) | |
| Construct a new MyLD2410 object. | |
| bool | begin () |
| Call this function in setup() to ascertain whether the device is responding. | |
| void | end () |
| Call this function to gracefully close the sensor. Useful for entering sleep mode. | |
| void | debugOn () |
| Set the debug flag. | |
| void | debugOff () |
| Reset the debug flag. | |
| Response | check () |
| Call this function in the main loop. | |
| bool | inConfigMode () |
| Check whether the device is in config mode (accepts commands) | |
| bool | inBasicMode () |
| Check whether the device is in basic mode (continuously sends basic presence data) | |
| bool | inEnhancedMode () |
| Check whether the device is in enhanced mode (continuously sends enhanced presence data) | |
| byte | getStatus () |
| Get the status of the sensor: 0 - No presence; 1 - Moving only; 2 - Stationary only; 3 - Both moving and stationary; 4 - Auto thresholds in progress; 5 - Auto thresholds successful; 6 - Auto thresholds failed; 255 - The sensor status is invalid. | |
| const char * | statusString () |
| Get the presence status as a c-string. | |
| unsigned long | getTimestamp () |
| Get the time (in milliseconds) of the last successfully received data frame. | |
| unsigned long | getFrameCount () |
| Get the number of data frames received so far. | |
| bool | presenceDetected () |
| Check whether presence was detected in the latest frame. | |
| bool | stationaryTargetDetected () |
| Check whether a stationary target was detected in the latest frame. | |
| unsigned long | stationaryTargetDistance () |
| Get the distance to the stationary target in [cm]. | |
| byte | stationaryTargetSignal () |
| Get the signal from the stationary target. | |
| const ValuesArray & | getStationarySignals () |
| Get the Stationary Signals object, if in enhanced mode. | |
| bool | movingTargetDetected () |
| Check whether a moving target was detected in the latest frame. | |
| unsigned long | movingTargetDistance () |
| Get the distance to the moving target in [cm]. | |
| byte | movingTargetSignal () |
| Get the signal from the moving target. | |
| const ValuesArray & | getMovingSignals () |
| Get the Moving Signals object, if in enhanced mode. | |
| unsigned long | detectedDistance () |
| Get the detected distance. | |
| const byte * | getMAC () |
| Get the Bluetooth MAC address as an array byte[6]. | |
| String | getMACstr () |
| Get the Bluetooth MAC address as a String. | |
| String | getFirmware () |
| Get the Firmware as a String. | |
| byte | getFirmwareMajor () |
| Get the Firmware Major. | |
| byte | getFirmwareMinor () |
| Get the Firmware Minor. | |
| unsigned long | getVersion () |
| Get the protocol version. | |
| const SensorData & | getSensorData () |
| Get the SensorData object. | |
| byte | getResolution () |
| Get the sensor resolution (gate-width) in [cm]. | |
| const ValuesArray & | getMovingThresholds () |
| Get the detection thresholds for moving targets. | |
| const ValuesArray & | getStationaryThresholds () |
| Get the detection thresholds for stationary targets. | |
| byte | getRange () |
| Get the maximum detection gate. | |
| unsigned long | getRange_cm () |
| Get the maximum detection range in [cm]. | |
| byte | getNoOneWindow () |
| Get the time-lag of "no presence" in [s]. The sensor begins reporting "no presence" only after no motion has been detected for that many seconds. | |
| bool | configMode (bool enable=true) |
| Request config mode. | |
| bool | enhancedMode (bool enable=true) |
| Request enhanced mode. | |
| bool | requestAuxConfig () |
| Request the current auxiliary configuration. | |
| bool | autoThresholds (byte _timeout=10) |
| Begin the automatic threshold detection routine (firmware >= 2.44) | |
| AutoStatus | getAutoStatus () |
| Get the status of the automatic threshold detection routine (firmware >= 2.44) | |
| bool | requestMAC () |
| Request the Bluetooth MAC address. | |
| bool | requestFirmware () |
| Request the Firmware. | |
| bool | requestResolution () |
| Request the resolution (gate-width) | |
| bool | setResolution (bool fine=false) |
| Set the resolution of the sensor. | |
| bool | requestParameters () |
| Request the sensor parameters: range, motion thresholds, stationary thresholds, no-one window. | |
| bool | setGateParameters (byte gate, byte movingThreshold, byte stationaryThreshold) |
| Set the gate parameters for a particular gate, or for all gates at once. | |
| bool | setMovingThreshold (byte gate, byte movingThreshold) |
| Set the moving target threshold for a particular gate. | |
| bool | setStationaryThreshold (byte gate, byte stationaryThreshold) |
| Set the stationary target threshold for a particular gate. | |
| bool | setGateParameters (const ValuesArray &moving_thresholds, const ValuesArray &stationary_thresholds, byte noOneWindow=5) |
| Set the parameters for all gates at once, as well as the no-one window. | |
| bool | setMaxGate (byte movingGate, byte stationaryGate, byte noOneWindow=5) |
| Set the detection range for moving targets, stationary targets, as well as the no-one window. | |
| bool | setNoOneWindow (byte noOneWindow) |
| Set the no-one window parameter. | |
| bool | setMaxMovingGate (byte movingGate) |
| Set the maximum moving gate. | |
| bool | setMaxStationaryGate (byte stationaryGate) |
| Set the maximum stationary gate. | |
| byte | getMaxMovingGate () |
| Get the maximum moving gate. | |
| byte | getMaxStationaryGate () |
| Get the maximum stationary gate. | |
| bool | requestReset () |
| Request reset to factory default parameters. | |
| bool | requestReboot () |
| Request reboot. | |
| bool | requestBTon () |
| Turn Bluetooth ON. | |
| bool | requestBToff () |
| Turn Bluetooth OFF. | |
| bool | setBTpassword (const char *passwd) |
| Set a new BT password. | |
| bool | setBTpassword (const String &passwd) |
| Set a new BT password. | |
| bool | resetBTpassword () |
| Reset the BT password. | |
| bool | setBaud (byte baud) |
| Reset the serial baud rate. The sensor reboots at the new rate on success. | |
| byte | getLightLevel () |
| Get the Light Level. | |
| LightControl | getLightControl () |
| Get the Light Control parameter. | |
| bool | setAuxControl (LightControl light_control, byte light_threshold, OutputControl output_control) |
| Set the Auxiliary Control parameters. | |
| bool | resetAuxControl () |
| Reset the Auxiliary Control parameters to their default values. | |
| byte | getLightThreshold () |
| Get the Light Threshold. | |
| OutputControl | getOutputControl () |
| Get the Output Control parameter. | |
| byte | getOutLevel () |
| Get the Light Level. | |
| MyLD2410::MyLD2410 | ( | Stream & | serial, |
| bool | debug = false ) |
Construct a new MyLD2410 object.
Construct from a serial stream object.
| serial | - a reference to a stream object (sensorSerial) |
| debug | - a flag that controls whether debug data will be sent to Serial |
| bool MyLD2410::autoThresholds | ( | byte | _timeout = 10 | ) |
Begin the automatic threshold detection routine (firmware >= 2.44)
| _timeout | - allow for timeout [s] to leave the room |
| MyLD2410::Response MyLD2410::check | ( | ) |
Call this function in the main loop.
| bool MyLD2410::configMode | ( | bool | enable = true | ) |
Request config mode.
| enable | [true]/false |
| unsigned long MyLD2410::detectedDistance | ( | ) |
Get the detected distance.
| bool MyLD2410::enhancedMode | ( | bool | enable = true | ) |
Request enhanced mode.
| enable | [true]/false |
| AutoStatus MyLD2410::getAutoStatus | ( | ) |
Get the status of the automatic threshold detection routine (firmware >= 2.44)
| String MyLD2410::getFirmware | ( | ) |
Get the Firmware as a String.
| byte MyLD2410::getFirmwareMajor | ( | ) |
Get the Firmware Major.
| byte MyLD2410::getFirmwareMinor | ( | ) |
Get the Firmware Minor.
| unsigned long MyLD2410::getFrameCount | ( | ) |
Get the number of data frames received so far.
| LightControl MyLD2410::getLightControl | ( | ) |
Get the Light Control parameter.
| byte MyLD2410::getLightLevel | ( | ) |
Get the Light Level.
| byte MyLD2410::getLightThreshold | ( | ) |
Get the Light Threshold.
| const byte * MyLD2410::getMAC | ( | ) |
Get the Bluetooth MAC address as an array byte[6].
| String MyLD2410::getMACstr | ( | ) |
Get the Bluetooth MAC address as a String.
| byte MyLD2410::getMaxMovingGate | ( | ) |
Get the maximum moving gate.
| byte MyLD2410::getMaxStationaryGate | ( | ) |
Get the maximum stationary gate.
| const MyLD2410::ValuesArray & MyLD2410::getMovingSignals | ( | ) |
Get the Moving Signals object, if in enhanced mode.
| const MyLD2410::ValuesArray & MyLD2410::getMovingThresholds | ( | ) |
Get the detection thresholds for moving targets.
| byte MyLD2410::getNoOneWindow | ( | ) |
Get the time-lag of "no presence" in [s]. The sensor begins reporting "no presence" only after no motion has been detected for that many seconds.
| byte MyLD2410::getOutLevel | ( | ) |
Get the Light Level.
| OutputControl MyLD2410::getOutputControl | ( | ) |
Get the Output Control parameter.
| byte MyLD2410::getRange | ( | ) |
Get the maximum detection gate.
| unsigned long MyLD2410::getRange_cm | ( | ) |
Get the maximum detection range in [cm].
| byte MyLD2410::getResolution | ( | ) |
Get the sensor resolution (gate-width) in [cm].
| const MyLD2410::SensorData & MyLD2410::getSensorData | ( | ) |
Get the SensorData object.
| const MyLD2410::ValuesArray & MyLD2410::getStationarySignals | ( | ) |
Get the Stationary Signals object, if in enhanced mode.
| const MyLD2410::ValuesArray & MyLD2410::getStationaryThresholds | ( | ) |
Get the detection thresholds for stationary targets.
| byte MyLD2410::getStatus | ( | ) |
Get the status of the sensor: 0 - No presence; 1 - Moving only; 2 - Stationary only; 3 - Both moving and stationary; 4 - Auto thresholds in progress; 5 - Auto thresholds successful; 6 - Auto thresholds failed; 255 - The sensor status is invalid.
| unsigned long MyLD2410::getVersion | ( | ) |
Get the protocol version.
| unsigned long MyLD2410::movingTargetDistance | ( | ) |
Get the distance to the moving target in [cm].
| byte MyLD2410::movingTargetSignal | ( | ) |
Get the signal from the moving target.
| bool MyLD2410::requestAuxConfig | ( | ) |
Request the current auxiliary configuration.
| bool MyLD2410::requestBToff | ( | ) |
Turn Bluetooth OFF.
| bool MyLD2410::requestBTon | ( | ) |
Turn Bluetooth ON.
| bool MyLD2410::requestFirmware | ( | ) |
Request the Firmware.
| bool MyLD2410::requestMAC | ( | ) |
Request the Bluetooth MAC address.
| bool MyLD2410::requestParameters | ( | ) |
Request the sensor parameters: range, motion thresholds, stationary thresholds, no-one window.
| bool MyLD2410::requestReboot | ( | ) |
Request reboot.
| bool MyLD2410::requestReset | ( | ) |
Request reset to factory default parameters.
| bool MyLD2410::requestResolution | ( | ) |
Request the resolution (gate-width)
| bool MyLD2410::resetAuxControl | ( | ) |
Reset the Auxiliary Control parameters to their default values.
| bool MyLD2410::resetBTpassword | ( | ) |
Reset the BT password.
| bool MyLD2410::setAuxControl | ( | LightControl | light_control, |
| byte | light_threshold, | ||
| OutputControl | output_control ) |
Set the Auxiliary Control parameters.
| light_control | |
| light_threshold | |
| output_control |
| bool MyLD2410::setBaud | ( | byte | baud | ) |
Reset the serial baud rate. The sensor reboots at the new rate on success.
| bool MyLD2410::setBTpassword | ( | const char * | passwd | ) |
Set a new BT password.
The BT password must be 6 characters long. If the string is shorter, it will be padded with spaces '\20'. If it is longer, only the first 6 characters will be used.
| passwd | c-string |
| bool MyLD2410::setBTpassword | ( | const String & | passwd | ) |
Set a new BT password.
The BT password must be 6 characters long. If the string is shorter, it will be padded with spaces '\20'. If it is longer, only the first 6 characters will be used.
| passwd | Arduino String |
| bool MyLD2410::setGateParameters | ( | byte | gate, |
| byte | movingThreshold, | ||
| byte | stationaryThreshold ) |
Set the gate parameters for a particular gate, or for all gates at once.
| gate | the gate to configure; pass a value greater than 8 (e.g 0xFF) to apply the same thresholds to all gates |
| movingThreshold | [0 - 100] |
| stationaryThreshold | [0 - 100] |
| bool MyLD2410::setGateParameters | ( | const ValuesArray & | moving_thresholds, |
| const ValuesArray & | stationary_thresholds, | ||
| byte | noOneWindow = 5 ) |
Set the parameters for all gates at once, as well as the no-one window.
| moving_thresholds | as a ValueArray |
| stationary_thresholds | as a ValueArray |
| noOneWindow |
| bool MyLD2410::setMaxGate | ( | byte | movingGate, |
| byte | stationaryGate, | ||
| byte | noOneWindow = 5 ) |
Set the detection range for moving targets, stationary targets, as well as the no-one window.
| movingGate | |
| stationaryGate | |
| noOneWindow |
| bool MyLD2410::setMaxMovingGate | ( | byte | movingGate | ) |
Set the maximum moving gate.
| movingGate |
| bool MyLD2410::setMaxStationaryGate | ( | byte | stationaryGate | ) |
Set the maximum stationary gate.
| stationaryGate |
| bool MyLD2410::setMovingThreshold | ( | byte | gate, |
| byte | movingThreshold ) |
Set the moving target threshold for a particular gate.
| gate | the gate to configure [0 - 8] |
| movingThreshold | [0 - 100] |
| bool MyLD2410::setNoOneWindow | ( | byte | noOneWindow | ) |
Set the no-one window parameter.
| noOneWindow | in [s] |
| bool MyLD2410::setResolution | ( | bool | fine = false | ) |
Set the resolution of the sensor.
| fine | true=20cm; [false]=75cm |
| bool MyLD2410::setStationaryThreshold | ( | byte | gate, |
| byte | stationaryThreshold ) |
Set the stationary target threshold for a particular gate.
| gate | the gate to configure [0 - 8] |
| stationaryhreshold | [0 - 100] |
| unsigned long MyLD2410::stationaryTargetDistance | ( | ) |
Get the distance to the stationary target in [cm].
| byte MyLD2410::stationaryTargetSignal | ( | ) |
Get the signal from the stationary target.
| const char * MyLD2410::statusString | ( | ) |
Get the presence status as a c-string.