mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 23:18:35 -07:00
log code updates, showing the last entries only
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#include "../nfc_i.h"
|
#include "../nfc_i.h"
|
||||||
|
|
||||||
#define NFC_SCENE_EMULATE_NFCV_LOG_SIZE_MAX (200)
|
#define NFC_SCENE_EMULATE_NFCV_LOG_SIZE_MAX (100)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
NfcSceneEmulateNfcVStateWidget,
|
NfcSceneEmulateNfcVStateWidget,
|
||||||
@@ -95,11 +95,17 @@ bool nfc_scene_emulate_nfcv_on_event(void* context, SceneManagerEvent event) {
|
|||||||
if(!furi_string_size(nfc->text_box_store)) {
|
if(!furi_string_size(nfc->text_box_store)) {
|
||||||
nfc_scene_emulate_nfcv_widget_config(nfc, true);
|
nfc_scene_emulate_nfcv_widget_config(nfc, true);
|
||||||
}
|
}
|
||||||
// Update TextBox data
|
if(strlen(nfcv_data->last_command) > 0) {
|
||||||
if(furi_string_size(nfc->text_box_store) < NFC_SCENE_EMULATE_NFCV_LOG_SIZE_MAX) {
|
/* use the last n bytes from the log so there's enough space for the new log entry */
|
||||||
|
size_t maxSize = NFC_SCENE_EMULATE_NFCV_LOG_SIZE_MAX - (strlen(nfcv_data->last_command) + 3);
|
||||||
|
if(furi_string_size(nfc->text_box_store) >= maxSize) {
|
||||||
|
furi_string_right(nfc->text_box_store, maxSize);
|
||||||
|
}
|
||||||
furi_string_cat_printf(nfc->text_box_store, "%s", nfcv_data->last_command);
|
furi_string_cat_printf(nfc->text_box_store, "%s", nfcv_data->last_command);
|
||||||
furi_string_push_back(nfc->text_box_store, '\n');
|
furi_string_push_back(nfc->text_box_store, '\n');
|
||||||
text_box_set_text(nfc->text_box, furi_string_get_cstr(nfc->text_box_store));
|
text_box_set_text(nfc->text_box, furi_string_get_cstr(nfc->text_box_store));
|
||||||
|
|
||||||
|
/* clear previously logged command */
|
||||||
strcpy(nfcv_data->last_command, "");
|
strcpy(nfcv_data->last_command, "");
|
||||||
}
|
}
|
||||||
consumed = true;
|
consumed = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user