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
189 lines
5.8 KiB
C
189 lines
5.8 KiB
C
#include "dap_main_view.h"
|
|
#include "dap_link_icons.h"
|
|
#include <gui/elements.h>
|
|
|
|
// extern const Icon I_ArrowDownEmpty_12x18;
|
|
// extern const Icon I_ArrowDownFilled_12x18;
|
|
// extern const Icon I_ArrowUpEmpty_12x18;
|
|
// extern const Icon I_ArrowUpFilled_12x18;
|
|
|
|
struct DapMainView {
|
|
View* view;
|
|
DapMainViewButtonCallback cb_left;
|
|
void* cb_context;
|
|
};
|
|
|
|
typedef struct {
|
|
DapMainViewMode mode;
|
|
DapMainViewVersion version;
|
|
bool usb_connected;
|
|
uint32_t baudrate;
|
|
bool dap_active;
|
|
bool tx_active;
|
|
bool rx_active;
|
|
} DapMainViewModel;
|
|
|
|
static void dap_main_view_draw_callback(Canvas* canvas, void* _model) {
|
|
DapMainViewModel* model = _model;
|
|
UNUSED(model);
|
|
canvas_clear(canvas);
|
|
elements_button_left(canvas, "Config");
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
canvas_draw_box(canvas, 0, 0, 127, 11);
|
|
canvas_set_color(canvas, ColorWhite);
|
|
|
|
const char* header_string;
|
|
if(model->usb_connected) {
|
|
if(model->version == DapMainViewVersionV1) {
|
|
header_string = "DAP Link V1 Connected";
|
|
} else if(model->version == DapMainViewVersionV2) {
|
|
header_string = "DAP Link V2 Connected";
|
|
} else {
|
|
header_string = "DAP Link Connected";
|
|
}
|
|
} else {
|
|
header_string = "DAP Link";
|
|
}
|
|
|
|
canvas_draw_str_aligned(canvas, 64, 9, AlignCenter, AlignBottom, header_string);
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
if(model->dap_active) {
|
|
canvas_draw_icon(canvas, 14, 16, &I_ArrowUpFilled_12x18);
|
|
canvas_draw_icon(canvas, 28, 16, &I_ArrowDownFilled_12x18);
|
|
} else {
|
|
canvas_draw_icon(canvas, 14, 16, &I_ArrowUpEmpty_12x18);
|
|
canvas_draw_icon(canvas, 28, 16, &I_ArrowDownEmpty_12x18);
|
|
}
|
|
|
|
switch(model->mode) {
|
|
case DapMainViewModeDisconnected:
|
|
canvas_draw_str_aligned(canvas, 26, 38, AlignCenter, AlignTop, "----");
|
|
break;
|
|
case DapMainViewModeSWD:
|
|
canvas_draw_str_aligned(canvas, 26, 38, AlignCenter, AlignTop, "SWD");
|
|
break;
|
|
case DapMainViewModeJTAG:
|
|
canvas_draw_str_aligned(canvas, 26, 38, AlignCenter, AlignTop, "JTAG");
|
|
break;
|
|
}
|
|
|
|
if(model->tx_active) {
|
|
canvas_draw_icon(canvas, 87, 16, &I_ArrowUpFilled_12x18);
|
|
} else {
|
|
canvas_draw_icon(canvas, 87, 16, &I_ArrowUpEmpty_12x18);
|
|
}
|
|
|
|
if(model->rx_active) {
|
|
canvas_draw_icon(canvas, 101, 16, &I_ArrowDownFilled_12x18);
|
|
} else {
|
|
canvas_draw_icon(canvas, 101, 16, &I_ArrowDownEmpty_12x18);
|
|
}
|
|
|
|
canvas_draw_str_aligned(canvas, 100, 38, AlignCenter, AlignTop, "UART");
|
|
|
|
canvas_draw_line(canvas, 44, 52, 123, 52);
|
|
if(model->baudrate == 0) {
|
|
canvas_draw_str(canvas, 45, 62, "Baud: ????");
|
|
} else {
|
|
char baudrate_str[18];
|
|
snprintf(baudrate_str, 18, "Baud: %lu", model->baudrate);
|
|
canvas_draw_str(canvas, 45, 62, baudrate_str);
|
|
}
|
|
}
|
|
|
|
static bool dap_main_view_input_callback(InputEvent* event, void* context) {
|
|
furi_assert(context);
|
|
DapMainView* dap_main_view = context;
|
|
bool consumed = false;
|
|
|
|
if(event->type == InputTypeShort) {
|
|
if(event->key == InputKeyLeft) {
|
|
if(dap_main_view->cb_left) {
|
|
dap_main_view->cb_left(dap_main_view->cb_context);
|
|
}
|
|
consumed = true;
|
|
}
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
DapMainView* dap_main_view_alloc() {
|
|
DapMainView* dap_main_view = malloc(sizeof(DapMainView));
|
|
|
|
dap_main_view->view = view_alloc();
|
|
view_allocate_model(dap_main_view->view, ViewModelTypeLocking, sizeof(DapMainViewModel));
|
|
view_set_context(dap_main_view->view, dap_main_view);
|
|
view_set_draw_callback(dap_main_view->view, dap_main_view_draw_callback);
|
|
view_set_input_callback(dap_main_view->view, dap_main_view_input_callback);
|
|
return dap_main_view;
|
|
}
|
|
|
|
void dap_main_view_free(DapMainView* dap_main_view) {
|
|
view_free(dap_main_view->view);
|
|
free(dap_main_view);
|
|
}
|
|
|
|
View* dap_main_view_get_view(DapMainView* dap_main_view) {
|
|
return dap_main_view->view;
|
|
}
|
|
|
|
void dap_main_view_set_left_callback(
|
|
DapMainView* dap_main_view,
|
|
DapMainViewButtonCallback callback,
|
|
void* context) {
|
|
with_view_model(
|
|
dap_main_view->view,
|
|
DapMainViewModel * model,
|
|
{
|
|
UNUSED(model);
|
|
dap_main_view->cb_left = callback;
|
|
dap_main_view->cb_context = context;
|
|
},
|
|
true);
|
|
}
|
|
|
|
void dap_main_view_set_mode(DapMainView* dap_main_view, DapMainViewMode mode) {
|
|
with_view_model(
|
|
dap_main_view->view, DapMainViewModel * model, { model->mode = mode; }, false);
|
|
}
|
|
|
|
void dap_main_view_set_dap(DapMainView* dap_main_view, bool active) {
|
|
with_view_model(
|
|
dap_main_view->view, DapMainViewModel * model, { model->dap_active = active; }, false);
|
|
}
|
|
|
|
void dap_main_view_set_tx(DapMainView* dap_main_view, bool active) {
|
|
with_view_model(
|
|
dap_main_view->view, DapMainViewModel * model, { model->tx_active = active; }, false);
|
|
}
|
|
|
|
void dap_main_view_set_rx(DapMainView* dap_main_view, bool active) {
|
|
with_view_model(
|
|
dap_main_view->view, DapMainViewModel * model, { model->rx_active = active; }, false);
|
|
}
|
|
|
|
void dap_main_view_set_baudrate(DapMainView* dap_main_view, uint32_t baudrate) {
|
|
with_view_model(
|
|
dap_main_view->view, DapMainViewModel * model, { model->baudrate = baudrate; }, false);
|
|
}
|
|
|
|
void dap_main_view_update(DapMainView* dap_main_view) {
|
|
with_view_model(
|
|
dap_main_view->view, DapMainViewModel * model, { UNUSED(model); }, true);
|
|
}
|
|
|
|
void dap_main_view_set_version(DapMainView* dap_main_view, DapMainViewVersion version) {
|
|
with_view_model(
|
|
dap_main_view->view, DapMainViewModel * model, { model->version = version; }, false);
|
|
}
|
|
|
|
void dap_main_view_set_usb_connected(DapMainView* dap_main_view, bool connected) {
|
|
with_view_model(
|
|
dap_main_view->view,
|
|
DapMainViewModel * model,
|
|
{ model->usb_connected = connected; },
|
|
false);
|
|
} |