create new setting pms_wake_interval for PMS sensor interval time

This commit is contained in:
gururise 2020-04-11 10:37:12 -07:00
parent 57b28112b0
commit 54f7cf475d
2 changed files with 12 additions and 11 deletions

View File

@ -505,8 +505,9 @@ struct PACKED SYSCFG {
uint16_t zb_pan_id; // F30
uint8_t zb_channel; // F32
uint8_t zb_free_byte; // F33
uint16_t pms_wake_interval;
uint8_t free_f18[132]; // F34
uint8_t free_f18[130]; // F34
uint16_t pulse_counter_debounce_low; // FB8
uint16_t pulse_counter_debounce_high; // FBA

View File

@ -161,7 +161,7 @@ bool PmsReadData(void)
}
/*********************************************************************************************\
* Command Sensor18 (currently using mcp230xx_int_timer variable - should change)
* Command Sensor18
*
* Warmup time for sensor is 30 seconds, therfore setting interval time to less than 60
* seconds doesn't really make sense.
@ -176,14 +176,14 @@ bool PmsCommandSensor(void)
{
if (XdrvMailbox.payload < MIN_INTERVAL_PERIOD) {
// Set Active Mode if interval is less than 60 seconds
Settings.mcp230xx_int_timer = 0;
Settings.pms_wake_interval = 0;
wake_mode = 1;
pms_ready = 1;
PmsSendCmd(CMD_MODE_ACTIVE);
PmsSendCmd(CMD_WAKEUP);
} else {
// Set Passive Mode and schedule read once per interval time
Settings.mcp230xx_int_timer = XdrvMailbox.payload;
Settings.pms_wake_interval = XdrvMailbox.payload;
PmsSendCmd(CMD_MODE_PASSIVE);
PmsSendCmd(CMD_SLEEP);
wake_mode = 0;
@ -194,10 +194,10 @@ bool PmsCommandSensor(void)
if (pin[GPIO_PMS5003_TX] >= 99)
{
// setting interval not supported if TX pin not connected
Settings.mcp230xx_int_timer = 0;
Settings.pms_wake_interval = 0;
}
Response_P(S_JSON_SENSOR_INDEX_NVALUE, XSNS_18, Settings.mcp230xx_int_timer);
Response_P(S_JSON_SENSOR_INDEX_NVALUE, XSNS_18, Settings.pms_wake_interval);
return true;
}
@ -206,17 +206,17 @@ bool PmsCommandSensor(void)
void PmsSecond(void) // Every second
{
if (Settings.mcp230xx_int_timer >= MIN_INTERVAL_PERIOD)
if (Settings.pms_wake_interval >= MIN_INTERVAL_PERIOD)
{
// Passive Mode
pms_time++;
if ((Settings.mcp230xx_int_timer - pms_time <= WARMUP_PERIOD) && !wake_mode)
if ((Settings.pms_wake_interval - pms_time <= WARMUP_PERIOD) && !wake_mode)
{
// wakeup sensor WARMUP_PERIOD before read interval
wake_mode = 1;
PmsSendCmd(CMD_WAKEUP);
}
if (pms_time >= Settings.mcp230xx_int_timer)
if (pms_time >= Settings.pms_wake_interval)
{
// sensor is awake and warmed up, set up for reading
PmsSendCmd(CMD_READ_DATA);
@ -230,7 +230,7 @@ void PmsSecond(void) // Every second
if (PmsReadData())
{
pms_valid = 10;
if (Settings.mcp230xx_int_timer >= MIN_INTERVAL_PERIOD)
if (Settings.pms_wake_interval >= MIN_INTERVAL_PERIOD)
{
PmsSendCmd(CMD_SLEEP);
wake_mode = 0;
@ -242,7 +242,7 @@ void PmsSecond(void) // Every second
if (pms_valid)
{
pms_valid--;
if (Settings.mcp230xx_int_timer >= MIN_INTERVAL_PERIOD)
if (Settings.pms_wake_interval >= MIN_INTERVAL_PERIOD)
{
PmsSendCmd(CMD_READ_DATA);
pms_ready = 1;