diff --git a/applications/plugins/weather_station/protocols/ws_generic.c b/applications/plugins/weather_station/protocols/ws_generic.c index 174531090..3a1c40726 100644 --- a/applications/plugins/weather_station/protocols/ws_generic.c +++ b/applications/plugins/weather_station/protocols/ws_generic.c @@ -99,6 +99,17 @@ bool ws_block_generic_serialize( 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)) { FURI_LOG_E(TAG, "Unable to add Channel"); @@ -168,6 +179,12 @@ 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)) { + 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; diff --git a/applications/plugins/weather_station/protocols/ws_generic.h b/applications/plugins/weather_station/protocols/ws_generic.h index b2a84df8e..7d0f198d5 100644 --- a/applications/plugins/weather_station/protocols/ws_generic.h +++ b/applications/plugins/weather_station/protocols/ws_generic.h @@ -29,6 +29,7 @@ struct WSBlockGeneric { uint8_t data_count_bit; uint8_t battery_low; uint8_t humidity; + uint32_t agedata; uint8_t channel; uint8_t btn; float temp; diff --git a/applications/plugins/weather_station/views/weather_station_receiver_info.c b/applications/plugins/weather_station/views/weather_station_receiver_info.c index 49b447f10..e5c1be42a 100644 --- a/applications/plugins/weather_station/views/weather_station_receiver_info.c +++ b/applications/plugins/weather_station/views/weather_station_receiver_info.c @@ -70,6 +70,55 @@ 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); + + int diffold = (int)curr_ts - (int)model->generic->agedata; + + 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) { + } + + 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); + } + } + + } 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);