2018-10-21 11:44:45 +01:00
|
|
|
/*
|
2020-02-20 17:50:43 +00:00
|
|
|
xsns_35_Tx20.ino - La Crosse Tx20/Tx23 wind sensor support for Tasmota
|
2018-10-21 11:44:45 +01:00
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
Copyright (C) 2020 Thomas Eckerstorfer, Norbert Richter and Theo Arends
|
2018-10-21 11:44:45 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
#if defined(USE_TX20_WIND_SENSOR) || defined(USE_TX23_WIND_SENSOR)
|
|
|
|
#if defined(USE_TX20_WIND_SENSOR) && defined(USE_TX23_WIND_SENSOR)
|
|
|
|
#undef USE_TX20_WIND_SENSOR
|
|
|
|
#warning **** use USE_TX20_WIND_SENSOR or USE_TX23_WIND_SENSOR but not both together, TX20 disabled ****
|
|
|
|
#endif
|
2018-10-21 11:44:45 +01:00
|
|
|
/*********************************************************************************************\
|
2020-02-20 17:50:43 +00:00
|
|
|
* La Crosse TX20/TX23 Anemometer
|
2018-10-21 11:44:45 +01:00
|
|
|
*
|
|
|
|
* based on https://github.com/bunnyhu/ESP8266_TX20_wind_sensor/
|
|
|
|
* http://blog.bubux.de/windsensor-tx20-mit-esp8266/
|
|
|
|
* https://www.john.geek.nz/2011/07/la-crosse-tx20-anemometer-communication-protocol/
|
2020-02-20 17:50:43 +00:00
|
|
|
* http://www.rd-1000.com/chpm78/lacrosse/Lacrosse_TX23_protocol.html
|
|
|
|
* https://www.john.geek.nz/2012/08/la-crosse-tx23u-anemometer-communication-protocol/
|
|
|
|
*
|
|
|
|
* TX23 RJ11 connection:
|
|
|
|
* 1 yellow - GND
|
|
|
|
* 2 green - NC
|
|
|
|
* 3 red - Vcc 3.3V
|
|
|
|
* 4 black/brown - TxD Signal (GPIOxx)
|
2018-10-21 11:44:45 +01:00
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2018-11-06 16:33:51 +00:00
|
|
|
#define XSNS_35 35
|
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
#define TX2X_BIT_TIME 1220 // microseconds
|
2020-02-24 16:25:03 +00:00
|
|
|
#define TX2X_WEIGHT_AVG_SAMPLE 150 // seconds
|
|
|
|
#define TX23_READ_INTERVAL 4 // seconds (don't use less than 3)
|
2018-10-21 11:44:45 +01:00
|
|
|
|
|
|
|
// The Arduino standard GPIO routines are not enough,
|
|
|
|
// must use some from the Espressif SDK as well
|
|
|
|
extern "C" {
|
|
|
|
#include "gpio.h"
|
|
|
|
}
|
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
#ifdef USE_TX20_WIND_SENSOR
|
|
|
|
#define D_TX2x_NAME "TX20"
|
|
|
|
#else
|
|
|
|
#define D_TX2x_NAME "TX23"
|
|
|
|
#endif
|
2018-10-21 11:44:45 +01:00
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
#ifdef USE_WEBSERVER
|
|
|
|
const char HTTP_SNS_TX2X[] PROGMEM =
|
|
|
|
"{s}" D_TX2x_NAME " " D_TX20_WIND_SPEED "{m}%s " D_UNIT_KILOMETER_PER_HOUR "{e}"
|
|
|
|
"{s}" D_TX2x_NAME " " D_TX20_WIND_SPEED_AVG "{m}%s " D_UNIT_KILOMETER_PER_HOUR "{e}"
|
2020-02-24 16:25:03 +00:00
|
|
|
"{s}" D_TX2x_NAME " " D_TX20_WIND_SPEED_MIN "{m}%s " D_UNIT_KILOMETER_PER_HOUR "{e}"
|
2020-02-20 17:50:43 +00:00
|
|
|
"{s}" D_TX2x_NAME " " D_TX20_WIND_SPEED_MAX "{m}%s " D_UNIT_KILOMETER_PER_HOUR "{e}"
|
2020-02-24 16:25:03 +00:00
|
|
|
"{s}" D_TX2x_NAME " " D_TX20_WIND_DIRECTION "{m}%s %s°{e}";
|
2018-10-21 11:44:45 +01:00
|
|
|
#endif // USE_WEBSERVER
|
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
const char kTx2xDirections[] PROGMEM = D_TX20_NORTH "|"
|
2018-10-21 11:44:45 +01:00
|
|
|
D_TX20_NORTH D_TX20_NORTH D_TX20_EAST "|"
|
|
|
|
D_TX20_NORTH D_TX20_EAST "|"
|
|
|
|
D_TX20_EAST D_TX20_NORTH D_TX20_EAST "|"
|
|
|
|
D_TX20_EAST "|"
|
|
|
|
D_TX20_EAST D_TX20_SOUTH D_TX20_EAST "|"
|
|
|
|
D_TX20_SOUTH D_TX20_EAST "|"
|
|
|
|
D_TX20_SOUTH D_TX20_SOUTH D_TX20_EAST "|"
|
|
|
|
D_TX20_SOUTH "|"
|
|
|
|
D_TX20_SOUTH D_TX20_SOUTH D_TX20_WEST "|"
|
|
|
|
D_TX20_SOUTH D_TX20_WEST "|"
|
|
|
|
D_TX20_WEST D_TX20_SOUTH D_TX20_WEST "|"
|
|
|
|
D_TX20_WEST "|"
|
|
|
|
D_TX20_WEST D_TX20_NORTH D_TX20_WEST "|"
|
|
|
|
D_TX20_NORTH D_TX20_WEST "|"
|
|
|
|
D_TX20_NORTH D_TX20_NORTH D_TX20_WEST;
|
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
uint8_t tx2x_sa = 0;
|
|
|
|
uint8_t tx2x_sb = 0;
|
|
|
|
uint8_t tx2x_sd = 0;
|
|
|
|
uint8_t tx2x_se = 0;
|
|
|
|
uint16_t tx2x_sc = 0;
|
|
|
|
uint16_t tx2x_sf = 0;
|
|
|
|
|
|
|
|
float tx2x_wind_speed_kmh = 0;
|
2020-02-24 16:25:03 +00:00
|
|
|
float tx2x_wind_speed_min = 200.0;
|
2020-02-20 17:50:43 +00:00
|
|
|
float tx2x_wind_speed_max = 0;
|
|
|
|
float tx2x_wind_speed_avg = 0;
|
|
|
|
uint8_t tx2x_wind_direction = 0;
|
2020-02-24 16:25:03 +00:00
|
|
|
int tx2x_count = 0;
|
|
|
|
uint16_t tx2x_avg_samples;
|
2018-10-21 11:44:45 +01:00
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
bool tx2x_available = false;
|
2018-10-21 11:44:45 +01:00
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
#ifdef USE_TX23_WIND_SENSOR
|
|
|
|
uint8_t tx23_stage = 0;
|
|
|
|
#endif
|
2018-10-21 11:44:45 +01:00
|
|
|
|
2019-05-22 09:39:37 +01:00
|
|
|
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
|
2020-02-20 17:50:43 +00:00
|
|
|
void TX2xStartRead(void) ICACHE_RAM_ATTR; // As iram is tight and it works this way too
|
2019-05-22 09:39:37 +01:00
|
|
|
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
void TX2xStartRead(void)
|
2018-10-21 11:44:45 +01:00
|
|
|
{
|
2020-02-20 17:50:43 +00:00
|
|
|
/**
|
|
|
|
* La Crosse TX20 Anemometer datagram every 2 seconds
|
2018-10-21 11:44:45 +01:00
|
|
|
* 0-0 11011 0011 111010101111 0101 1100 000101010000 0-0 - Received pin data at 1200 uSec per bit
|
|
|
|
* sa sb sc sd se sf
|
|
|
|
* 00100 1100 000101010000 1010 1100 000101010000 - sa to sd inverted user data, LSB first
|
2020-02-20 17:50:43 +00:00
|
|
|
* sa - Start frame (invert) 00100
|
|
|
|
* sb - Wind direction (invert) 0 - 15
|
|
|
|
* sc - Wind speed 0 (invert) - 511
|
|
|
|
* sd - Checksum (invert)
|
|
|
|
* se - Wind direction 0 - 15
|
|
|
|
* sf - Wind speed 0 - 511
|
|
|
|
*
|
|
|
|
* La Crosse TX23 Anemometer datagram after setting TxD to low/high
|
|
|
|
* 1-1 0 1 0-0 11011 0011 111010101111 0101 1100 000101010000 1-1 - Received pin data at 1200 uSec per bit
|
|
|
|
* t s c sa sb sc sd se sf
|
|
|
|
* t - host pulls TxD low - signals TX23 to sent measurement
|
|
|
|
* s - TxD released - TxD is pulled high due to pullup
|
|
|
|
* c - TX23U pulls TxD low - calculation in progress
|
|
|
|
* sa - Start frame 11011
|
2018-10-21 11:44:45 +01:00
|
|
|
* sb - Wind direction 0 - 15
|
|
|
|
* sc - Wind speed 0 - 511
|
|
|
|
* sd - Checksum
|
2020-02-20 17:50:43 +00:00
|
|
|
* se - Wind direction (invert) 0 - 15
|
|
|
|
* sf - Wind speed (invert) 0 - 511
|
2018-10-21 11:44:45 +01:00
|
|
|
*/
|
2020-02-20 17:50:43 +00:00
|
|
|
#ifdef USE_TX23_WIND_SENSOR
|
|
|
|
if (0!=tx23_stage)
|
|
|
|
{
|
|
|
|
if ((2==tx23_stage) || (3==tx23_stage))
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
tx2x_available = false;
|
|
|
|
|
|
|
|
tx2x_sa = 0;
|
|
|
|
tx2x_sb = 0;
|
|
|
|
tx2x_sd = 0;
|
|
|
|
tx2x_se = 0;
|
|
|
|
tx2x_sc = 0;
|
|
|
|
tx2x_sf = 0;
|
|
|
|
|
|
|
|
delayMicroseconds(TX2X_BIT_TIME / 2);
|
|
|
|
|
|
|
|
for (int32_t bitcount = 41; bitcount > 0; bitcount--) {
|
|
|
|
uint8_t dpin = (digitalRead(pin[GPIO_TX2X_TXD_BLACK]));
|
|
|
|
#ifdef USE_TX23_WIND_SENSOR
|
2020-02-24 16:25:03 +00:00
|
|
|
dpin ^= 1;
|
|
|
|
#endif
|
2020-02-20 17:50:43 +00:00
|
|
|
if (bitcount > 41 - 5) {
|
|
|
|
// start frame (invert)
|
|
|
|
tx2x_sa = (tx2x_sa << 1) | (dpin ^ 1);
|
|
|
|
} else if (bitcount > 41 - 5 - 4) {
|
|
|
|
// wind dir (invert)
|
|
|
|
tx2x_sb = tx2x_sb >> 1 | ((dpin ^ 1) << 3);
|
|
|
|
} else if (bitcount > 41 - 5 - 4 - 12) {
|
|
|
|
// windspeed (invert)
|
|
|
|
tx2x_sc = tx2x_sc >> 1 | ((dpin ^ 1) << 11);
|
|
|
|
} else if (bitcount > 41 - 5 - 4 - 12 - 4) {
|
|
|
|
// checksum (invert)
|
|
|
|
tx2x_sd = tx2x_sd >> 1 | ((dpin ^ 1) << 3);
|
|
|
|
} else if (bitcount > 41 - 5 - 4 - 12 - 4 - 4) {
|
|
|
|
// wind dir
|
|
|
|
tx2x_se = tx2x_se >> 1 | (dpin << 3);
|
|
|
|
} else {
|
|
|
|
// windspeed
|
|
|
|
tx2x_sf = tx2x_sf >> 1 | (dpin << 11);
|
|
|
|
}
|
|
|
|
delayMicroseconds(TX2X_BIT_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t chk = (tx2x_sb + (tx2x_sc & 0xf) + ((tx2x_sc >> 4) & 0xf) + ((tx2x_sc >> 8) & 0xf));
|
|
|
|
chk &= 0xf;
|
|
|
|
|
|
|
|
// check checksum, non-inverted with inverted values and max. speed
|
2020-02-24 16:25:03 +00:00
|
|
|
tx2x_available = ((chk == tx2x_sd) && (tx2x_sb==tx2x_se) && (tx2x_sc==tx2x_sf) && (tx2x_sc < 511));
|
2020-02-20 17:50:43 +00:00
|
|
|
#ifdef USE_TX23_WIND_SENSOR
|
2018-10-21 11:44:45 +01:00
|
|
|
}
|
2020-02-20 17:50:43 +00:00
|
|
|
tx23_stage++;
|
2018-10-21 11:44:45 +01:00
|
|
|
}
|
2020-02-20 17:50:43 +00:00
|
|
|
#endif
|
2018-10-21 11:44:45 +01:00
|
|
|
|
|
|
|
// Must clear this bit in the interrupt register,
|
|
|
|
// it gets set even when interrupts are disabled
|
2020-02-20 17:50:43 +00:00
|
|
|
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << pin[GPIO_TX2X_TXD_BLACK]);
|
2018-10-21 11:44:45 +01:00
|
|
|
}
|
|
|
|
|
2020-02-24 16:25:03 +00:00
|
|
|
void Tx2xResetStat(void)
|
2018-10-21 11:44:45 +01:00
|
|
|
{
|
2020-02-24 16:25:03 +00:00
|
|
|
tx2x_wind_speed_min = tx2x_wind_speed_kmh;
|
|
|
|
tx2x_wind_speed_max = tx2x_wind_speed_kmh;
|
|
|
|
uint16_t tx2x_prev_avg_samples = tx2x_avg_samples;
|
|
|
|
if (Settings.tele_period) {
|
|
|
|
// number for avg samples = teleperiod value if set
|
|
|
|
tx2x_avg_samples = Settings.tele_period;
|
|
|
|
} else {
|
|
|
|
// otherwise use default number of samples for this driver
|
|
|
|
tx2x_avg_samples = TX2X_WEIGHT_AVG_SAMPLE;
|
|
|
|
}
|
|
|
|
if (tx2x_prev_avg_samples != tx2x_avg_samples) {
|
|
|
|
tx2x_wind_speed_avg = tx2x_wind_speed_kmh;
|
2020-02-20 17:50:43 +00:00
|
|
|
tx2x_count = 0;
|
2020-02-24 16:25:03 +00:00
|
|
|
}
|
2020-02-20 17:50:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Tx2xRead(void)
|
|
|
|
{
|
|
|
|
#ifdef USE_TX23_WIND_SENSOR
|
2020-02-24 16:25:03 +00:00
|
|
|
// TX23 needs to trigger start transmission - TxD Line
|
|
|
|
// ___________ _ ___ ___
|
|
|
|
// |____| |___________| |_| |__XXXXXXXXXX
|
|
|
|
// trigger start conv Startframe Data
|
|
|
|
//
|
2020-02-20 17:50:43 +00:00
|
|
|
// note: TX23 speed calculation is unstable when conversion starts
|
|
|
|
// less than 2 seconds after last request
|
2020-02-24 16:25:03 +00:00
|
|
|
if ((uptime % TX23_READ_INTERVAL)==0) {
|
2020-02-20 17:50:43 +00:00
|
|
|
// TX23 start transmission by pulling down TxD line for at minimum 500ms
|
|
|
|
// so we pull TxD signal to low every 3 seconds
|
|
|
|
tx23_stage = 0;
|
|
|
|
pinMode(pin[GPIO_TX2X_TXD_BLACK], OUTPUT);
|
|
|
|
digitalWrite(pin[GPIO_TX2X_TXD_BLACK], LOW);
|
2020-02-24 16:25:03 +00:00
|
|
|
} else if ((uptime % TX23_READ_INTERVAL)==1) {
|
|
|
|
// after pulling down TxD: pull-up TxD every x+1 seconds
|
|
|
|
// to trigger TX23 start transmission
|
2020-02-20 17:50:43 +00:00
|
|
|
tx23_stage = 1; // first rising signal is invalid
|
|
|
|
pinMode(pin[GPIO_TX2X_TXD_BLACK], INPUT_PULLUP);
|
2018-10-21 11:44:45 +01:00
|
|
|
}
|
2020-02-20 17:50:43 +00:00
|
|
|
#endif
|
2020-02-24 16:25:03 +00:00
|
|
|
if (0!=Settings.tele_period && Settings.tele_period!=tx2x_avg_samples) {
|
|
|
|
// new teleperiod value
|
|
|
|
Tx2xResetStat();
|
2020-02-20 17:50:43 +00:00
|
|
|
}
|
2020-02-24 16:25:03 +00:00
|
|
|
if (tx2x_available) {
|
2020-02-20 17:50:43 +00:00
|
|
|
// Wind speed spec: 0 to 180 km/h (0 to 50 m/s)
|
|
|
|
tx2x_wind_speed_kmh = float(tx2x_sc) * 0.36;
|
2020-02-24 16:25:03 +00:00
|
|
|
if (tx2x_wind_speed_kmh < tx2x_wind_speed_min) {
|
|
|
|
tx2x_wind_speed_min = tx2x_wind_speed_kmh;
|
|
|
|
}
|
2020-02-20 17:50:43 +00:00
|
|
|
if (tx2x_wind_speed_kmh > tx2x_wind_speed_max) {
|
|
|
|
tx2x_wind_speed_max = tx2x_wind_speed_kmh;
|
2018-10-21 11:44:45 +01:00
|
|
|
}
|
2020-02-24 16:25:03 +00:00
|
|
|
// exponentially weighted average is not quite as smooth as the arithmetic average
|
|
|
|
// but close enough to the moving average and does not require the regular reset
|
|
|
|
// of the divider with the associated jump in avg values after period is over
|
|
|
|
if (tx2x_count <= tx2x_avg_samples) {
|
|
|
|
tx2x_count++;
|
|
|
|
}
|
|
|
|
tx2x_wind_speed_avg -= tx2x_wind_speed_avg / tx2x_count;
|
|
|
|
tx2x_wind_speed_avg += tx2x_wind_speed_kmh / tx2x_count;
|
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
tx2x_wind_direction = tx2x_sb;
|
2020-02-24 16:25:03 +00:00
|
|
|
|
|
|
|
if (!(uptime % tx2x_avg_samples)) {
|
|
|
|
tx2x_wind_speed_min = tx2x_wind_speed_kmh;
|
|
|
|
tx2x_wind_speed_max = tx2x_wind_speed_kmh;
|
|
|
|
|
|
|
|
}
|
2018-10-21 11:44:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
void Tx2xInit(void)
|
|
|
|
{
|
2020-02-24 16:25:03 +00:00
|
|
|
Tx2xResetStat();
|
2020-02-20 17:50:43 +00:00
|
|
|
#ifdef USE_TX23_WIND_SENSOR
|
|
|
|
tx23_stage = 0;
|
|
|
|
pinMode(pin[GPIO_TX2X_TXD_BLACK], OUTPUT);
|
|
|
|
digitalWrite(pin[GPIO_TX2X_TXD_BLACK], LOW);
|
|
|
|
#else
|
|
|
|
pinMode(pin[GPIO_TX2X_TXD_BLACK], INPUT);
|
|
|
|
#endif
|
|
|
|
attachInterrupt(pin[GPIO_TX2X_TXD_BLACK], TX2xStartRead, RISING);
|
2018-10-21 11:44:45 +01:00
|
|
|
}
|
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
void Tx2xShow(bool json)
|
2018-10-21 11:44:45 +01:00
|
|
|
{
|
2018-12-21 15:17:06 +00:00
|
|
|
char wind_speed_string[33];
|
2020-02-20 17:50:43 +00:00
|
|
|
dtostrfd(tx2x_wind_speed_kmh, 1, wind_speed_string);
|
2020-02-24 16:25:03 +00:00
|
|
|
char wind_speed_min_string[33];
|
|
|
|
dtostrfd(tx2x_wind_speed_min, 1, wind_speed_min_string);
|
2018-12-21 15:17:06 +00:00
|
|
|
char wind_speed_max_string[33];
|
2020-02-20 17:50:43 +00:00
|
|
|
dtostrfd(tx2x_wind_speed_max, 1, wind_speed_max_string);
|
2018-12-21 15:17:06 +00:00
|
|
|
char wind_speed_avg_string[33];
|
2020-02-20 17:50:43 +00:00
|
|
|
dtostrfd(tx2x_wind_speed_avg, 1, wind_speed_avg_string);
|
2020-02-24 16:25:03 +00:00
|
|
|
char wind_direction_degree_string[33];
|
|
|
|
dtostrfd(tx2x_wind_direction*22.5, 1, wind_direction_degree_string);
|
2018-12-21 15:17:06 +00:00
|
|
|
char wind_direction_string[4];
|
2020-02-20 17:50:43 +00:00
|
|
|
GetTextIndexed(wind_direction_string, sizeof(wind_direction_string), tx2x_wind_direction, kTx2xDirections);
|
2018-10-21 11:44:45 +01:00
|
|
|
|
|
|
|
if (json) {
|
2020-02-24 16:25:03 +00:00
|
|
|
#ifdef USE_TX2x_LEGACY_JSON
|
2020-02-20 17:50:43 +00:00
|
|
|
ResponseAppend_P(PSTR(",\"" D_TX2x_NAME "\":{\"Speed\":%s,\"SpeedAvg\":%s,\"SpeedMax\":%s,\"Direction\":\"%s\",\"Degree\":%s}"),
|
|
|
|
wind_speed_string, wind_speed_avg_string, wind_speed_max_string, wind_direction_string, wind_direction_degree);
|
2020-02-24 16:25:03 +00:00
|
|
|
#else
|
|
|
|
// new format grouped by Speed and Dir(ection)
|
|
|
|
// Card = cardianal (N../O../S../W..)
|
|
|
|
// Deg = Degree
|
|
|
|
ResponseAppend_P(
|
|
|
|
PSTR(",\"" D_TX2x_NAME "\":{\"Speed\":{\"Act\":%s,\"Avg\":%s,\"Min\":%s,\"Max\":%s},\"Direction\":{\"Cardinal\":\"%s\",\"Degree\":%s}}"),
|
|
|
|
wind_speed_string,
|
|
|
|
wind_speed_avg_string,
|
|
|
|
wind_speed_min_string,
|
|
|
|
wind_speed_max_string,
|
|
|
|
wind_direction_string,
|
|
|
|
wind_direction_degree_string
|
|
|
|
);
|
|
|
|
#endif
|
2018-10-21 11:44:45 +01:00
|
|
|
#ifdef USE_WEBSERVER
|
|
|
|
} else {
|
2020-02-24 16:25:03 +00:00
|
|
|
WSContentSend_PD(
|
|
|
|
HTTP_SNS_TX2X,
|
|
|
|
wind_speed_string,
|
|
|
|
wind_speed_avg_string,
|
|
|
|
wind_speed_min_string,
|
|
|
|
wind_speed_max_string,
|
|
|
|
wind_direction_string,
|
|
|
|
wind_direction_degree_string
|
|
|
|
);
|
2018-10-21 11:44:45 +01:00
|
|
|
#endif // USE_WEBSERVER
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************************\
|
|
|
|
* Interface
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
bool Xsns35(uint8_t function)
|
2018-10-21 11:44:45 +01:00
|
|
|
{
|
2019-01-28 13:08:33 +00:00
|
|
|
bool result = false;
|
2018-10-21 11:44:45 +01:00
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
if (pin[GPIO_TX2X_TXD_BLACK] < 99) {
|
2018-10-21 11:44:45 +01:00
|
|
|
switch (function) {
|
|
|
|
case FUNC_INIT:
|
2020-02-20 17:50:43 +00:00
|
|
|
Tx2xInit();
|
2018-10-21 11:44:45 +01:00
|
|
|
break;
|
|
|
|
case FUNC_EVERY_SECOND:
|
2020-02-20 17:50:43 +00:00
|
|
|
Tx2xRead();
|
2018-10-21 11:44:45 +01:00
|
|
|
break;
|
|
|
|
case FUNC_JSON_APPEND:
|
2020-02-24 16:25:03 +00:00
|
|
|
Tx2xShow(true);
|
2018-10-21 11:44:45 +01:00
|
|
|
break;
|
|
|
|
#ifdef USE_WEBSERVER
|
2019-03-19 16:31:43 +00:00
|
|
|
case FUNC_WEB_SENSOR:
|
2020-02-24 16:25:03 +00:00
|
|
|
Tx2xShow(false);
|
2018-10-21 11:44:45 +01:00
|
|
|
break;
|
|
|
|
#endif // USE_WEBSERVER
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-02-20 17:50:43 +00:00
|
|
|
#endif // USE_TX20_WIND_SENSOR || USE_TX23_WIND_SENSOR
|