Browse Source

USE weebo_get_figure_id

RogueMaster 8 months ago
parent
commit
7a3e705c4f
4 changed files with 12 additions and 8 deletions
  1. 1 4
      scenes/weebo_scene_info.c
  2. 9 3
      weebo.c
  3. 2 0
      weebo.h
  4. 0 1
      weebo_i.h

+ 1 - 4
scenes/weebo_scene_info.c

@@ -17,10 +17,7 @@ void weebo_scene_info_on_enter(void* context) {
         furi_string_cat_printf(str, "Unknown\n");
     }
     furi_string_free(name);
-    uint16_t id = 0;
-    id |= weebo->figure[UNPACKED_FIGURE_ID + 0] << 8;
-    id |= weebo->figure[UNPACKED_FIGURE_ID + 1] << 0;
-    furi_string_cat_printf(str, "ID: %04x\n", id);
+    furi_string_cat_printf(str, "ID: %04x\n", weebo_get_figure_id(weebo));
 
     text_box_set_font(weebo->text_box, TextBoxFontText);
     text_box_set_text(weebo->text_box, furi_string_get_cstr(weebo->text_box_store));

+ 9 - 3
weebo.c

@@ -4,6 +4,7 @@
 
 #define WEEBO_KEY_RETAIL_FILENAME "key_retail"
 #define FIGURE_ID_LIST            APP_ASSETS_PATH("figure_ids.nfc")
+#define UNPACKED_FIGURE_ID         0x1dc
 #define NFC_APP_EXTENSION         ".nfc"
 #define NFC_APP_PATH_PREFIX       "/ext/nfc"
 
@@ -138,13 +139,18 @@ static bool
     return parsed;
 }
 
-bool weebo_get_figure_name(Weebo* weebo, FuriString* name) {
-    bool parsed = false;
-
+uint16_t weebo_get_figure_id(Weebo* weebo) {
     uint16_t id = 0;
     id |= weebo->figure[UNPACKED_FIGURE_ID + 0] << 8;
     id |= weebo->figure[UNPACKED_FIGURE_ID + 1] << 0;
     FURI_LOG_D(TAG, "id = %04x", id);
+    return id;
+}
+
+bool weebo_get_figure_name(Weebo* weebo, FuriString* name) {
+    bool parsed = false;
+
+    uint16_t id = weebo_get_figure_id(weebo);
 
     FuriString* key = furi_string_alloc_printf("%04x", id);
     if(weebo_search_data(weebo->storage, FIGURE_ID_LIST, key, name)) {

+ 2 - 0
weebo.h

@@ -2,4 +2,6 @@
 
 typedef struct Weebo Weebo;
 
+uint16_t weebo_get_figure_id(Weebo* weebo);
+
 bool weebo_get_figure_name(Weebo* weebo, FuriString* name);

+ 0 - 1
weebo_i.h

@@ -42,7 +42,6 @@
 
 #define WEEBO_TEXT_STORE_SIZE      128
 #define WEEBO_FILE_NAME_MAX_LENGTH 64
-#define UNPACKED_FIGURE_ID         0x1dc
 
 #define NTAG215_SIZE     540
 #define NFC3D_UID_OFFSET 0x1D4