Skip to content

Commit

Permalink
Merge pull request #212 from solosky/develop
Browse files Browse the repository at this point in the history
2.10.0
  • Loading branch information
solosky authored Jan 28, 2024
2 parents e68a2c2 + 74d06d7 commit fc2c0f5
Show file tree
Hide file tree
Showing 61 changed files with 729 additions and 91 deletions.
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"functional": "c",
"tuple": "c",
"type_traits": "c",
"utility": "c"
"utility": "c",
"mui_list_view.h": "c",
"nrf_log.h": "c",
"string.h": "c",
"math.h": "c",
"mlib_common.h": "c"
}
}
8 changes: 8 additions & 0 deletions fw/application/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ SRC_FILES += \
$(PROJ_DIR)/mui/mui_mem.c \
$(PROJ_DIR)/mui/mui_anim.c \
$(PROJ_DIR)/mui/mui_math.c \
$(PROJ_DIR)/mui/mui_resource.c \
$(PROJ_DIR)/mui/view/mui_list_view.c \
$(PROJ_DIR)/mui/view/mui_text_input.c \
$(PROJ_DIR)/mui/view/mui_msg_box.c \
Expand Down Expand Up @@ -275,6 +276,7 @@ SRC_FILES += \
$(PROJ_DIR)/app/chameleon/port/fds_utils.c \
$(PROJ_DIR)/app/chameleon/port/tag_helper.c \
$(PROJ_DIR)/app/desktop/app_desktop.c \
$(PROJ_DIR)/app/desktop/view/app_list_view.c \
$(PROJ_DIR)/app/amiibo/app_amiibo.c \
$(PROJ_DIR)/app/amiibo/view/amiibo_detail_view.c \
$(PROJ_DIR)/app/amiibo/scene/amiibo_scene.c \
Expand Down Expand Up @@ -541,6 +543,7 @@ INC_FOLDERS += \
$(PROJ_DIR)/app/ble/scene \
$(PROJ_DIR)/app/ble/view \
$(PROJ_DIR)/app/desktop \
$(PROJ_DIR)/app/desktop/view \
$(PROJ_DIR)/app/settings \
$(PROJ_DIR)/app/settings/scene \
$(PROJ_DIR)/app/amiibo \
Expand Down Expand Up @@ -721,6 +724,11 @@ ota:
full: settingsgen
mergehex --merge $(OUTPUT_DIRECTORY)/settings.hex $(OUTPUT_DIRECTORY)/bootloader.hex $(SDK_ROOT)/components/softdevice/s112/hex/s112_nrf52_7.2.0_softdevice.hex $(OUTPUT_DIRECTORY)/pixljs.hex --output $(OUTPUT_DIRECTORY)/pixljs_all.hex

gen:
python3 ../scripts/amiibo_db_gen.py
python3 ../scripts/i18n_gen.py
python3 ../scripts/resource_gen.py

flash_ocd: default
openocd -f interface/cmsis-dap.cfg -c "transport select swd" -f target/nrf52.cfg -d2 -c init -c "reset init" -c halt -c "program $(OUTPUT_DIRECTORY)/pixljs.hex verify" -c "reset" -c exit

