Output timer value
Signed-off-by: Markus Birth <markus@birth-online.de>
This commit is contained in:
@@ -26,14 +26,14 @@ void nfc_scene_detect_scan_callback(NfcScannerEvent event, void* context) {
|
||||
|
||||
NfcCommand nfc_scene_poller_callback(NfcGenericEvent event, void* context) {
|
||||
//furi_assert(event.protocol == NfcProtocolIso14443_3a);
|
||||
furi_assert(event.protocol == NfcProtocolMfUltralight);
|
||||
//furi_assert(event.protocol == NfcProtocolMfUltralight);
|
||||
|
||||
Sonicare* app = context;
|
||||
//const Iso14443_3aPollerEvent* ev = event.event_data;
|
||||
const MfUltralightPollerEvent* ev = event.event_data;
|
||||
|
||||
//if (ev->type == Iso14443_3aPollerEventTypeReady) {
|
||||
if (ev->type == MfUltralightPollerEventTypeReadSuccess) {
|
||||
if (event.protocol == NfcProtocolMfUltralight && ev->type == MfUltralightPollerEventTypeReadSuccess) {
|
||||
FURI_LOG_I("sonicare_scene_read", "NFC Poller reports Read Success");
|
||||
nfc_device_set_data(app->nfc_device, NfcProtocolMfUltralight, nfc_poller_get_data(app->poller));
|
||||
FURI_LOG_D("sonicare_scene_read", "Pulling Mifare Ultralight data from poller");
|
||||
@@ -42,8 +42,12 @@ NfcCommand nfc_scene_poller_callback(NfcGenericEvent event, void* context) {
|
||||
mf_ultralight_copy(app->nfc_data, ul_data);
|
||||
|
||||
FURI_LOG_I("sonicare_scene_read", "Dataset has %i of %i pages read from Mifare Ultralight", ul_data->pages_read, ul_data->pages_total);
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, NfcCustomEventWorkerExit);
|
||||
return NfcCommandStop;
|
||||
|
||||
if (ul_data->pages_read == 43) {
|
||||
// only stop when we have all data
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, NfcCustomEventWorkerExit);
|
||||
return NfcCommandStop;
|
||||
}
|
||||
}
|
||||
|
||||
return NfcCommandContinue;
|
||||
|
||||
@@ -37,23 +37,35 @@ void sonicare_scene_read_complete_on_enter(void* context) {
|
||||
const MfUltralightData* ul_data = app->nfc_data;
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
|
||||
|
||||
furi_string_cat_printf(temp_str, "\e#%s\n", nfc_device_get_name(nfc_device, NfcDeviceNameTypeFull));
|
||||
|
||||
// UID
|
||||
furi_string_cat_printf(temp_str, "UID:");
|
||||
format_bytes(temp_str, ul_data->iso14443_3a_data->uid, ul_data->iso14443_3a_data->uid_len);
|
||||
furi_string_cat_printf(temp_str, "\n");
|
||||
|
||||
// Serial#
|
||||
furi_string_cat_str(temp_str, "Ser#: ");
|
||||
FuriString* serial_no = furi_string_alloc();
|
||||
furi_string_cat_str(serial_no, (char*)(ul_data->page[0x21].data));
|
||||
// furi_string_right(serial_no, 10);
|
||||
|
||||
furi_string_right(serial_no, 2);
|
||||
furi_string_cat(temp_str, serial_no);
|
||||
furi_string_free(serial_no);
|
||||
furi_string_cat_printf(temp_str, "\n");
|
||||
|
||||
furi_string_cat_printf(temp_str, "Timer:");
|
||||
const uint16_t seconds = ul_data->page[0x24].data[1]*256 + ul_data->page[0x24].data[0];
|
||||
const uint16_t brushes = seconds / 120; // one brush = 2 minutes
|
||||
format_bytes(temp_str, ul_data->page[0x24].data, 4);
|
||||
furi_string_cat_printf(temp_str, "\n");
|
||||
furi_string_cat_printf(temp_str, "Usage: %u brushes (%u s)\n", (int)brushes, (int)seconds);
|
||||
|
||||
|
||||
// Output to widget
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
|
||||
|
||||
furi_string_free(temp_str);
|
||||
furi_string_free(serial_no);
|
||||
|
||||
widget_add_button_element(widget, GuiButtonTypeRight, "Change", sonicare_scene_read_complete_widget_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SonicareViewWidget);
|
||||
|
||||
Reference in New Issue
Block a user