Skip to content

Commit

Permalink
Merge branch 'flipperdevices:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Astrrra authored Aug 20, 2022
2 parents bcf1b18 + fdb181b commit 9b6fa1a
Show file tree
Hide file tree
Showing 149 changed files with 2,484 additions and 1,182 deletions.
4 changes: 3 additions & 1 deletion applications/about/about.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <gui/modules/empty_screen.h>
#include <m-string.h>
#include <furi_hal_version.h>
#include <furi_hal_region.h>
#include <furi_hal_bt.h>

typedef DialogMessageButton (*AboutDialogScreen)(DialogsApp* dialogs, DialogMessage* message);
Expand Down Expand Up @@ -84,12 +85,13 @@ static DialogMessageButton hw_version_screen(DialogsApp* dialogs, DialogMessage*

string_cat_printf(
buffer,
"%d.F%dB%dC%d %s %s\n",
"%d.F%dB%dC%d %s:%s %s\n",
furi_hal_version_get_hw_version(),
furi_hal_version_get_hw_target(),
furi_hal_version_get_hw_body(),
furi_hal_version_get_hw_connect(),
furi_hal_version_get_hw_region_name(),
furi_hal_region_get_name(),
my_name ? my_name : "Unknown");

string_cat_printf(buffer, "Serial Number:\n");
Expand Down
4 changes: 2 additions & 2 deletions applications/accessor/accessor_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ void AccessorApp::run(void) {
}

AccessorApp::AccessorApp() {
notification = static_cast<NotificationApp*>(furi_record_open("notification"));
notification = static_cast<NotificationApp*>(furi_record_open(RECORD_NOTIFICATION));
onewire_host = onewire_host_alloc();
furi_hal_power_enable_otg();
}

AccessorApp::~AccessorApp() {
furi_hal_power_disable_otg();
furi_record_close("notification");
furi_record_close(RECORD_NOTIFICATION);
onewire_host_free(onewire_host);
}

Expand Down
3 changes: 2 additions & 1 deletion applications/accessor/accessor_view_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AccessorAppViewManager::AccessorAppViewManager() {
popup = popup_alloc();
add_view(ViewType::Popup, popup_get_view(popup));

gui = static_cast<Gui*>(furi_record_open("gui"));
gui = static_cast<Gui*>(furi_record_open(RECORD_GUI));
view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen);

// set previous view callback for all views
Expand All @@ -31,6 +31,7 @@ AccessorAppViewManager::~AccessorAppViewManager() {
view_dispatcher, static_cast<uint32_t>(AccessorAppViewManager::ViewType::Popup));

// free view modules
furi_record_close(RECORD_GUI);
submenu_free(submenu);
popup_free(popup);

Expand Down
2 changes: 2 additions & 0 deletions applications/applications.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ typedef struct {

typedef void (*FlipperOnStartHook)(void);

extern const char* FLIPPER_AUTORUN_APP_NAME;

/* Services list
* Spawned on startup
*/
Expand Down
12 changes: 6 additions & 6 deletions applications/archive/helpers/archive_favorites.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ uint16_t archive_favorites_count(void* context) {
break;
}
if(!string_size(buffer)) {
break;
continue; // Skip empty lines
}
++lines;
}
Expand Down Expand Up @@ -93,7 +93,7 @@ static bool archive_favourites_rescan() {
break;
}
if(!string_size(buffer)) {
break;
continue;
}

if(string_search(buffer, "/app:") == 0) {
Expand Down Expand Up @@ -152,7 +152,7 @@ bool archive_favorites_read(void* context) {
break;
}
if(!string_size(buffer)) {
break;
continue;
}

if(string_search(buffer, "/app:") == 0) {
Expand Down Expand Up @@ -215,7 +215,7 @@ bool archive_favorites_delete(const char* format, ...) {
break;
}
if(!string_size(buffer)) {
break;
continue;
}

if(string_search(buffer, filename)) {
Expand Down Expand Up @@ -259,7 +259,7 @@ bool archive_is_favorite(const char* format, ...) {
break;
}
if(!string_size(buffer)) {
break;
continue;
}
if(!string_search(buffer, filename)) {
found = true;
Expand Down Expand Up @@ -299,7 +299,7 @@ bool archive_favorites_rename(const char* src, const char* dst) {
break;
}
if(!string_size(buffer)) {
break;
continue;
}

archive_file_append(
Expand Down
3 changes: 2 additions & 1 deletion applications/bt/bt_hid_app/bt_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ BtHid* bt_hid_app_alloc() {
app->view_dispatcher, BtHidViewMouse, bt_hid_mouse_get_view(app->bt_hid_mouse));

// TODO switch to menu after Media is done
view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewKeynote);
app->view_id = BtHidViewKeynote;
view_dispatcher_switch_to_view(app->view_dispatcher, app->view_id);

return app;
}
Expand Down
2 changes: 1 addition & 1 deletion applications/cli/cli_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
void cli_command_device_info_callback(const char* key, const char* value, bool last, void* context) {
UNUSED(context);
UNUSED(last);
printf("%-24s: %s\r\n", key, value);
printf("%-30s: %s\r\n", key, value);
}

/*
Expand Down
4 changes: 4 additions & 0 deletions applications/desktop/helpers/slideshow.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ bool slideshow_is_loaded(Slideshow* slideshow) {
return slideshow->loaded;
}

bool slideshow_is_one_page(Slideshow* slideshow) {
return slideshow->loaded && (slideshow->icon.frame_count == 1);
}

bool slideshow_advance(Slideshow* slideshow) {
uint8_t next_frame = slideshow->current_frame + 1;
if(next_frame < slideshow->icon.frame_count) {
Expand Down
1 change: 1 addition & 0 deletions applications/desktop/helpers/slideshow.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Slideshow* slideshow_alloc();
void slideshow_free(Slideshow* slideshow);
bool slideshow_load(Slideshow* slideshow, const char* fspath);
bool slideshow_is_loaded(Slideshow* slideshow);
bool slideshow_is_one_page(Slideshow* slideshow);
void slideshow_goback(Slideshow* slideshow);
bool slideshow_advance(Slideshow* slideshow);
void slideshow_draw(Slideshow* slideshow, Canvas* canvas, uint8_t x, uint8_t y);
18 changes: 10 additions & 8 deletions applications/desktop/views/desktop_view_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ void desktop_debug_render(Canvas* canvas, void* model) {
const Version* ver;
char buffer[64];

static const char* headers[] = {"FW Version Info:", "Dolphin Info:"};
static const char* headers[] = {"Device Info:", "Dolphin Info:"};

canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 2, 9 + STATUS_BAR_Y_SHIFT, headers[m->screen]);
canvas_draw_str_aligned(
canvas, 64, 1 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignTop, headers[m->screen]);
canvas_set_font(canvas, FontSecondary);

if(m->screen != DesktopViewStatsMeta) {
Expand All @@ -36,22 +37,23 @@ void desktop_debug_render(Canvas* canvas, void* model) {
snprintf(
buffer,
sizeof(buffer),
"%d.F%dB%dC%d %s %s",
"%d.F%dB%dC%d %s:%s %s",
furi_hal_version_get_hw_version(),
furi_hal_version_get_hw_target(),
furi_hal_version_get_hw_body(),
furi_hal_version_get_hw_connect(),
furi_hal_version_get_hw_region_name(),
furi_hal_region_get_name(),
my_name ? my_name : "Unknown");
canvas_draw_str(canvas, 5, 19 + STATUS_BAR_Y_SHIFT, buffer);
canvas_draw_str(canvas, 0, 19 + STATUS_BAR_Y_SHIFT, buffer);

ver = furi_hal_version_get_firmware_version();
const BleGlueC2Info* c2_ver = NULL;
#ifdef SRV_BT
c2_ver = ble_glue_get_c2_info();
#endif
if(!ver) {
canvas_draw_str(canvas, 5, 29 + STATUS_BAR_Y_SHIFT, "No info");
canvas_draw_str(canvas, 0, 30 + STATUS_BAR_Y_SHIFT, "No info");
return;
}

Expand All @@ -61,7 +63,7 @@ void desktop_debug_render(Canvas* canvas, void* model) {
"%s [%s]",
version_get_version(ver),
version_get_builddate(ver));
canvas_draw_str(canvas, 5, 28 + STATUS_BAR_Y_SHIFT, buffer);
canvas_draw_str(canvas, 0, 30 + STATUS_BAR_Y_SHIFT, buffer);

snprintf(
buffer,
Expand All @@ -71,11 +73,11 @@ void desktop_debug_render(Canvas* canvas, void* model) {
version_get_githash(ver),
version_get_gitbranchnum(ver),
c2_ver ? c2_ver->StackTypeString : "<none>");
canvas_draw_str(canvas, 5, 39 + STATUS_BAR_Y_SHIFT, buffer);
canvas_draw_str(canvas, 0, 40 + STATUS_BAR_Y_SHIFT, buffer);

snprintf(
buffer, sizeof(buffer), "[%d] %s", version_get_target(ver), version_get_gitbranch(ver));
canvas_draw_str(canvas, 5, 50 + STATUS_BAR_Y_SHIFT, buffer);
canvas_draw_str(canvas, 0, 50 + STATUS_BAR_Y_SHIFT, buffer);

} else {
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
Expand Down
14 changes: 9 additions & 5 deletions applications/desktop/views/desktop_view_slideshow.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ static bool desktop_view_slideshow_input(InputEvent* event, void* context) {
furi_assert(event);
DesktopSlideshowView* instance = context;

DesktopSlideshowViewModel* model = view_get_model(instance->view);
bool update_view = false;
if(event->type == InputTypeShort) {
DesktopSlideshowViewModel* model = view_get_model(instance->view);
bool end_slideshow = false;
switch(event->key) {
case InputKeyLeft:
Expand All @@ -54,15 +55,18 @@ static bool desktop_view_slideshow_input(InputEvent* event, void* context) {
if(end_slideshow) {
instance->callback(DesktopSlideshowCompleted, instance->context);
}
view_commit_model(instance->view, true);
update_view = true;
} else if(event->key == InputKeyOk) {
if(event->type == InputTypePress) {
furi_timer_start(instance->timer, DESKTOP_SLIDESHOW_POWEROFF_SHORT);
} else if(event->type == InputTypeRelease) {
furi_timer_stop(instance->timer);
furi_timer_start(instance->timer, DESKTOP_SLIDESHOW_POWEROFF_LONG);
if(!slideshow_is_one_page(model->slideshow)) {
furi_timer_start(instance->timer, DESKTOP_SLIDESHOW_POWEROFF_LONG);
}
}
}
view_commit_model(instance->view, update_view);

return true;
}
Expand All @@ -79,12 +83,12 @@ static void desktop_view_slideshow_enter(void* context) {
instance->timer =
furi_timer_alloc(desktop_first_start_timer_callback, FuriTimerTypeOnce, instance);

furi_timer_start(instance->timer, DESKTOP_SLIDESHOW_POWEROFF_LONG);

DesktopSlideshowViewModel* model = view_get_model(instance->view);
model->slideshow = slideshow_alloc();
if(!slideshow_load(model->slideshow, SLIDESHOW_FS_PATH)) {
instance->callback(DesktopSlideshowCompleted, instance->context);
} else if(!slideshow_is_one_page(model->slideshow)) {
furi_timer_start(instance->timer, DESKTOP_SLIDESHOW_POWEROFF_LONG);
}
view_commit_model(instance->view, false);
}
Expand Down
5 changes: 5 additions & 0 deletions applications/gui/modules/file_browser_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ static bool browser_folder_check_and_switch(string_t path) {
FileInfo file_info;
Storage* storage = furi_record_open(RECORD_STORAGE);
bool is_root = false;

if(string_search_rchar(path, '/') == 0) {
is_root = true;
}

while(1) {
// Check if folder is existing and navigate back if not
if(storage_common_stat(storage, string_get_cstr(path), &file_info) == FSE_OK) {
Expand Down
13 changes: 13 additions & 0 deletions applications/gui/modules/widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ void widget_add_text_box_element(
widget_add_element(widget, text_box_element);
}

void widget_add_text_scroll_element(
Widget* widget,
uint8_t x,
uint8_t y,
uint8_t width,
uint8_t height,
const char* text) {
furi_assert(widget);
WidgetElement* text_scroll_element =
widget_element_text_scroll_create(x, y, width, height, text);
widget_add_element(widget, text_scroll_element);
}

void widget_add_button_element(
Widget* widget,
GuiButtonType button_type,
Expand Down
21 changes: 21 additions & 0 deletions applications/gui/modules/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ void widget_add_text_box_element(
const char* text,
bool strip_to_dots);

/** Add Text Scroll Element
*
* @param widget Widget instance
* @param x x coordinate
* @param y y coordinate
* @param width width to fit text
* @param height height to fit text
* @param[in] text Formatted text. Default format: align left, Secondary font.
* The following formats are available:
* "\e#Bold text" - sets bold font before until next '\n' symbol
* "\ecCenter-aligned text" - sets center horizontal align until the next '\n' symbol
* "\erRight-aligned text" - sets right horizontal align until the next '\n' symbol
*/
void widget_add_text_scroll_element(
Widget* widget,
uint8_t x,
uint8_t y,
uint8_t width,
uint8_t height,
const char* text);

/** Add Button Element
*
* @param widget Widget instance
Expand Down
8 changes: 8 additions & 0 deletions applications/gui/modules/widget_elements/widget_element_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct WidgetElement {

// generic model holder
void* model;
FuriMutex* model_mutex;

// pointer to widget that hold our element
Widget* parent;
Expand Down Expand Up @@ -80,3 +81,10 @@ WidgetElement* widget_element_frame_create(
uint8_t width,
uint8_t height,
uint8_t radius);

WidgetElement* widget_element_text_scroll_create(
uint8_t x,
uint8_t y,
uint8_t width,
uint8_t height,
const char* text);
Loading

0 comments on commit 9b6fa1a

Please sign in to comment.