First Locale integration

This commit is contained in:
VerstreuteSeele
2022-12-19 17:57:39 +01:00
parent 383752072d
commit 07b9e691d9
7 changed files with 32 additions and 19 deletions
@@ -3,7 +3,7 @@
#include <furi.h>
#include <furi_hal.h>
#define WS_VERSION_APP "0.6"
#define WS_VERSION_APP "0.6.1"
#define WS_DEVELOPED "SkorP"
#define WS_GITHUB "https://github.com/flipperdevices/flipperzero-firmware"
@@ -134,9 +134,8 @@ static void ws_protocol_ambient_weather_remote_controller(WSBlockGeneric* instan
instance->id = (instance->data >> 32) & 0xFF;
instance->battery_low = (instance->data >> 31) & 1;
instance->channel = ((instance->data >> 28) & 0x07) + 1;
instance->temp = ws_block_generic_fahrenheit_to_celsius(
((float)((instance->data >> 16) & 0x0FFF) - 400.0f) / 10.0f);
instance->humidity = (instance->data >> 8) & 0xFF;
instance->temp =
locale_fahrenheit_to_celsius(((float)((instance->data >> 16) & 0x0FFF) - 400.0f) / 10.0f); instance->humidity = (instance->data >> 8) & 0xFF;
instance->btn = WS_NO_BTN;
// ToDo maybe it won't be needed
@@ -143,8 +143,8 @@ static void ws_protocol_infactory_remote_controller(WSBlockGeneric* instance) {
instance->id = instance->data >> 32;
instance->battery_low = (instance->data >> 26) & 1;
instance->btn = WS_NO_BTN;
instance->temp = ws_block_generic_fahrenheit_to_celsius(
((float)((instance->data >> 12) & 0x0FFF) - 900.0f) / 10.0f);
instance->temp =
locale_fahrenheit_to_celsius(((float)((instance->data >> 12) & 0x0FFF) - 900.0f) / 10.0f);
instance->humidity =
(((instance->data >> 8) & 0x0F) * 10) + ((instance->data >> 4) & 0x0F); // BCD, 'A0'=100%rH
instance->channel = instance->data & 0x03;
@@ -208,8 +208,4 @@ bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipp
} while(0);
return res;
}
float ws_block_generic_fahrenheit_to_celsius(float fahrenheit) {
return (fahrenheit - 32.0f) / 1.8f;
}
@@ -8,6 +8,7 @@
#include "furi.h"
#include "furi_hal.h"
#include <lib/subghz/types.h>
#include <locale/locale.h>
#ifdef __cplusplus
extern "C" {
@@ -62,8 +63,6 @@ bool ws_block_generic_serialize(
*/
bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipper_format);
float ws_block_generic_fahrenheit_to_celsius(float fahrenheit);
#ifdef __cplusplus
}
#endif
@@ -81,12 +81,31 @@ void ws_view_receiver_info_draw(Canvas* canvas, WSReceiverInfoModel* model) {
if(model->generic->temp != WS_NO_TEMPERATURE) {
canvas_draw_icon(canvas, 6, 43, &I_Therm_7x16);
snprintf(buffer, sizeof(buffer), "%3.1f C", (double)model->generic->temp);
uint8_t temp_x1 = 47;
uint8_t temp_x2 = 38;
if(model->generic->temp < -9.0) {
temp_x1 = 49;
temp_x2 = 40;
uint8_t temp_x1 = 0;
uint8_t temp_x2 = 0;
if(furi_hal_rtc_get_locale_units() == FuriHalRtcLocaleUnitsMetric) {
snprintf(buffer, sizeof(buffer), "%3.1f C", (double)model->generic->temp);
if(model->generic->temp < -9.0f) {
temp_x1 = 49;
temp_x2 = 40;
} else {
temp_x1 = 47;
temp_x2 = 38;
}
} else {
snprintf(
buffer,
sizeof(buffer),
"%3.1f F",
(double)locale_celsius_to_fahrenheit(model->generic->temp));
if((model->generic->temp < -27.77f) || (model->generic->temp > 37.77f)) {
temp_x1 = 50;
temp_x2 = 42;
} else {
temp_x1 = 48;
temp_x2 = 40;
}
}
canvas_draw_str_aligned(canvas, temp_x1, 47, AlignRight, AlignTop, buffer);
canvas_draw_circle(canvas, temp_x2, 46, 1);
+1 -1
View File
@@ -14,7 +14,7 @@ DEBUG = 0
# Suffix to add to files when building distribution
# If OS environment has DIST_SUFFIX set, it will be used instead
DIST_SUFFIX = "CC_CL-0016_12192022"
DIST_SUFFIX = "CC_CL-0017_12192022"
# Coprocessor firmware
COPRO_OB_DATA = "scripts/ob.data"