Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into release-candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
skotopes committed Sep 29, 2022
2 parents 14a1809 + 76d38e8 commit a0f6a23
Show file tree
Hide file tree
Showing 87 changed files with 3,019 additions and 953 deletions.
3 changes: 2 additions & 1 deletion .vscode/example/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@
"servertype": "openocd",
"device": "stlink",
"svdFile": "./debug/STM32WB55_CM4.svd",
// If you're debugging early in the boot process, before OS scheduler is running,
// you have to comment out the following line.
"rtos": "FreeRTOS",
"configFiles": [
"interface/stlink.cfg",
"./debug/stm32wbx.cfg",
],
"postAttachCommands": [
// "attach 1",
// "compare-sections",
"source debug/flipperapps.py",
// "source debug/FreeRTOS/FreeRTOS.py",
Expand Down
8 changes: 4 additions & 4 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Check out details on [how to build firmware](documentation/fbt.md), [write appli

Flipper Zero's firmware consists of two components:

- Core2 firmware set - proprietary components by ST: FUS + radio stack. FUS is flashed at factory and you should never update it.
- Core2 firmware set - proprietary components by ST: FUS + radio stack. FUS is flashed at factory, and you should never update it.
- Core1 Firmware - HAL + OS + Drivers + Applications.

They both must be flashed in the order described.
Expand Down Expand Up @@ -52,7 +52,7 @@ Prerequisites:
- [arm-gcc-none-eabi](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
- openocd

One liner: `./fbt firmware_flash`
One-liner: `./fbt firmware_flash`

## With USB DFU

Expand Down Expand Up @@ -128,7 +128,7 @@ Connect your device via ST-Link and run:
- `debug` - Debug tool: GDB-plugins, SVD-file and etc
- `documentation` - Documentation generation system configs and input files
- `firmware` - Firmware source code
- `lib` - Our and 3rd party libraries, drivers and etc...
- `lib` - Our and 3rd party libraries, drivers, etc.
- `scripts` - Supplementary scripts and python libraries home

Also pay attention to `ReadMe.md` files inside of those directories.
Also pay attention to `ReadMe.md` files inside those directories.
23 changes: 13 additions & 10 deletions applications/main/fap_loader/fap_loader_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ typedef struct {
DialogsApp* dialogs;
Gui* gui;
string_t fap_path;

ViewDispatcher* view_dispatcher;
Loading* loading;
} FapLoader;

static bool
Expand All @@ -25,7 +28,7 @@ static bool
FlipperApplication* app = flipper_application_alloc(loader->storage, &hashtable_api_interface);

FlipperApplicationPreloadStatus preload_res =
flipper_application_preload(app, string_get_cstr(path));
flipper_application_preload_manifest(app, string_get_cstr(path));

bool load_success = false;

Expand Down Expand Up @@ -144,12 +147,12 @@ int32_t fap_loader_app(void* p) {
loader->dialogs = furi_record_open(RECORD_DIALOGS);
loader->gui = furi_record_open(RECORD_GUI);

ViewDispatcher* view_dispatcher = view_dispatcher_alloc();
Loading* loading = loading_alloc();
loader->view_dispatcher = view_dispatcher_alloc();
loader->loading = loading_alloc();

view_dispatcher_enable_queue(view_dispatcher);
view_dispatcher_attach_to_gui(view_dispatcher, loader->gui, ViewDispatcherTypeFullscreen);
view_dispatcher_add_view(view_dispatcher, 0, loading_get_view(loading));
view_dispatcher_attach_to_gui(
loader->view_dispatcher, loader->gui, ViewDispatcherTypeFullscreen);
view_dispatcher_add_view(loader->view_dispatcher, 0, loading_get_view(loader->loading));

if(p) {
string_init_set(loader->fap_path, (const char*)p);
Expand All @@ -158,14 +161,14 @@ int32_t fap_loader_app(void* p) {
string_init_set(loader->fap_path, EXT_PATH("apps"));

while(fap_loader_select_app(loader)) {
view_dispatcher_switch_to_view(view_dispatcher, 0);
view_dispatcher_switch_to_view(loader->view_dispatcher, 0);
fap_loader_run_selected_app(loader);
};
}

view_dispatcher_remove_view(view_dispatcher, 0);
loading_free(loading);
view_dispatcher_free(view_dispatcher);
view_dispatcher_remove_view(loader->view_dispatcher, 0);
loading_free(loader->loading);
view_dispatcher_free(loader->view_dispatcher);

string_clear(loader->fap_path);
furi_record_close(RECORD_GUI);
Expand Down
49 changes: 22 additions & 27 deletions applications/main/infrared/infrared_brute_force.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,36 @@ struct InfraredBruteForce {
FlipperFormat* ff;
const char* db_filename;
string_t current_record_name;
InfraredSignal* current_signal;
InfraredBruteForceRecordDict_t records;
bool is_started;
};

InfraredBruteForce* infrared_brute_force_alloc() {
InfraredBruteForce* brute_force = malloc(sizeof(InfraredBruteForce));
brute_force->ff = NULL;
brute_force->db_filename = NULL;
brute_force->current_signal = NULL;
brute_force->is_started = false;
string_init(brute_force->current_record_name);
InfraredBruteForceRecordDict_init(brute_force->records);
return brute_force;
}

void infrared_brute_force_free(InfraredBruteForce* brute_force) {
furi_assert(!brute_force->ff);
furi_assert(!brute_force->is_started);
InfraredBruteForceRecordDict_clear(brute_force->records);
string_clear(brute_force->current_record_name);
free(brute_force);
}

void infrared_brute_force_set_db_filename(InfraredBruteForce* brute_force, const char* db_filename) {
furi_assert(!brute_force->is_started);
brute_force->db_filename = db_filename;
}

bool infrared_brute_force_calculate_messages(InfraredBruteForce* brute_force) {
furi_assert(!brute_force->is_started);
furi_assert(brute_force->db_filename);
bool success = false;

Expand Down Expand Up @@ -76,6 +82,7 @@ bool infrared_brute_force_start(
InfraredBruteForce* brute_force,
uint32_t index,
uint32_t* record_count) {
furi_assert(!brute_force->is_started);
bool success = false;
*record_count = 0;

Expand All @@ -96,50 +103,37 @@ bool infrared_brute_force_start(
if(*record_count) {
Storage* storage = furi_record_open(RECORD_STORAGE);
brute_force->ff = flipper_format_buffered_file_alloc(storage);
brute_force->current_signal = infrared_signal_alloc();
brute_force->is_started = true;
success =
flipper_format_buffered_file_open_existing(brute_force->ff, brute_force->db_filename);
if(!success) {
flipper_format_free(brute_force->ff);
brute_force->ff = NULL;
furi_record_close(RECORD_STORAGE);
}
if(!success) infrared_brute_force_stop(brute_force);
}
return success;
}

bool infrared_brute_force_is_started(InfraredBruteForce* brute_force) {
return brute_force->ff;
return brute_force->is_started;
}

void infrared_brute_force_stop(InfraredBruteForce* brute_force) {
furi_assert(string_size(brute_force->current_record_name));
furi_assert(brute_force->ff);

furi_assert(brute_force->is_started);
string_reset(brute_force->current_record_name);
infrared_signal_free(brute_force->current_signal);
flipper_format_free(brute_force->ff);
furi_record_close(RECORD_STORAGE);
brute_force->current_signal = NULL;
brute_force->ff = NULL;
brute_force->is_started = false;
furi_record_close(RECORD_STORAGE);
}

bool infrared_brute_force_send_next(InfraredBruteForce* brute_force) {
furi_assert(string_size(brute_force->current_record_name));
furi_assert(brute_force->ff);
bool success = false;

string_t signal_name;
string_init(signal_name);
InfraredSignal* signal = infrared_signal_alloc();

do {
success = infrared_signal_read(signal, brute_force->ff, signal_name);
} while(success && !string_equal_p(brute_force->current_record_name, signal_name));

furi_assert(brute_force->is_started);
const bool success = infrared_signal_search_and_read(
brute_force->current_signal, brute_force->ff, brute_force->current_record_name);
if(success) {
infrared_signal_transmit(signal);
infrared_signal_transmit(brute_force->current_signal);
}

infrared_signal_free(signal);
string_clear(signal_name);
return success;
}

Expand All @@ -155,5 +149,6 @@ void infrared_brute_force_add_record(
}

void infrared_brute_force_reset(InfraredBruteForce* brute_force) {
furi_assert(!brute_force->is_started);
InfraredBruteForceRecordDict_reset(brute_force->records);
}
63 changes: 50 additions & 13 deletions applications/main/infrared/infrared_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,26 @@ static inline bool infrared_signal_read_raw(InfraredSignal* signal, FlipperForma
return success;
}

static bool infrared_signal_read_body(InfraredSignal* signal, FlipperFormat* ff) {
string_t tmp;
string_init(tmp);
bool success = false;

do {
if(!flipper_format_read_string(ff, "type", tmp)) break;
if(string_equal_p(tmp, "raw")) {
success = infrared_signal_read_raw(signal, ff);
} else if(string_equal_p(tmp, "parsed")) {
success = infrared_signal_read_message(signal, ff);
} else {
FURI_LOG_E(TAG, "Unknown signal type");
}
} while(false);

string_clear(tmp);
return success;
}

InfraredSignal* infrared_signal_alloc() {
InfraredSignal* signal = malloc(sizeof(InfraredSignal));

Expand Down Expand Up @@ -227,24 +247,41 @@ bool infrared_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char*
}

bool infrared_signal_read(InfraredSignal* signal, FlipperFormat* ff, string_t name) {
string_t buf;
string_init(buf);
string_t tmp;
string_init(tmp);
bool success = false;

do {
if(!flipper_format_read_string(ff, "name", buf)) break;
string_set(name, buf);
if(!flipper_format_read_string(ff, "type", buf)) break;
if(!string_cmp_str(buf, "raw")) {
success = infrared_signal_read_raw(signal, ff);
} else if(!string_cmp_str(buf, "parsed")) {
success = infrared_signal_read_message(signal, ff);
} else {
FURI_LOG_E(TAG, "Unknown type of signal (allowed - raw/parsed) ");
}
if(!flipper_format_read_string(ff, "name", tmp)) break;
string_set(name, tmp);
if(!infrared_signal_read_body(signal, ff)) break;
success = true;
} while(0);

string_clear(buf);
string_clear(tmp);
return success;
}

bool infrared_signal_search_and_read(
InfraredSignal* signal,
FlipperFormat* ff,
const string_t name) {
bool success = false;
string_t tmp;
string_init(tmp);

do {
bool is_name_found = false;
while(flipper_format_read_string(ff, "name", tmp)) {
is_name_found = string_equal_p(name, tmp);
if(is_name_found) break;
}
if(!is_name_found) break;
if(!infrared_signal_read_body(signal, ff)) break;
success = true;
} while(false);

string_clear(tmp);
return success;
}

Expand Down
4 changes: 4 additions & 0 deletions applications/main/infrared/infrared_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ InfraredMessage* infrared_signal_get_message(InfraredSignal* signal);

bool infrared_signal_save(InfraredSignal* signal, FlipperFormat* ff, const char* name);
bool infrared_signal_read(InfraredSignal* signal, FlipperFormat* ff, string_t name);
bool infrared_signal_search_and_read(
InfraredSignal* signal,
FlipperFormat* ff,
const string_t name);

void infrared_signal_transmit(InfraredSignal* signal);
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ bool subghz_scene_receiver_config_on_event(void* context, SceneManagerEvent even

void subghz_scene_receiver_config_on_exit(void* context) {
SubGhz* subghz = context;
variable_item_list_set_selected_item(subghz->variable_item_list, 0);
variable_item_list_reset(subghz->variable_item_list);
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
Expand Down
7 changes: 5 additions & 2 deletions applications/main/subghz/views/transmitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void subghz_view_transmitter_add_data_to_show(
}

static void subghz_view_transmitter_button_right(Canvas* canvas, const char* str) {
const uint8_t button_height = 13;
const uint8_t button_height = 12;
const uint8_t vertical_offset = 3;
const uint8_t horizontal_offset = 1;
const uint8_t string_width = canvas_string_width(canvas, str);
Expand All @@ -69,7 +69,10 @@ static void subghz_view_transmitter_button_right(Canvas* canvas, const char* str

canvas_invert_color(canvas);
canvas_draw_icon(
canvas, x + horizontal_offset, y - button_height + vertical_offset, &I_ButtonCenter_7x7);
canvas,
x + horizontal_offset,
y - button_height + vertical_offset - 1,
&I_ButtonCenter_7x7);
canvas_draw_str(
canvas, x + horizontal_offset + icon_width_with_offset, y - vertical_offset, str);
canvas_invert_color(canvas);
Expand Down
12 changes: 12 additions & 0 deletions applications/plugins/signal_generator/application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
App(
appid="signal_generator",
name="Signal Generator",
apptype=FlipperAppType.PLUGIN,
entry_point="signal_gen_app",
cdefines=["APP_SIGNAL_GEN"],
requires=["gui"],
stack_size=1 * 1024,
order=50,
fap_icon="signal_gen_10px.png",
fap_category="Tools",
)
30 changes: 30 additions & 0 deletions applications/plugins/signal_generator/scenes/signal_gen_scene.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "../signal_gen_app_i.h"

// Generate scene on_enter handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
void (*const signal_gen_scene_on_enter_handlers[])(void*) = {
#include "signal_gen_scene_config.h"
};
#undef ADD_SCENE

// Generate scene on_event handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
bool (*const signal_gen_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
#include "signal_gen_scene_config.h"
};
#undef ADD_SCENE

// Generate scene on_exit handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
void (*const signal_gen_scene_on_exit_handlers[])(void* context) = {
#include "signal_gen_scene_config.h"
};
#undef ADD_SCENE

// Initialize scene handlers configuration structure
const SceneManagerHandlers signal_gen_scene_handlers = {
.on_enter_handlers = signal_gen_scene_on_enter_handlers,
.on_event_handlers = signal_gen_scene_on_event_handlers,
.on_exit_handlers = signal_gen_scene_on_exit_handlers,
.scene_num = SignalGenSceneNum,
};
Loading

0 comments on commit a0f6a23

Please sign in to comment.