mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-20 00:48:11 -07:00
Simplify and fix time display
display only OLD when we have more than 59 mins
This commit is contained in:
@@ -144,13 +144,6 @@ static void ws_protocol_acurite_592txr_remote_controller(WSBlockGeneric* instanc
|
||||
instance->temp = ((float)(temp_raw)-1000) / 10.0f;
|
||||
|
||||
instance->btn = WS_NO_BTN;
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
instance->agedata = curr_ts;
|
||||
}
|
||||
|
||||
void ws_protocol_decoder_acurite_592txr_feed(void* context, bool level, uint32_t duration) {
|
||||
|
||||
@@ -123,13 +123,6 @@ static void ws_protocol_acurite_606tx_remote_controller(WSBlockGeneric* instance
|
||||
}
|
||||
instance->btn = WS_NO_BTN;
|
||||
instance->humidity = WS_NO_HUMIDITY;
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
instance->agedata = curr_ts;
|
||||
}
|
||||
|
||||
void ws_protocol_decoder_acurite_606tx_feed(void* context, bool level, uint32_t duration) {
|
||||
|
||||
@@ -123,13 +123,6 @@ static void ws_protocol_acurite_609txc_remote_controller(WSBlockGeneric* instanc
|
||||
instance->temp = (temp_raw >> 4) * 0.1f;
|
||||
instance->humidity = (instance->data >> 8) & 0xff;
|
||||
instance->btn = WS_NO_BTN;
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
instance->agedata = curr_ts;
|
||||
}
|
||||
|
||||
void ws_protocol_decoder_acurite_609txc_feed(void* context, bool level, uint32_t duration) {
|
||||
|
||||
@@ -160,13 +160,6 @@ static void ws_protocol_ambient_weather_remote_controller(WSBlockGeneric* instan
|
||||
ERROR;
|
||||
}
|
||||
*/
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
instance->agedata = curr_ts;
|
||||
}
|
||||
|
||||
void ws_protocol_decoder_ambient_weather_feed(void* context, bool level, uint32_t duration) {
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
#include "auriol_hg0601a.h"
|
||||
|
||||
#define TAG "WSProtocolAuriol_TH"
|
||||
@@ -136,13 +133,6 @@ static void ws_protocol_auriol_th_remote_controller(WSBlockGeneric* instance) {
|
||||
}
|
||||
|
||||
instance->humidity = (instance->data >> 1) & 0x7F;
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
instance->agedata = curr_ts;
|
||||
}
|
||||
|
||||
void ws_protocol_decoder_auriol_th_feed(void* context, bool level, uint32_t duration) {
|
||||
|
||||
@@ -135,12 +135,6 @@ static void ws_protocol_gt_wt_02_remote_controller(WSBlockGeneric* instance) {
|
||||
instance->temp = (float)((~(instance->data >> 13) & 0x07FF) + 1) / -10.0f;
|
||||
}
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
instance->agedata = curr_ts;
|
||||
|
||||
instance->humidity = (instance->data >> 6) & 0x7F;
|
||||
if(instance->humidity <= 10) // actually the sensors sends 10 below working range of 20%
|
||||
instance->humidity = 0;
|
||||
|
||||
@@ -179,13 +179,6 @@ static void ws_protocol_gt_wt_03_remote_controller(WSBlockGeneric* instance) {
|
||||
} else {
|
||||
instance->temp = (float)((~(instance->data >> 9) & 0x07FF) + 1) / -10.0f;
|
||||
}
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
instance->agedata = curr_ts;
|
||||
}
|
||||
|
||||
void ws_protocol_decoder_gt_wt_03_feed(void* context, bool level, uint32_t duration) {
|
||||
|
||||
@@ -148,13 +148,6 @@ static void ws_protocol_infactory_remote_controller(WSBlockGeneric* instance) {
|
||||
instance->humidity =
|
||||
(((instance->data >> 8) & 0x0F) * 10) + ((instance->data >> 4) & 0x0F); // BCD, 'A0'=100%rH
|
||||
instance->channel = instance->data & 0x03;
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
instance->agedata = curr_ts;
|
||||
}
|
||||
|
||||
void ws_protocol_decoder_infactory_feed(void* context, bool level, uint32_t duration) {
|
||||
|
||||
@@ -123,13 +123,6 @@ static void ws_protocol_lacrosse_tx141thbv2_remote_controller(WSBlockGeneric* in
|
||||
instance->channel = ((instance->data >> 29) & 0x03) + 1;
|
||||
instance->temp = ((float)((instance->data >> 17) & 0x0FFF) - 500.0f) / 10.0f;
|
||||
instance->humidity = (instance->data >> 9) & 0xFF;
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
instance->agedata = curr_ts;
|
||||
}
|
||||
|
||||
void ws_protocol_decoder_lacrosse_tx141thbv2_feed(void* context, bool level, uint32_t duration) {
|
||||
|
||||
@@ -135,13 +135,6 @@ static void ws_protocol_nexus_th_remote_controller(WSBlockGeneric* instance) {
|
||||
}
|
||||
|
||||
instance->humidity = instance->data & 0xFF;
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
instance->agedata = curr_ts;
|
||||
}
|
||||
|
||||
void ws_protocol_decoder_nexus_th_feed(void* context, bool level, uint32_t duration) {
|
||||
|
||||
@@ -132,13 +132,6 @@ static void ws_protocol_thermopro_tx4_remote_controller(WSBlockGeneric* instance
|
||||
}
|
||||
|
||||
instance->humidity = (instance->data >> 1) & 0xFF;
|
||||
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
instance->agedata = curr_ts;
|
||||
}
|
||||
|
||||
void ws_protocol_decoder_thermopro_tx4_feed(void* context, bool level, uint32_t duration) {
|
||||
|
||||
@@ -99,11 +99,16 @@ bool ws_block_generic_serialize(
|
||||
break;
|
||||
}
|
||||
|
||||
temp_data = instance->agedata;
|
||||
if(!flipper_format_write_uint32(flipper_format, "Old", &temp_data, 1)) {
|
||||
FURI_LOG_E(TAG, "Unable to add agedata");
|
||||
break;
|
||||
}
|
||||
//DATE AGE set
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
temp_data = curr_ts;
|
||||
if(!flipper_format_write_uint32(flipper_format, "Old", &temp_data, 1)) {
|
||||
FURI_LOG_E(TAG, "Unable to add agedata");
|
||||
break;
|
||||
}
|
||||
|
||||
temp_data = instance->channel;
|
||||
if(!flipper_format_write_uint32(flipper_format, "Ch", &temp_data, 1)) {
|
||||
@@ -174,17 +179,17 @@ bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipp
|
||||
}
|
||||
instance->humidity = (uint8_t)temp_data;
|
||||
|
||||
if(!flipper_format_read_uint32(flipper_format, "Old", (uint32_t*)&temp_data, 1)) {
|
||||
if(!flipper_format_read_uint32(flipper_format, "Old", (uint32_t*)&temp_data, 1)) {
|
||||
FURI_LOG_E(TAG, "Missing agedata");
|
||||
break;
|
||||
}
|
||||
instance->agedata = (uint32_t)temp_data;
|
||||
|
||||
if(!flipper_format_read_uint32(flipper_format, "Ch", (uint32_t*)&temp_data, 1)) {
|
||||
FURI_LOG_E(TAG, "Missing Channel");
|
||||
break;
|
||||
}
|
||||
instance->channel = (uint8_t)temp_data;
|
||||
if(!flipper_format_read_uint32(flipper_format, "Ch", (uint32_t*)&temp_data, 1)) {
|
||||
FURI_LOG_E(TAG, "Missing Channel");
|
||||
break;
|
||||
}
|
||||
instance->channel = (uint8_t)temp_data;
|
||||
|
||||
if(!flipper_format_read_uint32(flipper_format, "Btn", (uint32_t*)&temp_data, 1)) {
|
||||
FURI_LOG_E(TAG, "Missing Btn");
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include "weather_station_receiver.h"
|
||||
#include "../weather_station_app_i.h"
|
||||
#include "weather_station_icons.h"
|
||||
@@ -72,46 +70,54 @@ void ws_view_receiver_info_draw(Canvas* canvas, WSReceiverInfoModel* model) {
|
||||
snprintf(buffer, sizeof(buffer), "Data: 0x%llX", model->generic->data);
|
||||
canvas_draw_str(canvas, 5, 32, buffer);
|
||||
|
||||
//DATA AGE
|
||||
if((int) model->generic->agedata > 0){
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
//DATA AGE
|
||||
if((int)model->generic->agedata > 0) {
|
||||
FuriHalRtcDateTime curr_dt;
|
||||
furi_hal_rtc_get_datetime(&curr_dt);
|
||||
uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt);
|
||||
|
||||
int diffold = (int) curr_ts - (int) model->generic->agedata;
|
||||
int diffold = (int)curr_ts - (int)model->generic->agedata;
|
||||
|
||||
if(diffold>60){
|
||||
if(diffold > 60) {
|
||||
int tmp_sec = diffold;
|
||||
int cnt_min = 1;
|
||||
for(int i = 1; tmp_sec > 60; i++) {
|
||||
tmp_sec = tmp_sec - 60;
|
||||
cnt_min = i;
|
||||
}
|
||||
if(cnt_min >= 59) {
|
||||
}
|
||||
|
||||
int tmp_sec = diffold;
|
||||
int cnt_min = 1;
|
||||
for(int i=1; tmp_sec>60; i++){
|
||||
tmp_sec = tmp_sec - 60;
|
||||
cnt_min = i;
|
||||
}
|
||||
if(curr_ts % 2 == 0) {
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 97, 23, 26, 11, 1);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, "OLD");
|
||||
} else {
|
||||
if(cnt_min >= 59) {
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 97, 23, 26, 11, 1);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, "OLD");
|
||||
} else {
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 97, 23, 26, 11, 1);
|
||||
canvas_draw_box(canvas, 97, 23, 26, 11);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
snprintf(buffer, sizeof(buffer), "%dm", cnt_min);
|
||||
canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
if ( curr_ts % 2 == 0){
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 97, 23, 26, 11, 1);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, "OLD");
|
||||
}else{
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 97, 23, 26, 11, 1);
|
||||
canvas_draw_box(canvas, 97, 23, 26, 11);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
snprintf(buffer, sizeof(buffer), "%dm", cnt_min);
|
||||
canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer);
|
||||
}
|
||||
|
||||
}else{
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 97, 23, 26, 11, 1);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
snprintf(buffer, sizeof(buffer), "%d", diffold);
|
||||
canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer);
|
||||
}
|
||||
}
|
||||
//DATA AGE end
|
||||
} else {
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_rframe(canvas, 97, 23, 26, 11, 1);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
snprintf(buffer, sizeof(buffer), "%d", diffold);
|
||||
canvas_draw_str_aligned(canvas, 109, 29, AlignCenter, AlignCenter, buffer);
|
||||
}
|
||||
}
|
||||
//DATA AGE end
|
||||
|
||||
elements_bold_rounded_frame(canvas, 2, 37, 123, 25);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
|
||||
Reference in New Issue
Block a user