Expand Down
1 change: 1 addition & 0 deletions fw/application/src/app/amiibo/app_amiibo.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ mini_app_t app_amiibo_info = {.id = MINI_APP_ID_AMIIBO,
.sys = false,
.deamon = false,
.hibernate_enabled = true,
.icon_32x32 = &app_amiibo_emulator_32x32,
.run_cb = app_amiibo_on_run,
.kill_cb = app_amiibo_on_kill,
.on_event_cb = app_amiibo_on_event};
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static void amiibo_scene_amiibo_detail_menu_on_selected(mui_list_view_event_t ev
sprintf(msg, _T(DELETE_TAG_CONFIRM), string_get_cstr(app->current_file));
mui_msg_box_set_message(app->p_msg_box, msg);
mui_msg_box_set_btn_text(app->p_msg_box, _T(CONFIRM), NULL, _T(CANCEL));
mui_msg_box_set_btn_focus(app->p_msg_box, 0);
mui_msg_box_set_btn_focus(app->p_msg_box, 2);
mui_msg_box_set_event_cb(app->p_msg_box, amiibo_scene_amiibo_detail_delete_tag_confirmed);

mui_view_dispatcher_switch_to_view(app->p_view_dispatcher, AMIIBO_VIEW_ID_MSG_BOX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ static void amiibo_scene_file_browser_menu_on_selected(mui_list_view_event_t eve
mui_msg_box_set_header(app->p_msg_box, getLangString(_L_DELETE));
mui_msg_box_set_message(app->p_msg_box, msg);
mui_msg_box_set_btn_text(app->p_msg_box, getLangString(_L_DELETE), NULL, getLangString(_L_CANCEL));
mui_msg_box_set_btn_focus(app->p_msg_box, 0);
mui_msg_box_set_btn_focus(app->p_msg_box, 2);
mui_msg_box_set_event_cb(app->p_msg_box, amiibo_scene_file_browser_menu_msg_box_remove_folder_event_cb);

mui_view_dispatcher_switch_to_view(app->p_view_dispatcher, AMIIBO_VIEW_ID_MSG_BOX);
Expand Down
1 change: 1 addition & 0 deletions fw/application/src/app/amiibolink/app_amiibolink.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ mini_app_t app_amiibolink_info = {.id = MINI_APP_ID_AMIIBOLINK,
.deamon = false,
.sys = false,
.hibernate_enabled = true,
.icon_32x32 = &app_amiibo_link_32x32,
.run_cb = app_amiibolink_on_run,
.kill_cb = app_amiibolink_on_kill,
.on_event_cb = app_amiibolink_on_event};
1 change: 1 addition & 0 deletions fw/application/src/app/amiidb/app_amiidb.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ const mini_app_t app_amiidb_info = {.id = MINI_APP_ID_AMIIDB,
.sys = false,
.deamon = false,
.hibernate_enabled = false,
.icon_32x32 = &app_amiibo_database_32x32,
.run_cb = app_amiidb_on_run,
.kill_cb = app_amiidb_on_kill,
.on_event_cb = app_amiidb_on_event};
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void amiidb_scene_fav_list_menu_msg_box(app_amiidb_t *app, const char *he
mui_msg_box_set_message(app->p_msg_box, msg);
mui_msg_box_set_btn_text(app->p_msg_box, getLangString(_L_APP_AMIIDB_CONFIRM), NULL,
getLangString(_L_APP_AMIIDB_CANCEL));
mui_msg_box_set_btn_focus(app->p_msg_box, 0);
mui_msg_box_set_btn_focus(app->p_msg_box, 2);
mui_msg_box_set_event_cb(app->p_msg_box, cb);

mui_view_dispatcher_switch_to_view(app->p_view_dispatcher, AMIIDB_VIEW_ID_MSG_BOX);
Expand Down
1 change: 1 addition & 0 deletions fw/application/src/app/ble/app_ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ mini_app_t app_ble_info = {.id = MINI_APP_ID_BLE,
.deamon = false,
.sys = false,
.hibernate_enabled = false,
.icon_32x32 = &app_ble_transfer_32x32,
.run_cb = app_ble_on_run,
.kill_cb = app_ble_on_kill,
.on_event_cb = app_ble_on_event};
1 change: 1 addition & 0 deletions fw/application/src/app/chameleon/app_chameleon.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ mini_app_t app_chameleon_info = {.id = MINI_APP_ID_CHAMELEON,
.deamon = false,
.sys = false,
.hibernate_enabled = true,
.icon_32x32 = &app_card_emulator_32x32,
.run_cb = app_chameleon_on_run,
.kill_cb = app_chameleon_on_kill,
.on_event_cb = app_chameleon_on_event};
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ void chameleon_scene_menu_card_data_file_load_from_file(app_chameleon_t *app, co
return;
}

// set nickname by filename
err = tag_helper_set_nickname(file_name);
if (err != 0) {
mui_toast_view_show(app->p_toast_view, _T(APP_CHAMELEON_CARD_SET_NICK_FAILED));
return;
}

NRF_LOG_INFO("load card data:%d", err);
mui_toast_view_show(app->p_toast_view, _T(APP_CHAMELEON_CARD_DATA_LOAD_SUCCESS));
mui_scene_dispatcher_back_scene(app->p_scene_dispatcher, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void chameleon_scene_menu_card_data_file_save_on_enter(void *user_data) {
app_chameleon_t *app = user_data;
char file_name[32];

sprintf(file_name, "%02d.bin", tag_emulation_get_slot());
tag_helper_get_nickname(file_name, sizeof(file_name));

mui_text_input_set_header(app->p_text_input, _T(APP_CHAMELEON_CARD_DATA_SAVE_INPUT_FILE_NAME));
mui_text_input_set_input_text(app->p_text_input, file_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void chameleon_scene_menu_card_type_on_event(mui_list_view_event_t event, mui_li
mui_msg_box_set_header(app->p_msg_box, _T(MESSAGE));
mui_msg_box_set_message(app->p_msg_box, _T(APP_CHAMELEON_CARD_TYPE_FACTORY_DATA_CONFRIM));
mui_msg_box_set_btn_text(app->p_msg_box, _T(CONFIRM), NULL, _T(CANCEL));
mui_msg_box_set_btn_focus(app->p_msg_box, 0);
mui_msg_box_set_btn_focus(app->p_msg_box, 2);
mui_msg_box_set_event_cb(app->p_msg_box, chameleon_scene_menu_card_type_factory_cb);

mui_view_dispatcher_switch_to_view(app->p_view_dispatcher, CHAMELEON_VIEW_ID_MSG_BOX);
Expand Down
16 changes: 11 additions & 5 deletions fw/application/src/app/chameleon/view/chameleon_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static void chameleon_view_on_draw(mui_view_t *p_view, mui_canvas_t *p_canvas) {

mui_canvas_set_font(p_canvas, MUI_FONT_NORMAL);

uint8_t x = 0, y = 0;
uint8_t x = 0, y = 0, w = 0;
mui_canvas_draw_box(p_canvas, 0, y, mui_canvas_get_width(p_canvas), 12);
mui_canvas_set_draw_color(p_canvas, 0);

Expand All @@ -43,13 +43,19 @@ static void chameleon_view_on_draw(mui_view_t *p_view, mui_canvas_t *p_canvas) {

mui_canvas_set_draw_color(p_canvas, 1);

x = 8;
y = 13 + (mui_canvas_get_height(p_canvas) - 16) / 2;
w = mui_canvas_get_width(p_canvas) - x * 2;

tag_helper_get_nickname(buff, sizeof(buff));

y = 13 + (mui_canvas_get_height(p_canvas) - 16) / 2;
x = (mui_canvas_get_width(p_canvas) - mui_canvas_get_utf8_width(p_canvas, buff)) / 2;
mui_canvas_draw_utf8(p_canvas, x, y, buff);
if (w > mui_canvas_get_utf8_width(p_canvas, buff)) {
x += (w - mui_canvas_get_utf8_width(p_canvas, buff)) / 2;
}

mui_canvas_draw_utf8_truncate(p_canvas, x, y, w, buff);
mui_canvas_draw_utf8(p_canvas, 0, y, "<");
mui_canvas_draw_utf8(p_canvas, mui_canvas_get_width(p_canvas) - 8, y, ">");
mui_canvas_draw_utf8(p_canvas, mui_canvas_get_width(p_canvas) - 5, y, ">");

mui_canvas_set_font(p_canvas, MUI_FONT_SMALL);
sprintf(buff, "%s <%02x/%02x %02x>", tag_name->short_name, coll_res->sak[0], coll_res->atqa[0], coll_res->atqa[1]);
Expand Down
26 changes: 13 additions & 13 deletions fw/application/src/app/desktop/app_desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

#include "mui_include.h"

#include "app_list_view.h"
#include "i18n/language.h"
#include "mini_app_launcher.h"
#include "mui_list_view.h"

typedef enum { DESKTOP_VIEW_ID_MAIN } desktop_view_id_t;

Expand All @@ -14,13 +14,13 @@ static void app_desktop_on_kill(mini_app_inst_t *p_app_inst);
static void app_desktop_on_event(mini_app_inst_t *p_app_inst, mini_app_event_t *p_event);

typedef struct {
mui_list_view_t *p_list_view;
app_list_view_t *p_app_list_view;
mui_view_dispatcher_t *p_view_dispatcher;
} app_desktop_t;

static void app_desktop_list_view_on_selected(mui_list_view_event_t event, mui_list_view_t *p_view,
mui_list_item_t *p_item) {
mini_app_launcher_run(mini_app_launcher(), (uint32_t)p_item->user_data);
static void app_desktop_list_view_on_selected(app_list_view_event_t event, app_list_view_t *p_view) {
mini_app_t * app = app_list_view_get(p_view, app_list_view_get_focus(p_view));
mini_app_launcher_run(mini_app_launcher(), app->id);
}

void app_desktop_on_run(mini_app_inst_t *p_app_inst) {
Expand All @@ -29,30 +29,30 @@ void app_desktop_on_run(mini_app_inst_t *p_app_inst) {

p_app_inst->p_handle = p_app_handle;
p_app_handle->p_view_dispatcher = mui_view_dispatcher_create();
p_app_handle->p_list_view = mui_list_view_create();
p_app_handle->p_app_list_view = app_list_view_create();

for (uint32_t i = 0; i < mini_app_registry_get_app_num(); i++) {
const mini_app_t *p_app = mini_app_registry_find_by_index(i);
if (!p_app->sys) {
mui_list_view_add_item(p_app_handle->p_list_view, p_app->icon, getLangString(p_app->name_i18n_key),
(void *)p_app->id);
app_list_view_add_app(p_app_handle->p_app_list_view, p_app);
}
}

mui_list_view_set_selected_cb(p_app_handle->p_list_view, app_desktop_list_view_on_selected);
app_list_view_set_event_cb(p_app_handle->p_app_list_view, app_desktop_list_view_on_selected);

mui_view_dispatcher_add_view(p_app_handle->p_view_dispatcher, DESKTOP_VIEW_ID_MAIN,
mui_list_view_get_view(p_app_handle->p_list_view));
mui_view_dispatcher_attach(p_app_handle->p_view_dispatcher, MUI_LAYER_DESKTOP);
app_list_view_get_view(p_app_handle->p_app_list_view));
mui_view_dispatcher_attach(p_app_handle->p_view_dispatcher, MUI_LAYER_WINDOW);
mui_view_dispatcher_switch_to_view(p_app_handle->p_view_dispatcher, DESKTOP_VIEW_ID_MAIN);
}

void app_desktop_on_kill(mini_app_inst_t *p_app_inst) {
app_desktop_t *p_app_handle = p_app_inst->p_handle;

mui_view_dispatcher_detach(p_app_handle->p_view_dispatcher, MUI_LAYER_DESKTOP);
mui_view_dispatcher_switch_to_view(p_app_handle->p_view_dispatcher, VIEW_NONE);
mui_view_dispatcher_detach(p_app_handle->p_view_dispatcher, MUI_LAYER_WINDOW);
mui_view_dispatcher_free(p_app_handle->p_view_dispatcher);
mui_list_view_free(p_app_handle->p_list_view);
app_list_view_free(p_app_handle->p_app_list_view);

mui_mem_free(p_app_handle);

Expand Down
Loading

0 comments on commit fc2c0f5

Please sign in to comment.