Skip to content

Commit

Permalink
Weather station update (#2209)
Browse files Browse the repository at this point in the history
* Acurite609txc fix

* Added Kedsum

* Add auriol 5in1

* prev was: FPW_Acurite5in1, this is EmosE601x

* Remove BTN from weather
Saved flash space by creating chaos.
Fix EmosE601
  • Loading branch information
htotoo committed Jul 24, 2024
1 parent 2fdd531 commit 5d9428e
Show file tree
Hide file tree
Showing 27 changed files with 492 additions and 59 deletions.
7 changes: 6 additions & 1 deletion firmware/application/apps/ui_weatherstation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,12 @@ const char* WeatherView::getWeatherSensorTypeName(FPROTO_WEATHER_SENSOR type) {
return "Wendox W6726";
case FPW_Acurite986:
return "Acurite986";

case FPW_KEDSUM:
return "Kedsum";
case FPW_Acurite5in1:
return "Acurite5in1";
case FPW_EmosE601x:
return "EmosE601x";
case FPW_Invalid:
default:
return "Unknown";
Expand Down
1 change: 0 additions & 1 deletion firmware/baseband/fprotos/w-acurite592txr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ class FProtoWeatherAcurite592TXR : public FProtoWeatherBase {
humidity = (data >> 24) & 0x7F;
uint16_t temp_raw = ((data >> 9) & 0xF80) | ((data >> 8) & 0x7F);
temp = ((float)(temp_raw)-1000) / 10.0f;
btn = WS_NO_BTN;
}
};

Expand Down
149 changes: 149 additions & 0 deletions firmware/baseband/fprotos/w-acurite5in1.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@

#ifndef __FPROTO_Acurite_5in1_H__
#define __FPROTO_Acurite_5in1_H__

#include "weatherbase.hpp"

typedef enum {
Acurite_5n1DecoderStepReset = 0,
Acurite_5n1DecoderStepCheckPreambule,
Acurite_5n1DecoderStepSaveDuration,
Acurite_5n1DecoderStepCheckDuration,
} Acurite_5n1DecoderStep;

class FProtoWeatherAcurite5in1 : public FProtoWeatherBase {
public:
FProtoWeatherAcurite5in1() {
sensorType = FPW_Acurite5in1;
}

void feed(bool level, uint32_t duration) {
switch (parser_step) {
case Acurite_5n1DecoderStepReset:
if ((level) && (DURATION_DIFF(duration, te_short * 3) < te_delta * 2)) {
parser_step = Acurite_5n1DecoderStepCheckPreambule;
te_last = duration;
header_count = 0;
}
break;

case Acurite_5n1DecoderStepCheckPreambule:
if (level) {
te_last = duration;
} else {
if ((DURATION_DIFF(te_last, te_short * 3) < te_delta * 2) &&
(DURATION_DIFF(duration, te_short * 3) < te_delta * 2)) {
// Found preambule
header_count++;
} else if ((header_count > 2) && (header_count < 5)) {
if ((DURATION_DIFF(te_last, te_short) < te_delta) &&
(DURATION_DIFF(duration, te_long) < te_delta)) {
decode_data = 0;
decode_count_bit = 0;
subghz_protocol_blocks_add_bit(0);
parser_step = Acurite_5n1DecoderStepSaveDuration;
} else if (
(DURATION_DIFF(te_last, te_long) < te_delta) &&
(DURATION_DIFF(duration, te_short) < te_delta)) {
decode_data = 0;
decode_count_bit = 0;
subghz_protocol_blocks_add_bit(1);
parser_step = Acurite_5n1DecoderStepSaveDuration;
} else {
parser_step = Acurite_5n1DecoderStepReset;
}
} else {
parser_step = Acurite_5n1DecoderStepReset;
}
}
break;

case Acurite_5n1DecoderStepSaveDuration:
if (level) {
te_last = duration;
parser_step = Acurite_5n1DecoderStepCheckDuration;
} else {
parser_step = Acurite_5n1DecoderStepReset;
}
break;

case Acurite_5n1DecoderStepCheckDuration:
if (!level) {
if (duration >= ((uint32_t)te_short * 5)) {
if ((decode_count_bit == min_count_bit_for_found) &&
ws_protocol_acurite_5n1_check_crc() &&
ws_protocol_acurite_5n1_check_message_type()) {
data = decode_data;
data_count_bit = decode_count_bit;
ws_protocol_acurite_5n1_remote_controller();
if (callback) callback(this);
}
decode_data = 0;
decode_count_bit = 0;
parser_step = Acurite_5n1DecoderStepReset;
break;
} else if ((DURATION_DIFF(te_last, te_short) < te_delta) &&
(DURATION_DIFF(duration, te_long) < te_delta)) {
subghz_protocol_blocks_add_bit(0);
parser_step = Acurite_5n1DecoderStepSaveDuration;
} else if (
(DURATION_DIFF(te_last, te_long) < te_delta) &&
(DURATION_DIFF(duration, te_short) < te_delta)) {
subghz_protocol_blocks_add_bit(1);
parser_step = Acurite_5n1DecoderStepSaveDuration;
} else {
parser_step = Acurite_5n1DecoderStepReset;
}
} else {
parser_step = Acurite_5n1DecoderStepReset;
}
break;
}
}

protected:
uint32_t te_short = 200;
uint32_t te_long = 400;
uint32_t te_delta = 90;
uint32_t min_count_bit_for_found = 64;

bool ws_protocol_acurite_5n1_check_message_type() {
if (((decode_data >> 40) & 0x3F) == 0x38) {
return true;
} else {
return false;
}
}

bool ws_protocol_acurite_5n1_check_crc() {
uint8_t msg[] = {
(uint8_t)(decode_data >> 56),
(uint8_t)(decode_data >> 48),
(uint8_t)(decode_data >> 40),
(uint8_t)(decode_data >> 32),
(uint8_t)(decode_data >> 24),
(uint8_t)(decode_data >> 16),
(uint8_t)(decode_data >> 8)};

if ((FProtoGeneral::subghz_protocol_blocks_add_bytes(msg, 7) ==
(uint8_t)(decode_data & 0xFF)) &&
(!FProtoGeneral::subghz_protocol_blocks_parity_bytes(&msg[2], 5))) {
return true;
} else {
return false;
}
}

void ws_protocol_acurite_5n1_remote_controller() {
uint8_t channell[] = {3, 0, 2, 1};
uint8_t channel_raw = ((data >> 62) & 0x03);
channel = channell[channel_raw];
id = (data >> 48) & 0x3FFF;
battery_low = !((data >> 46) & 1);
humidity = (data >> 8) & 0x7F;
uint16_t temp_raw = ((data >> (24 - 7)) & 0x780) | ((data >> 16) & 0x7F);
temp = FProtoGeneral::locale_fahrenheit_to_celsius(((float)(temp_raw)-400) / 10.0f);
};
};

#endif
1 change: 0 additions & 1 deletion firmware/baseband/fprotos/w-acurite606tx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class FProtoWeatherAcurite606TX : public FProtoWeatherBase {
} else {
temp = (float)((~(data >> 8) & 0x07FF) + 1) / -10.0f;
}
btn = WS_NO_BTN;
humidity = WS_NO_HUMIDITY;
}
bool ws_protocol_acurite_606tx_check() {
Expand Down
22 changes: 6 additions & 16 deletions firmware/baseband/fprotos/w-acurite609tx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,22 @@ class FProtoWeatherAcurite609TX : public FProtoWeatherBase {

case Acurite_609TXCDecoderStepCheckDuration:
if (!level) {
if (DURATION_DIFF(te_last, te_short) <
te_delta) {
if ((DURATION_DIFF(duration, te_short) <
te_delta) ||
(duration > te_long * 3)) {
if (DURATION_DIFF(te_last, te_short) < te_delta) {
if ((DURATION_DIFF(duration, te_short) < te_delta) || (duration > te_long * 3)) {
// Found syncPostfix
parser_step = Acurite_609TXCDecoderStepReset;
if ((decode_count_bit ==
min_count_bit_for_found) &&
ws_protocol_acurite_609txc_check()) {
if ((decode_count_bit == min_count_bit_for_found) && ws_protocol_acurite_609txc_check()) {
data = decode_data;
data_count_bit = decode_count_bit;
ws_protocol_acurite_609txc_remote_controller();
if (callback) callback(this);
}
decode_data = 0;
decode_count_bit = 0;
} else if (
DURATION_DIFF(duration, te_long) <
te_delta * 2) {
} else if (DURATION_DIFF(duration, te_long) < te_delta * 2) {
subghz_protocol_blocks_add_bit(0);
parser_step = Acurite_609TXCDecoderStepSaveDuration;
} else if (
DURATION_DIFF(duration, te_long * 2) <
te_delta * 4) {
} else if (DURATION_DIFF(duration, te_long * 2) < te_delta * 4) {
subghz_protocol_blocks_add_bit(1);
parser_step = Acurite_609TXCDecoderStepSaveDuration;
} else {
Expand All @@ -81,7 +72,7 @@ class FProtoWeatherAcurite609TX : public FProtoWeatherBase {

protected:
uint32_t te_short = 500;
uint32_t te_long = 2000;
uint32_t te_long = 1000;
uint32_t te_delta = 150;
uint32_t min_count_bit_for_found = 32;

Expand All @@ -97,7 +88,6 @@ class FProtoWeatherAcurite609TX : public FProtoWeatherBase {
(int16_t)(((data >> 12) & 0xf000) | ((data >> 16) << 4));
temp = (temp_raw >> 4) * 0.1f;
humidity = (data >> 8) & 0xff;
btn = WS_NO_BTN;
}
bool ws_protocol_acurite_609txc_check() {
if (!decode_data) return false;
Expand Down
1 change: 0 additions & 1 deletion firmware/baseband/fprotos/w-acurite986.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class FProtoWeatherAcurite986 : public FProtoWeatherBase {
temp = -(temp & 0x7F);
}
temp = FProtoGeneral::locale_fahrenheit_to_celsius((float)temp);
btn = WS_NO_BTN;
humidity = WS_NO_HUMIDITY;
}

Expand Down
3 changes: 1 addition & 2 deletions firmware/baseband/fprotos/w-ambient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class FProtoWeatherAmbient : public FProtoWeatherBase {
uint32_t te_long = 1000;
uint32_t te_delta = 120;
uint32_t min_count_bit_for_found = 48;

ManchesterState manchester_saved_state = ManchesterStateMid1;
bool ws_protocol_ambient_weather_check_crc() {
uint8_t msg[] = {
static_cast<uint8_t>(decode_data >> 40),
Expand All @@ -81,7 +81,6 @@ class FProtoWeatherAmbient : public FProtoWeatherBase {
channel = ((data >> 28) & 0x07) + 1;
temp = FProtoGeneral::locale_fahrenheit_to_celsius(((float)((data >> 16) & 0x0FFF) - 400.0f) / 10.0f);
humidity = (data >> 8) & 0xFF;
btn = WS_NO_BTN;
}
};

Expand Down
2 changes: 1 addition & 1 deletion firmware/baseband/fprotos/w-auriol-ahfl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class FProtoWeatherAuriolAhfl : public FProtoWeatherBase {
void ws_protocol_auriol_ahfl_remote_controller() {
id = data >> 34;
battery_low = (data >> 33) & 1;
btn = (data >> 32) & 1;
// btn = (data >> 32) & 1;
channel = ((data >> 30) & 0x3) + 1;
if (!((data >> 29) & 1)) {
temp = (float)((data >> 18) & 0x07FF) / 10.0f;
Expand Down
1 change: 0 additions & 1 deletion firmware/baseband/fprotos/w-auriol-th.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class FProtoWeatherAuriolTh : public FProtoWeatherBase {
id = (data >> 31) & 0xFF;
battery_low = ((data >> 30) & 1);
channel = ((data >> 25) & 0x03) + 1;
btn = WS_NO_BTN;
if (!((data >> 23) & 1)) {
temp = (float)((data >> 13) & 0x07FF) / 10.0f;
} else {
Expand Down
Loading

0 comments on commit 5d9428e

Please sign in to comment.