Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Merge branch 'unleashed/dev' into dev
Browse files Browse the repository at this point in the history
Merge only part of commits from

https://github.com/DarkFlippers/unleashed-firmware/tree/dev

Excluding some breaking changes and other things, that will be merged after release
  • Loading branch information
xMasterX committed Apr 5, 2024
1 parent ad82ee1 commit d7c1614
Show file tree
Hide file tree
Showing 24 changed files with 2,286 additions and 41 deletions.
9 changes: 9 additions & 0 deletions applications/main/nfc/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ App(
sources=["plugins/supported_cards/metromoney.c"],
)

App(
appid="charliecard_parser",
apptype=FlipperAppType.PLUGIN,
entry_point="charliecard_plugin_ep",
targets=["f7"],
requires=["nfc"],
sources=["plugins/supported_cards/charliecard.c"],
)

App(
appid="kazan_parser",
apptype=FlipperAppType.PLUGIN,
Expand Down
1,059 changes: 1,059 additions & 0 deletions applications/main/nfc/plugins/supported_cards/charliecard.c

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions applications/main/nfc/scenes/nfc_scene_mf_ultralight_unlock_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ void nfc_scene_mf_ultralight_unlock_menu_on_enter(void* context) {
uint32_t state =
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMfUltralightUnlockMenu);
if(nfc_device_get_protocol(nfc->nfc_device) == NfcProtocolMfUltralight) {
submenu_add_item(
submenu,
"Unlock With Reader",
SubmenuIndexMfUlUnlockMenuReader,
nfc_scene_mf_ultralight_unlock_menu_submenu_callback,
nfc);
const MfUltralightData* mfu_data =
nfc_device_get_data(nfc->nfc_device, NfcProtocolMfUltralight);
// Hide for MFU-C since it uses 3DES
if(mfu_data->type != MfUltralightTypeMfulC) {
submenu_add_item(
submenu,
"Unlock With Reader",
SubmenuIndexMfUlUnlockMenuReader,
nfc_scene_mf_ultralight_unlock_menu_submenu_callback,
nfc);
}
}
submenu_add_item(
submenu,
Expand Down
15 changes: 12 additions & 3 deletions applications/services/desktop/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ static void desktop_loader_callback(const void* message, void* context) {
Desktop* desktop = context;
const LoaderEvent* event = message;

if(event->type == LoaderEventTypeApplicationStarted) {
if(event->type == LoaderEventTypeApplicationBeforeLoad) {
desktop->animation_lock = api_lock_alloc_locked();
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalBeforeAppStarted);
} else if(event->type == LoaderEventTypeApplicationStopped) {
api_lock_wait_unlock_and_free(desktop->animation_lock);
desktop->animation_lock = NULL;
} else if(
event->type == LoaderEventTypeApplicationLoadFailed ||
event->type == LoaderEventTypeApplicationStopped) {
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAfterAppFinished);
}
}

static void desktop_lock_icon_draw_callback(Canvas* canvas, void* context) {
UNUSED(context);
furi_assert(canvas);
Expand Down Expand Up @@ -115,8 +121,11 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {

switch(event) {
case DesktopGlobalBeforeAppStarted:
animation_manager_unload_and_stall_animation(desktop->animation_manager);
if(animation_manager_is_animation_loaded(desktop->animation_manager)) {
animation_manager_unload_and_stall_animation(desktop->animation_manager);
}
desktop_auto_lock_inhibit(desktop);
api_lock_unlock(desktop->animation_lock);
return true;
case DesktopGlobalAfterAppFinished:
animation_manager_load_and_continue_animation(desktop->animation_manager);
Expand Down
3 changes: 3 additions & 0 deletions applications/services/desktop/desktop_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <loader/loader.h>
#include <notification/notification_app.h>
#include <toolbox/api_lock.h>

#define STATUS_BAR_Y_SHIFT 13

Expand Down Expand Up @@ -84,6 +85,8 @@ struct Desktop {

FuriPubSub* ascii_events_pubsub;
FuriPubSubSubscription* ascii_events_subscription;

FuriApiLock animation_lock;
};

Desktop* desktop_alloc();
Expand Down
20 changes: 6 additions & 14 deletions applications/services/desktop/scenes/desktop_scene_lock_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,9 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
if(desktop_pin_is_valid(&desktop->settings.pin_code)) {
desktop_lock(desktop, true);
} else {
LoaderStatus status = loader_start(
desktop->loader, "Desktop", DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG, NULL);
if(status == LoaderStatusOk) {
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 1);
} else {
FURI_LOG_E(TAG, "Unable to start desktop settings");
}
loader_start_detached_with_gui_error(
desktop->loader, "Desktop", DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG);
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 1);
}
consumed = true;
break;
Expand All @@ -110,13 +106,9 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
power_off(power);
furi_record_close(RECORD_POWER);
} else {
LoaderStatus status = loader_start(
desktop->loader, "Desktop", DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG, NULL);
if(status == LoaderStatusOk) {
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 2);
} else {
FURI_LOG_E(TAG, "Unable to start desktop settings");
}
loader_start_detached_with_gui_error(
desktop->loader, "Desktop", DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG);
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 2);
}
consumed = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) {
switch(event.event) {
case DesktopLockedEventOpenPowerOff: {
if(xtreme_settings.lockscreen_poweroff) {
loader_start(desktop->loader, "Power", "off", NULL);
loader_start_detached_with_gui_error(desktop->loader, "Power", "off");
}
consumed = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion applications/services/desktop/scenes/desktop_scene_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
break;

case DesktopMainEventOpenPowerOff: {
loader_start(desktop->loader, "Power", "off", NULL);
loader_start_detached_with_gui_error(desktop->loader, "Power", "off");
consumed = true;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion applications/services/gui/modules/text_box.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void text_box_insert_endline(Canvas* canvas, TextBoxModel* model) {
line_num++;
model->text = furi_string_get_cstr(model->text_formatted);
model->text_pos = (char*)model->text;
uint8_t lines_on_screen = 56 / canvas_current_font_height(canvas);
size_t lines_on_screen = 56 / canvas_current_font_height(canvas);
if(model->focus == TextBoxFocusEnd && line_num > lines_on_screen) {
// Set text position to 5th line from the end
const char* end = model->text + furi_string_size(model->text_formatted);
Expand Down
17 changes: 13 additions & 4 deletions applications/services/loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ static void loader_start_internal_app(
const FlipperInternalApplication* app,
const char* args) {
FURI_LOG_I(TAG, "Starting %s", app->name);
LoaderEvent event;
event.type = LoaderEventTypeApplicationBeforeLoad;
furi_pubsub_publish(loader->pubsub, &event);

// store args
furi_assert(loader->app.args == NULL);
Expand Down Expand Up @@ -429,6 +432,9 @@ static LoaderStatus loader_start_external_app(
FuriString* error_message,
FlipperApplicationFlag flags) {
LoaderStatus status = loader_make_success_status(error_message);
LoaderEvent event;
event.type = LoaderEventTypeApplicationBeforeLoad;
furi_pubsub_publish(loader->pubsub, &event);

do {
loader->app.fap = flipper_application_alloc(storage, firmware_api_interface);
Expand Down Expand Up @@ -456,7 +462,7 @@ static LoaderStatus loader_start_external_app(
if(load_status != FlipperApplicationLoadStatusSuccess) {
const char* err_msg = flipper_application_load_status_to_string(load_status);
status = loader_make_status_error(
LoaderStatusErrorInternal, error_message, "Load failed %s: %s", path, err_msg);
LoaderStatusErrorInternal, error_message, "Load failed, %s: %s", path, err_msg);
break;
} else if(api_mismatch) {
// Successful map, but found api mismatch -> warn user
Expand Down Expand Up @@ -512,11 +518,14 @@ static LoaderStatus loader_start_external_app(

loader_start_app_thread(loader, flags);

return status;
} while(0);

flipper_application_free(loader->app.fap);
loader->app.fap = NULL;
if(status != LoaderStatusOk) {
flipper_application_free(loader->app.fap);
loader->app.fap = NULL;
event.type = LoaderEventTypeApplicationLoadFailed;
furi_pubsub_publish(loader->pubsub, &event);
}

return status;
}
Expand Down
2 changes: 2 additions & 0 deletions applications/services/loader/loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ typedef enum {
} LoaderStatus;

typedef enum {
LoaderEventTypeApplicationBeforeLoad,
LoaderEventTypeApplicationLoadFailed,
LoaderEventTypeApplicationStarted,
LoaderEventTypeApplicationStopped
} LoaderEventType;
Expand Down
1 change: 1 addition & 0 deletions applications/system/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ App(
"updater_app",
"storage_move_to_sd",
"js_app",
"js_app_start",
"findmyflipper_autostart",
# "archive",
],
Expand Down
15 changes: 15 additions & 0 deletions applications/system/js_app/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ App(
fap_category="assets",
)

App(
appid="js_app_start",
apptype=FlipperAppType.STARTUP,
entry_point="js_app_on_system_start",
order=160,
)

App(
appid="js_dialog",
apptype=FlipperAppType.PLUGIN,
Expand Down Expand Up @@ -117,3 +124,11 @@ App(
requires=["js_app"],
sources=["modules/js_textbox.c"],
)

App(
appid="js_widget",
apptype=FlipperAppType.PLUGIN,
entry_point="js_widget_ep",
requires=["js_app"],
sources=["modules/js_widget.c"],
)
9 changes: 9 additions & 0 deletions applications/system/js_app/examples/apps/Scripts/path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let storage = require("storage");

print("script has __dirpath of" + __dirpath);
print("script has __filepath of" + __filepath);
if (storage.exists(__dirpath + "/math.js")) {
print("math.js exist here.");
} else {
print("math.js does not exist here.");
}
Binary file not shown.
59 changes: 59 additions & 0 deletions applications/system/js_app/examples/apps/Scripts/widget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
let widget = require("widget");

let demo_seconds = 30;

print("Loading file", __filepath);
print("From directory", __dirpath);

// addText supports "Primary" and "Secondary" font sizes.
widget.addText(10, 10, "Primary", "Example JS widget");
widget.addText(10, 20, "Secondary", "Example widget from JS!");

// load a Xbm file from the same directory as this script.
widget.addText(0, 30, "Secondary", __filepath);
let logo = widget.loadImageXbm(__dirpath + "/widget-js.fxbm");

// add a line (x1, y1, x2, y2)
widget.addLine(10, 35, 120, 35);

// add a circle/disc (x, y, radius)
widget.addCircle(12, 52, 10);
widget.addDisc(12, 52, 5);

// add a frame/box (x, y, width, height)
widget.addFrame(30, 45, 10, 10);
widget.addBox(32, 47, 6, 6);

// add a rounded frame/box (x, y, width, height, radius)
widget.addRframe(50, 45, 15, 15, 3);
widget.addRbox(53, 48, 6, 6, 2);

// add a dot (x, y)
widget.addDot(100, 45);
widget.addDot(102, 44);
widget.addDot(104, 43);

// add a glyph (x, y, glyph)
widget.addGlyph(115, 50, "#".charCodeAt(0));

// Show the widget (drawing the layers in the orderer they were added)
widget.show();

let i = 1;
let bitmap = undefined;
while (widget.isOpen() && i <= demo_seconds) {
// Print statements will only show up once the widget is closed.
print("count is at", i++);

// You can call remove on any added item, it does not impact the other ids.
if (bitmap) { widget.remove(bitmap); bitmap = undefined; }
// All of the addXXX functions return an id that can be used to remove the item.
else { bitmap = widget.addXbm(77, 45, logo); }

delay(1000);
}

// If user did not press the back button, close the widget.
if (widget.isOpen()) {
widget.close();
}
Loading

0 comments on commit d7c1614

Please sign in to comment.