53435579b3
* fbt, faploader: minimal app module implementation * faploader, libs: moved API hashtable core to flipper_application * example: compound api * lib: flipper_application: naming fixes, doxygen comments * fbt: changed `requires` manifest field behavior for app extensions * examples: refactored plugin apps; faploader: changed new API naming; fbt: changed PLUGIN app type meaning * loader: dropped support for debug apps & plugin menus * moved applications/plugins -> applications/external * Restored x bit on chiplist_convert.py * git: fixed free-dap submodule path * pvs: updated submodule paths * examples: example_advanced_plugins.c: removed potential memory leak on errors * examples: example_plugins: refined requires * fbt: not deploying app modules for debug/sample apps; extra validation for .PLUGIN-type apps * apps: removed cdefines for external apps * fbt: moved ext app path definition * fbt: reworked fap_dist handling; f18: synced api_symbols.csv * fbt: removed resources_paths for extapps * scripts: reworked storage * scripts: reworked runfap.py & selfupdate.py to use new api * wip: fal runner * fbt: moved file packaging into separate module * scripts: storage: fixes * scripts: storage: minor fixes for new api * fbt: changed internal artifact storage details for external apps * scripts: storage: additional fixes and better error reporting; examples: using APP_DATA_PATH() * fbt, scripts: reworked launch_app to deploy plugins; moved old runfap.py to distfap.py * fbt: extra check for plugins descriptors * fbt: additional checks in emitter * fbt: better info message on SDK rebuild * scripts: removed requirements.txt * loader: removed remnants of plugins & debug menus * post-review fixes
154 lines
5.3 KiB
C
154 lines
5.3 KiB
C
#include "../dap_gui_i.h"
|
|
#include "../../dap_link.h"
|
|
|
|
typedef struct {
|
|
DapState dap_state;
|
|
bool dap_active;
|
|
bool tx_active;
|
|
bool rx_active;
|
|
} DapSceneMainState;
|
|
|
|
static bool process_dap_state(DapGuiApp* app) {
|
|
DapSceneMainState* state =
|
|
(DapSceneMainState*)scene_manager_get_scene_state(app->scene_manager, DapSceneMain);
|
|
if(state == NULL) return true;
|
|
|
|
DapState* prev_state = &state->dap_state;
|
|
DapState next_state;
|
|
dap_app_get_state(app->dap_app, &next_state);
|
|
bool need_to_update = false;
|
|
|
|
if(prev_state->dap_mode != next_state.dap_mode) {
|
|
switch(next_state.dap_mode) {
|
|
case DapModeDisconnected:
|
|
dap_main_view_set_mode(app->main_view, DapMainViewModeDisconnected);
|
|
notification_message(app->notifications, &sequence_blink_stop);
|
|
break;
|
|
case DapModeSWD:
|
|
dap_main_view_set_mode(app->main_view, DapMainViewModeSWD);
|
|
notification_message(app->notifications, &sequence_blink_start_blue);
|
|
break;
|
|
case DapModeJTAG:
|
|
dap_main_view_set_mode(app->main_view, DapMainViewModeJTAG);
|
|
notification_message(app->notifications, &sequence_blink_start_magenta);
|
|
break;
|
|
}
|
|
need_to_update = true;
|
|
}
|
|
|
|
if(prev_state->dap_version != next_state.dap_version) {
|
|
switch(next_state.dap_version) {
|
|
case DapVersionUnknown:
|
|
dap_main_view_set_version(app->main_view, DapMainViewVersionUnknown);
|
|
break;
|
|
case DapVersionV1:
|
|
dap_main_view_set_version(app->main_view, DapMainViewVersionV1);
|
|
break;
|
|
case DapVersionV2:
|
|
dap_main_view_set_version(app->main_view, DapMainViewVersionV2);
|
|
break;
|
|
}
|
|
need_to_update = true;
|
|
}
|
|
|
|
if(prev_state->usb_connected != next_state.usb_connected) {
|
|
dap_main_view_set_usb_connected(app->main_view, next_state.usb_connected);
|
|
need_to_update = true;
|
|
}
|
|
|
|
if(prev_state->dap_counter != next_state.dap_counter) {
|
|
if(!state->dap_active) {
|
|
state->dap_active = true;
|
|
dap_main_view_set_dap(app->main_view, state->dap_active);
|
|
need_to_update = true;
|
|
}
|
|
} else {
|
|
if(state->dap_active) {
|
|
state->dap_active = false;
|
|
dap_main_view_set_dap(app->main_view, state->dap_active);
|
|
need_to_update = true;
|
|
}
|
|
}
|
|
|
|
if(prev_state->cdc_baudrate != next_state.cdc_baudrate) {
|
|
dap_main_view_set_baudrate(app->main_view, next_state.cdc_baudrate);
|
|
need_to_update = true;
|
|
}
|
|
|
|
if(prev_state->cdc_tx_counter != next_state.cdc_tx_counter) {
|
|
if(!state->tx_active) {
|
|
state->tx_active = true;
|
|
dap_main_view_set_tx(app->main_view, state->tx_active);
|
|
need_to_update = true;
|
|
notification_message(app->notifications, &sequence_blink_start_red);
|
|
}
|
|
} else {
|
|
if(state->tx_active) {
|
|
state->tx_active = false;
|
|
dap_main_view_set_tx(app->main_view, state->tx_active);
|
|
need_to_update = true;
|
|
notification_message(app->notifications, &sequence_blink_stop);
|
|
}
|
|
}
|
|
|
|
if(prev_state->cdc_rx_counter != next_state.cdc_rx_counter) {
|
|
if(!state->rx_active) {
|
|
state->rx_active = true;
|
|
dap_main_view_set_rx(app->main_view, state->rx_active);
|
|
need_to_update = true;
|
|
notification_message(app->notifications, &sequence_blink_start_green);
|
|
}
|
|
} else {
|
|
if(state->rx_active) {
|
|
state->rx_active = false;
|
|
dap_main_view_set_rx(app->main_view, state->rx_active);
|
|
need_to_update = true;
|
|
notification_message(app->notifications, &sequence_blink_stop);
|
|
}
|
|
}
|
|
|
|
if(need_to_update) {
|
|
dap_main_view_update(app->main_view);
|
|
}
|
|
|
|
*prev_state = next_state;
|
|
return true;
|
|
}
|
|
|
|
static void dap_scene_main_on_left(void* context) {
|
|
DapGuiApp* app = (DapGuiApp*)context;
|
|
view_dispatcher_send_custom_event(app->view_dispatcher, DapAppCustomEventConfig);
|
|
}
|
|
|
|
void dap_scene_main_on_enter(void* context) {
|
|
DapGuiApp* app = context;
|
|
DapSceneMainState* state = malloc(sizeof(DapSceneMainState));
|
|
dap_main_view_set_left_callback(app->main_view, dap_scene_main_on_left, app);
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, DapGuiAppViewMainView);
|
|
scene_manager_set_scene_state(app->scene_manager, DapSceneMain, (uint32_t)state);
|
|
}
|
|
|
|
bool dap_scene_main_on_event(void* context, SceneManagerEvent event) {
|
|
DapGuiApp* app = context;
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
if(event.event == DapAppCustomEventConfig) {
|
|
scene_manager_next_scene(app->scene_manager, DapSceneConfig);
|
|
return true;
|
|
}
|
|
} else if(event.type == SceneManagerEventTypeTick) {
|
|
return process_dap_state(app);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void dap_scene_main_on_exit(void* context) {
|
|
DapGuiApp* app = context;
|
|
DapSceneMainState* state =
|
|
(DapSceneMainState*)scene_manager_get_scene_state(app->scene_manager, DapSceneMain);
|
|
scene_manager_set_scene_state(app->scene_manager, DapSceneMain, (uint32_t)NULL);
|
|
FURI_SW_MEMBARRIER();
|
|
free(state);
|
|
notification_message(app->notifications, &sequence_blink_stop);
|
|
} |