Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
SubGhz: Display Weather Station temperature in units matching system …
Browse files Browse the repository at this point in the history
…locale (#569)
  • Loading branch information
Willy-JL authored Feb 24, 2024
2 parents f2eff7b + 195ae7d commit c4cab4c
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 35 deletions.
7 changes: 5 additions & 2 deletions lib/subghz/protocols/acurite_592txr.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,23 @@ SubGhzProtocolStatus
void ws_protocol_decoder_acurite_592txr_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderAcurite_592TXR* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}

Expand Down
7 changes: 5 additions & 2 deletions lib/subghz/protocols/acurite_606tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_acurite_606tx_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderAcurite_606TX* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/acurite_609txc.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_acurite_609txc_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderAcurite_609TXC* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 40),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
9 changes: 6 additions & 3 deletions lib/subghz/protocols/acurite_986.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static void ws_protocol_acurite_986_remote_controller(WSBlockGeneric* instance)
if(temp & 0x80) {
temp = -(temp & 0x7F);
}
instance->temp = locale_fahrenheit_to_celsius((float)temp);
instance->temp = (float)temp;
instance->btn = WS_NO_BTN;
instance->humidity = WS_NO_HUMIDITY;
}
Expand Down Expand Up @@ -256,19 +256,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_acurite_986_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderAcurite_986* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? locale_fahrenheit_to_celsius(instance->generic.temp) :
instance->generic.temp),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/ambient_weather.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_ambient_weather_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderAmbient_Weather* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/auriol_ahfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,19 +239,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_auriol_ahfl_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderAuriol_AHFL* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/auriol_hg0601a.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_auriol_th_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderAuriol_TH* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/gt_wt_02.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_gt_wt_02_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderGT_WT02* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/gt_wt_03.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,19 +315,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_gt_wt_03_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderGT_WT03* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/infactory.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_infactory_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderInfactory* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/kedsum_th.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_kedsum_th_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderKedsumTH* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/lacrosse_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_lacrosse_tx_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderLaCrosse_TX* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/lacrosse_tx141thbv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,19 +290,22 @@ SubGhzProtocolStatus ws_protocol_decoder_lacrosse_tx141thbv2_deserialize(
void ws_protocol_decoder_lacrosse_tx141thbv2_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderLaCrosse_TX141THBv2* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
7 changes: 5 additions & 2 deletions lib/subghz/protocols/nexus_th.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,20 +313,23 @@ SubGhzProtocolStatus
void ws_protocol_decoder_nexus_th_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderNexus_TH* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}

Expand Down
7 changes: 5 additions & 2 deletions lib/subghz/protocols/thermopro_tx4.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,19 +236,22 @@ SubGhzProtocolStatus
void ws_protocol_decoder_thermopro_tx4_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderThermoPRO_TX4* instance = context;
bool locale_is_metric = furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric;
furi_string_cat_printf(
output,
"%s\r\n%dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%3.1f C Hum:%d%%",
"Temp:%3.1f %c Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(double)instance->generic.temp,
(double)(locale_is_metric ? instance->generic.temp :
locale_celsius_to_fahrenheit(instance->generic.temp)),
locale_is_metric ? 'C' : 'F',
instance->generic.humidity);
}
Loading

0 comments on commit c4cab4c

Please sign in to comment.