mirror of https://github.com/arendst/Tasmota.git
6.5.0.3 Add command Sensor20
6.5.0.3 20190328 * Add command Sensor20 1..255 to change Nova Fitness SDS01 working period in minutes (#5452)
This commit is contained in:
parent
e631d49d0f
commit
e8e5d1c03c
|
@ -1,4 +1,7 @@
|
|||
/* 6.5.0.2 20190325
|
||||
/* 6.5.0.3 20190328
|
||||
* Add command Sensor20 1..255 to change Nova Fitness SDS01 working period in minutes (#5452)
|
||||
*
|
||||
* 6.5.0.2 20190325
|
||||
* Change UDP initial message handling from string to char using static memory and add debug info (#5505)
|
||||
* Add optional support for Badger HR-E Water Meter (#5539)
|
||||
*
|
||||
|
|
|
@ -330,8 +330,9 @@ struct SYSCFG {
|
|||
uint8_t rgbwwTable[5]; // 71A
|
||||
uint8_t user_template_base; // 71F
|
||||
mytmplt user_template; // 720 29 bytes
|
||||
uint8_t novasds_period; // 73D
|
||||
|
||||
uint8_t free_73D[87]; // 73D
|
||||
uint8_t free_73D[86]; // 73E
|
||||
|
||||
uint32_t drivers[3]; // 794
|
||||
uint32_t monitors; // 7A0
|
||||
|
|
|
@ -815,6 +815,8 @@ void SettingsDefaultSet2(void)
|
|||
Settings.rgbwwTable[j] = 255;
|
||||
}
|
||||
|
||||
Settings.novasds_period = WORKING_PERIOD;
|
||||
|
||||
memset(&Settings.drivers, 0xFF, 32); // Enable all possible monitors, displays, drivers and sensors
|
||||
}
|
||||
|
||||
|
@ -1055,6 +1057,9 @@ void SettingsDelta(void)
|
|||
if (Settings.version < 0x06040113) {
|
||||
Settings.param[P_RGB_REMAP] = RGB_REMAP_RGBW;
|
||||
}
|
||||
if (Settings.version < 0x06050003) {
|
||||
Settings.novasds_period = WORKING_PERIOD;
|
||||
}
|
||||
|
||||
Settings.version = VERSION;
|
||||
SettingsSave(1);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef _SONOFF_VERSION_H_
|
||||
#define _SONOFF_VERSION_H_
|
||||
|
||||
#define VERSION 0x06050002
|
||||
#define VERSION 0x06050003
|
||||
|
||||
#define D_PROGRAMNAME "Sonoff-Tasmota"
|
||||
#define D_AUTHOR "Theo Arends"
|
||||
|
|
|
@ -47,13 +47,11 @@
|
|||
#define NOVA_SDS_DEVICE_ID 0xFFFF // NodaSDS all sensor response
|
||||
#endif
|
||||
|
||||
|
||||
TasmotaSerial *NovaSdsSerial;
|
||||
|
||||
uint8_t novasds_type = 1;
|
||||
uint8_t novasds_valid = 0;
|
||||
|
||||
|
||||
struct sds011data {
|
||||
uint16_t pm100;
|
||||
uint16_t pm25;
|
||||
|
@ -126,9 +124,9 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor
|
|||
void NovaSdsSetWorkPeriod(void)
|
||||
{
|
||||
// set sensor working period
|
||||
NovaSdsCommand(NOVA_SDS_WORKING_PERIOD, NOVA_SDS_SET_MODE, WORKING_PERIOD, NOVA_SDS_DEVICE_ID, nullptr);
|
||||
NovaSdsCommand(NOVA_SDS_WORKING_PERIOD, NOVA_SDS_SET_MODE, Settings.novasds_period, NOVA_SDS_DEVICE_ID, nullptr);
|
||||
// set sensor report only on query
|
||||
NovaSdsCommand(NOVA_SDS_REPORTING_MODE, NOVA_SDS_SET_MODE, NOVA_SDS_REPORT_QUERY, NOVA_SDS_DEVICE_ID, nullptr);
|
||||
NovaSdsCommand(NOVA_SDS_REPORTING_MODE, NOVA_SDS_SET_MODE, NOVA_SDS_REPORT_QUERY, NOVA_SDS_DEVICE_ID, nullptr);
|
||||
}
|
||||
|
||||
bool NovaSdsReadData(void)
|
||||
|
@ -162,7 +160,22 @@ void NovaSdsSecond(void) // Every second
|
|||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************/
|
||||
/*********************************************************************************************\
|
||||
* Command Sensor20
|
||||
*
|
||||
* 1 .. 255 - Set working period in minutes
|
||||
\*********************************************************************************************/
|
||||
|
||||
bool NovaSdsCommandSensor(void)
|
||||
{
|
||||
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 256)) {
|
||||
Settings.novasds_period = XdrvMailbox.payload;
|
||||
NovaSdsSetWorkPeriod();
|
||||
}
|
||||
Response_P(S_JSON_SENSOR_INDEX_NVALUE, XSNS_20, Settings.novasds_period);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NovaSdsInit(void)
|
||||
{
|
||||
|
@ -226,6 +239,11 @@ bool Xsns20(uint8_t function)
|
|||
case FUNC_EVERY_SECOND:
|
||||
NovaSdsSecond();
|
||||
break;
|
||||
case FUNC_COMMAND_SENSOR:
|
||||
if (XSNS_20 == XdrvMailbox.index) {
|
||||
result = NovaSdsCommandSensor();
|
||||
}
|
||||
break;
|
||||
case FUNC_JSON_APPEND:
|
||||
NovaSdsShow(1);
|
||||
break;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef USE_HRE
|
||||
/*********************************************************************************************\
|
||||
* HR-E LCD Water meter register interface
|
||||
*
|
||||
|
@ -27,26 +28,24 @@
|
|||
* KG44?Q45484=0444444V;RB000000022;IB018435683
|
||||
* where the RB...; is the miligalons used
|
||||
*
|
||||
* Note that this sensor takes a _long_ time to read. 62 bits * 4 ms/bit for the
|
||||
* Note that this sensor takes a _long_ time to read. 62 bits * 4 ms/bit for the
|
||||
* sync sequence plus 46 bytes * 40 ms/byte = 2088 ms minimum. If we aren't alligned
|
||||
* to the sync sequence, it could be almost twice that.
|
||||
* To keep from bogging the kernel down, we read 8 bits at a time on the 50 ms callback.
|
||||
* It will take seconds to discover if the device is there.
|
||||
*
|
||||
* In lieu of an actual schematic to describe the electrical interface, here is a description:
|
||||
*
|
||||
*
|
||||
* hre_clock_pin: drives the power/clock for the water meter through a 1k resister to
|
||||
* the base of a pnp transistor
|
||||
* hre_data_pin: is the data and has a 1 k pulldown
|
||||
*
|
||||
*
|
||||
* The pnp transitor has the collector connected to the power/clock and is pulled up
|
||||
* to +5 via a 1 k resistor.
|
||||
* The emitter is connected to ground
|
||||
*
|
||||
*
|
||||
\*********************************************************************************************/
|
||||
|
||||
#ifdef USE_HRE
|
||||
|
||||
#define XSNS_43 43
|
||||
|
||||
enum hre_states {
|
||||
|
@ -110,14 +109,14 @@ void hreInit(void)
|
|||
{
|
||||
hre_read_errors = 0;
|
||||
hre_good = false;
|
||||
|
||||
|
||||
pinMode(pin[GPIO_HRE_CLOCK], OUTPUT);
|
||||
pinMode(pin[GPIO_HRE_DATA], INPUT);
|
||||
|
||||
// Note that the level shifter inverts this line and we want to leave it
|
||||
// high when not being read.
|
||||
digitalWrite(pin[GPIO_HRE_CLOCK], LOW);
|
||||
|
||||
|
||||
hre_state = hre_sync;
|
||||
}
|
||||
|
||||
|
@ -134,7 +133,7 @@ void hreEvery50ms(void)
|
|||
|
||||
static char ch;
|
||||
static size_t i;
|
||||
|
||||
|
||||
switch (hre_state)
|
||||
{
|
||||
case hre_sync:
|
||||
|
@ -145,7 +144,7 @@ void hreEvery50ms(void)
|
|||
hre_state = hre_syncing;
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_syncing"));
|
||||
break;
|
||||
|
||||
|
||||
case hre_syncing:
|
||||
// Find the header, a string of 62 '1's
|
||||
// Since each bit taks 2 ms, we just read 20 bits at a time
|
||||
|
@ -183,12 +182,12 @@ void hreEvery50ms(void)
|
|||
// it seems that if there is much of a delay between getting the sync
|
||||
// bits and starting the read, the HRE won't output the message we
|
||||
// are looking for...
|
||||
|
||||
|
||||
case hre_reading:
|
||||
// Read two characters at a time...
|
||||
buff[read_counter++] = hreReadChar(parity_errors);
|
||||
buff[read_counter++] = hreReadChar(parity_errors);
|
||||
|
||||
|
||||
if (read_counter == 46)
|
||||
{
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "pe:%d, re:%d, buff:%s"),
|
||||
|
@ -205,7 +204,7 @@ void hreEvery50ms(void)
|
|||
hre_usage = curr_usage;
|
||||
hre_usage_time = curr_start;
|
||||
hre_good = true;
|
||||
|
||||
|
||||
hre_state = hre_sleep;
|
||||
}
|
||||
else
|
||||
|
@ -215,7 +214,7 @@ void hreEvery50ms(void)
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case hre_sleep:
|
||||
hre_usage_time = curr_start;
|
||||
hre_state = hre_sleeping;
|
||||
|
@ -233,14 +232,14 @@ void hreShow(boolean json)
|
|||
{
|
||||
if (!hre_good)
|
||||
return;
|
||||
|
||||
|
||||
const char *id = "HRE";
|
||||
|
||||
char usage[16];
|
||||
char rate[16];
|
||||
dtostrfd(hre_usage, 2, usage);
|
||||
dtostrfd(hre_rate, 3, rate);
|
||||
|
||||
|
||||
if (json)
|
||||
{
|
||||
ResponseAppend_P(JSON_SNS_GNGPM, id, usage, rate);
|
||||
|
@ -263,7 +262,7 @@ bool Xsns43(byte function)
|
|||
// If we don't have pins assigned give up quickly.
|
||||
if (pin[GPIO_HRE_CLOCK] >= 99 || pin[GPIO_HRE_DATA] >= 99)
|
||||
return false;
|
||||
|
||||
|
||||
switch (function)
|
||||
{
|
||||
case FUNC_INIT:
|
||||
|
|
Loading…
Reference in New Issue