diff --git a/scenes/tagtinker_scene_barcode_input.c b/scenes/tagtinker_scene_barcode_input.c index 46ef8bc..ea508e7 100644 --- a/scenes/tagtinker_scene_barcode_input.c +++ b/scenes/tagtinker_scene_barcode_input.c @@ -6,7 +6,8 @@ static void unsupported_tag_back_cb(GuiButtonType type, InputType input_type, void* ctx) { UNUSED(type); - UNUSED(input_type); + /* Widget buttons report press, short and release alike; act once. */ + if(input_type != InputTypeShort) return; TagTinkerApp* app = ctx; scene_manager_previous_scene(app->scene_manager); } @@ -60,12 +61,30 @@ bool tagtinker_scene_barcode_input_on_event(void* ctx, SceneManagerEvent event) - app->selected_target = tagtinker_ensure_target(app, app->barcode); + int8_t idx = tagtinker_ensure_target(app, app->barcode); - if(app->selected_target >= 0) { - tagtinker_select_target(app, (uint8_t)app->selected_target); + if(idx < 0) { + /* The barcode already passed validation, so the only way left to fail + * is a full target list. Do not open the target actions with index -1. */ + widget_reset(app->widget); + widget_add_string_element( + app->widget, 64, 10, AlignCenter, AlignTop, FontPrimary, "Target List Full"); + widget_add_string_multiline_element( + app->widget, + 64, + 30, + AlignCenter, + AlignTop, + FontSecondary, + "Delete a saved tag\nto add a new one."); + widget_add_button_element( + app->widget, GuiButtonTypeLeft, "Back", unsupported_tag_back_cb, app); + view_dispatcher_switch_to_view(app->view_dispatcher, TagTinkerViewWidget); + return true; } + tagtinker_select_target(app, (uint8_t)idx); + uint32_t target_scene = scene_manager_get_scene_state( app->scene_manager, TagTinkerSceneBarcodeInput); scene_manager_next_scene(app->scene_manager, target_scene); diff --git a/scenes/tagtinker_scene_target_actions.c b/scenes/tagtinker_scene_target_actions.c index 979802b..e39e022 100644 --- a/scenes/tagtinker_scene_target_actions.c +++ b/scenes/tagtinker_scene_target_actions.c @@ -29,6 +29,27 @@ static void show_target_details(TagTinkerApp* app, const TagTinkerTarget* target text_box_set_focus(app->text_box, TextBoxFocusStart); static char details_buf[256]; + + if(!target->profile.known) { + /* No table entry: size and colour are unknown, not 0x0 and Mono. */ + snprintf( + details_buf, + sizeof(details_buf), + "--- Tag Info ---\n" + "Model: Unknown\n" + "Type: %u\n" + "Not in the profile table,\n" + "so Set Text, Set Image\n" + "and WiFi Plugins are\n" + "hidden for this tag.\n" + "Barcode:\n%s", + target->profile.type_code, + target->barcode); + text_box_set_text(app->text_box, details_buf); + scene_manager_next_scene(app->scene_manager, TagTinkerSceneTextBox); + return; + } + uint16_t size_w = target->profile.width; uint16_t size_h = target->profile.height; tagtinker_profile_glass_size(&target->profile, &size_w, &size_h); diff --git a/scenes/tagtinker_scene_transmit.c b/scenes/tagtinker_scene_transmit.c index f5ab8fd..bf87eb3 100644 --- a/scenes/tagtinker_scene_transmit.c +++ b/scenes/tagtinker_scene_transmit.c @@ -457,6 +457,11 @@ static bool tx_send_color26_text(TagTinkerApp* app) { } static bool tx_stream_text_image(TagTinkerApp* app) { + /* A target without a table profile has no dimensions. Refuse here: both + * text paths below would otherwise call malloc(0), which the firmware + * treats as a fatal error. */ + if(app->image_tx_job.width == 0U || app->image_tx_job.height == 0U) return false; + if(tx_is_color26(app)) { return tx_send_color26_text(app); } diff --git a/tagtinker_app.c b/tagtinker_app.c index f6c5292..bb4fbb5 100644 --- a/tagtinker_app.c +++ b/tagtinker_app.c @@ -289,7 +289,10 @@ bool tagtinker_delete_target(TagTinkerApp* app, uint8_t index) { bool tagtinker_target_supports_graphics(const TagTinkerTarget* target) { if(!target) return false; - return target->profile.kind != TagTinkerTagKindSegment; + /* Only profile-table entries have real dimensions. A type code missing + * from the table leaves a zeroed profile (0x0, kind Unknown), so the app + * has no known display size to render text or images for. */ + return target->profile.known && target->profile.kind == TagTinkerTagKindDotMatrix; } bool tagtinker_target_supports_accent(const TagTinkerTarget* target) {