Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P159] Extend max threshold #5140

Open
wants to merge 1 commit into
base: mega
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/_P159_LD2410.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// #######################################################################################################

/** Changelog:
* 2024-10-09 tonhuisman: Extend sensitivity max. value to 110 (experimental, was 100)
* 2023-10-29 tonhuisman: Rework processing, allow Interval = 0, as now the events will be generated when a value changes,
* but at most once per 100 msec, to not overload the ESP. Fixed the LD2410 library to work correctly
* with the event-driven scheduler model of ESPEasy, instead of the continuous loop() run of Arduino
Expand Down
12 changes: 7 additions & 5 deletions src/src/PluginStructs/P159_data_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bool P159_data_struct::processSensor(struct EventStruct *event) {

for (uint8_t i = 0; i <= mMax; ++i) {
addLog(LOG_LEVEL_INFO, strformat(F("LD2410: Sensitivity, gate %d (%.2f - %.2f mtr): moving:%3d, stationary:%3d"),
i, i * 0.75f, (i + 1) * 0.75f,
i, i * P159_GATE_DISTANCE_METERS, (i + 1) * P159_GATE_DISTANCE_METERS,
i <= mMvGate ? radar->cfgMovingGateSensitivity(i) : 0,
i <= mStGate ? radar->cfgStationaryGateSensitivity(i) : 0));
}
Expand Down Expand Up @@ -297,11 +297,11 @@ bool P159_data_struct::plugin_webform_load(struct EventStruct *event) {

for (uint8_t i = 0; i <= mMax; ++i) {
html_TR_TD();
addHtml(strformat(F("Gate %d (%.2f - %.2f mtr)"), i, i * 0.75f, (i + 1) * 0.75f));
addHtml(strformat(F("Gate %d (%.2f - %.2f mtr)"), i, i * P159_GATE_DISTANCE_METERS, (i + 1) * P159_GATE_DISTANCE_METERS));
html_TD();
addNumericBox(getPluginCustomArgName(idx++), radar->cfgMovingGateSensitivity(i), 0, 100, true);
addNumericBox(getPluginCustomArgName(idx++), radar->cfgMovingGateSensitivity(i), 0, P159_MAX_SENSITIVITY_VALUE, true);
html_TD();
addNumericBox(getPluginCustomArgName(idx++), radar->cfgStationaryGateSensitivity(i), 0, 100, true);
addNumericBox(getPluginCustomArgName(idx++), radar->cfgStationaryGateSensitivity(i), 0, P159_MAX_SENSITIVITY_VALUE, true);
}
html_end_table();
addHtml(strformat(F("\n<script type='text/javascript'>document.getElementById('saveSens')."
Expand Down Expand Up @@ -332,7 +332,9 @@ bool P159_data_struct::plugin_webform_save(struct EventStruct *event) {
const uint16_t sStat = getFormItemIntCustomArgName(idx++);

// Set sensitivity (level) to 100 to effectively disable sensitivity
radar->setGateSensitivityThreshold(gate, gate <= gMove ? sMove : 100, gate <= gStat ? sStat : 100);
radar->setGateSensitivityThreshold(gate,
gate <= gMove ? sMove : P159_MAX_SENSITIVITY_VALUE,
gate <= gStat ? sStat : P159_MAX_SENSITIVITY_VALUE);
}
radar->requestConfigurationModeEnd();
addLog(LOG_LEVEL_INFO, F("LD2410: Save sensitivity settings to sensor, done."));
Expand Down
13 changes: 8 additions & 5 deletions src/src/PluginStructs/P159_data_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@
# define P159_OUTPUT_MOVING_SENSOR_ENERGY_GATE0 37
# define P159_OUTPUT_MOVING_SENSOR_ENERGY_GATE8 45

# define P159_NR_OUTPUT_OPTIONS 8 // Last P159_OUTPUT_*_DISTANCE value + 1 (count)
# define P159_NR_ENGINEERING_OUTPUT_OPTIONS 28 // Last P159_OUTPUT_*_DISTANCE value + 1 (count) ENGINEERING
# define P159_NR_MAX_OUTPUT_OPTIONS 46 // Last P159_OUTPUT_*_SENSOR value + 1 (count)
# define P159_NR_OUTPUT_OPTIONS 8 // Last P159_OUTPUT_*_DISTANCE value + 1 (count)
# define P159_NR_ENGINEERING_OUTPUT_OPTIONS 28 // Last P159_OUTPUT_*_DISTANCE value + 1 (count) ENGINEERING
# define P159_NR_MAX_OUTPUT_OPTIONS 46 // Last P159_OUTPUT_*_SENSOR value + 1 (count)

# define P159_DELAY_RESTART 2500 // milliseconds to 'wait' (ignore) after a device-restart
# define P159_DELAY_SENDOUT 100 // Minimal milliseconds between sending data/events
# define P159_DELAY_RESTART 2500 // milliseconds to 'wait' (ignore) after a device-restart
# define P159_DELAY_SENDOUT 100 // Minimal milliseconds between sending data/events

# define P159_MAX_SENSITIVITY_VALUE 110 // Max sensitivity 0 = most sensitive, 100 = least sensitive (docs)
# define P159_GATE_DISTANCE_METERS 0.75f // Size of each gate in meters (0.75f)

enum class P159_state_e : uint8_t {
Initializing = 0u,
Expand Down