mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-28 11:26:32 +03:00
Merge pull request #197 from LY2NEO/dev
Improved plugin WS data dashboard, added data age counter.
This commit is contained in:
commit
42cc41cda3
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user