Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Feb 26, 2023
2 parents a24d0f1 + 0bc995b commit 802035d
Show file tree
Hide file tree
Showing 57 changed files with 1,190 additions and 610 deletions.
23 changes: 8 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
### New changes
* Desktop: Autolock with PIN Code (by @Willy-JL | PR #338) - **Desktop settings (pin code, favourite app, autolock time) will be resetted!!! Only one time after installing - due to changes in settings structure, after installing of this release desktop settings will not be reset with next release**
* Desktop: Faster back button hold time for power off, was 2 seconds, now 1.3sec
* GUI: Fix keyboard capitalization bug (by @Willy-JL | PR #362) (fixes #361)
* Plugins: Added **SWD Probe** [(by g3gg0)](https://github.com/g3gg0/flipper-swd_probe) (moved from extra pack into main FW)
* Plugins: Show RSSI in Weather Station app and in POCSAG Pager app
* Plugins: Improve Tetris fall speed algorithm (by @p3ngu19z | PR #343)
* Plugins: Add missing buttons into HID app, remove old keyboard app, move Bluetooth remote to Misc
* Infrared: Assets update (by @amec0e | PR #340 / #357 / #358)
* Misc: Typo combing (by @Round-Pi | PR #352)
* OFW: Dolphin: drop holiday animation
* OFW: fbt: FBT_QUIET option; docs on environment
* OFW: Delete rwfiletest.bin on exit SDcard benchmark
* OFW: Re-init NFC when starting the worker
* OFW: Up toolchain version to 21
* OFW: Display Mifare Classic data in NFC app
* SubGHz: **Keeloq: Beninca - protocol support**
* SubGHz: **Hold right in received signal list to delete selected signal**
* SubGHz: **Custom buttons for Keeloq and Alutech AT4N** - now you can use arrow buttons to send signal with different button code
* SubGHz: Debug mode counter increase settings (+5, +10, default: +1)
* Infrared: Debug TX PIN output settings (ability to move tx signal out to GPIO) (implemented #364)
* Plugins: Updated -> [BH1750] Lightmeter [(by oleksiikutuzov)](https://github.com/oleksiikutuzov/flipperzero-lightmeter)
* OFW: BadUSB -> STRINGDELAY(STRING_DELAY) feature, worker signal handling refactoring -> (Fixed #365 (BadUSB won't detect connection and/or hangs))
* OFW: Grammar fixes

#### [🎲 Download latest extra apps pack](https://download-directory.github.io/?url=https://github.com/xMasterX/unleashed-extra-pack/tree/main/apps)

Expand Down
6 changes: 6 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Encoders/sending made by Eng1n33r & @xMasterX:
- Keeloq: FAAC RC,XT
- Keeloq: Mutancode
- Keeloq: Normstahl
- Keeloq: Beninca
- CAME Atomo
- Nice Flor S
- FAAC SLH (Spa) [External seed calculation required (For info contact me in Discord: Nano#8998)]
Expand Down Expand Up @@ -164,6 +165,11 @@ Games:
- Sub-GHz -> Press OK in frequency analyzer to use detected frequency in Read modes [(by derskythe)](https://github.com/DarkFlippers/unleashed-firmware/pull/77)
- Sub-GHz -> Long press OK button in Sub-GHz Frequency analyzer to switch to Read menu [(by derskythe)](https://github.com/DarkFlippers/unleashed-firmware/pull/79)
- Lock device with pin(or regular lock if pin not set) by holding UP button on main screen [(by an4tur0r)](https://github.com/DarkFlippers/unleashed-firmware/pull/107)
* SubGHz -> **Hold right in received signal list to delete selected signal**
* SubGHz -> **Custom buttons for Keeloq and Alutech AT4N** - now you can use arrow buttons to send signal with different button code
* SubGHz -> Debug mode counter increase settings (+5, +10, default: +1)
* SubGHz -> Debug PIN output settings for protocol development
* Infrared -> Debug TX PIN output settings

# Instructions
## [- How to install firmware](https://github.com/DarkFlippers/unleashed-firmware/blob/dev/documentation/HowToInstall.md)
Expand Down
81 changes: 61 additions & 20 deletions applications/main/bad_usb/bad_usb_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct BadUsbScript {
FuriString* file_path;
uint32_t defdelay;
uint16_t layout[128];
uint32_t stringdelay;
FuriThread* thread;
uint8_t file_buf[FILE_BUFFER_LEN + 1];
uint8_t buf_start;
Expand Down Expand Up @@ -113,6 +114,8 @@ static const char ducky_cmd_delay[] = {"DELAY "};
static const char ducky_cmd_string[] = {"STRING "};
static const char ducky_cmd_defdelay_1[] = {"DEFAULT_DELAY "};
static const char ducky_cmd_defdelay_2[] = {"DEFAULTDELAY "};
static const char ducky_cmd_stringdelay_1[] = {"STRINGDELAY "};
static const char ducky_cmd_stringdelay_2[] = {"STRING_DELAY "};
static const char ducky_cmd_repeat[] = {"REPEAT "};
static const char ducky_cmd_sysrq[] = {"SYSRQ "};

Expand Down Expand Up @@ -211,14 +214,19 @@ static bool ducky_altstring(const char* param) {

static bool ducky_string(BadUsbScript* bad_usb, const char* param) {
uint32_t i = 0;

while(param[i] != '\0') {
uint16_t keycode = BADUSB_ASCII_TO_KEY(bad_usb, param[i]);
if(keycode != HID_KEYBOARD_NONE) {
furi_hal_hid_kb_press(keycode);
furi_hal_hid_kb_release(keycode);
if(bad_usb->stringdelay > 0) {
furi_delay_ms(bad_usb->stringdelay);
}
}
i++;
}
bad_usb->stringdelay = 0;
return true;
}

Expand Down Expand Up @@ -277,6 +285,20 @@ static int32_t
snprintf(error, error_len, "Invalid number %s", line_tmp);
}
return (state) ? (0) : SCRIPT_STATE_ERROR;
} else if(
(strncmp(line_tmp, ducky_cmd_stringdelay_1, strlen(ducky_cmd_stringdelay_1)) == 0) ||
(strncmp(line_tmp, ducky_cmd_stringdelay_2, strlen(ducky_cmd_stringdelay_2)) == 0)) {
//STRINGDELAY, finally it's here
line_tmp = &line_tmp[ducky_get_command_len(line_tmp) + 1];
state = ducky_get_number(line_tmp, &bad_usb->stringdelay);
if((state) && (bad_usb->stringdelay > 0)) {
return state;
}
if(error != NULL) {
snprintf(error, error_len, "Invalid number %s", line_tmp);
}
return SCRIPT_STATE_ERROR;

} else if(strncmp(line_tmp, ducky_cmd_string, strlen(ducky_cmd_string)) == 0) {
// STRING
line_tmp = &line_tmp[ducky_get_command_len(line_tmp) + 1];
Expand Down Expand Up @@ -484,6 +506,19 @@ static void bad_usb_hid_state_callback(bool state, void* context) {
furi_thread_flags_set(furi_thread_get_id(bad_usb->thread), WorkerEvtDisconnect);
}

static uint32_t bad_usb_flags_get(uint32_t flags_mask, uint32_t timeout) {
uint32_t flags = furi_thread_flags_get();
furi_check((flags & FuriFlagError) == 0);
if(flags == 0) {
flags = furi_thread_flags_wait(flags_mask, FuriFlagWaitAny, timeout);
furi_check(((flags & FuriFlagError) == 0) || (flags == (unsigned)FuriFlagErrorTimeout));
} else {
uint32_t state = furi_thread_flags_clear(flags);
furi_check((state & FuriFlagError) == 0);
}
return flags;
}

static int32_t bad_usb_worker(void* context) {
BadUsbScript* bad_usb = context;

Expand Down Expand Up @@ -520,11 +555,9 @@ static int32_t bad_usb_worker(void* context) {
bad_usb->st.state = worker_state;

} else if(worker_state == BadUsbStateNotConnected) { // State: USB not connected
uint32_t flags = furi_thread_flags_wait(
WorkerEvtEnd | WorkerEvtConnect | WorkerEvtToggle,
FuriFlagWaitAny,
FuriWaitForever);
furi_check((flags & FuriFlagError) == 0);
uint32_t flags = bad_usb_flags_get(
WorkerEvtEnd | WorkerEvtConnect | WorkerEvtToggle, FuriWaitForever);

if(flags & WorkerEvtEnd) {
break;
} else if(flags & WorkerEvtConnect) {
Expand All @@ -535,11 +568,9 @@ static int32_t bad_usb_worker(void* context) {
bad_usb->st.state = worker_state;

} else if(worker_state == BadUsbStateIdle) { // State: ready to start
uint32_t flags = furi_thread_flags_wait(
WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect,
FuriFlagWaitAny,
FuriWaitForever);
furi_check((flags & FuriFlagError) == 0);
uint32_t flags = bad_usb_flags_get(
WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect, FuriWaitForever);

if(flags & WorkerEvtEnd) {
break;
} else if(flags & WorkerEvtToggle) { // Start executing script
Expand All @@ -548,6 +579,7 @@ static int32_t bad_usb_worker(void* context) {
bad_usb->buf_len = 0;
bad_usb->st.line_cur = 0;
bad_usb->defdelay = 0;
bad_usb->stringdelay = 0;
bad_usb->repeat_cnt = 0;
bad_usb->file_end = false;
storage_file_seek(script_file, 0, true);
Expand All @@ -558,11 +590,9 @@ static int32_t bad_usb_worker(void* context) {
bad_usb->st.state = worker_state;

} else if(worker_state == BadUsbStateWillRun) { // State: start on connection
uint32_t flags = furi_thread_flags_wait(
WorkerEvtEnd | WorkerEvtConnect | WorkerEvtToggle,
FuriFlagWaitAny,
FuriWaitForever);
furi_check((flags & FuriFlagError) == 0);
uint32_t flags = bad_usb_flags_get(
WorkerEvtEnd | WorkerEvtConnect | WorkerEvtToggle, FuriWaitForever);

if(flags & WorkerEvtEnd) {
break;
} else if(flags & WorkerEvtConnect) { // Start executing script
Expand All @@ -571,12 +601,22 @@ static int32_t bad_usb_worker(void* context) {
bad_usb->buf_len = 0;
bad_usb->st.line_cur = 0;
bad_usb->defdelay = 0;
bad_usb->stringdelay = 0;
bad_usb->repeat_cnt = 0;
bad_usb->file_end = false;
storage_file_seek(script_file, 0, true);
// extra time for PC to recognize Flipper as keyboard
furi_thread_flags_wait(0, FuriFlagWaitAny, 1500);
worker_state = BadUsbStateRunning;
flags = furi_thread_flags_wait(
WorkerEvtEnd | WorkerEvtDisconnect | WorkerEvtToggle,
FuriFlagWaitAny | FuriFlagNoClear,
1500);
if(flags == (unsigned)FuriFlagErrorTimeout) {
// If nothing happened - start script execution
worker_state = BadUsbStateRunning;
} else if(flags & WorkerEvtToggle) {
worker_state = BadUsbStateIdle;
furi_thread_flags_clear(WorkerEvtToggle);
}
} else if(flags & WorkerEvtToggle) { // Cancel scheduled execution
worker_state = BadUsbStateNotConnected;
}
Expand All @@ -586,6 +626,7 @@ static int32_t bad_usb_worker(void* context) {
uint16_t delay_cur = (delay_val > 1000) ? (1000) : (delay_val);
uint32_t flags = furi_thread_flags_wait(
WorkerEvtEnd | WorkerEvtToggle | WorkerEvtDisconnect, FuriFlagWaitAny, delay_cur);

delay_val -= delay_cur;
if(!(flags & FuriFlagError)) {
if(flags & WorkerEvtEnd) {
Expand Down Expand Up @@ -629,9 +670,9 @@ static int32_t bad_usb_worker(void* context) {
} else if(
(worker_state == BadUsbStateFileError) ||
(worker_state == BadUsbStateScriptError)) { // State: error
uint32_t flags = furi_thread_flags_wait(
WorkerEvtEnd, FuriFlagWaitAny, FuriWaitForever); // Waiting for exit command
furi_check((flags & FuriFlagError) == 0);
uint32_t flags =
bad_usb_flags_get(WorkerEvtEnd, FuriWaitForever); // Waiting for exit command

if(flags & WorkerEvtEnd) {
break;
}
Expand Down
2 changes: 0 additions & 2 deletions applications/main/bad_usb/scenes/bad_usb_scene_file_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ static bool bad_usb_file_select(BadUsbApp* bad_usb) {
void bad_usb_scene_file_select_on_enter(void* context) {
BadUsbApp* bad_usb = context;

furi_hal_usb_disable();
if(bad_usb->bad_usb_script) {
bad_usb_script_close(bad_usb->bad_usb_script);
bad_usb->bad_usb_script = NULL;
Expand All @@ -34,7 +33,6 @@ void bad_usb_scene_file_select_on_enter(void* context) {

scene_manager_next_scene(bad_usb->scene_manager, BadUsbSceneWork);
} else {
furi_hal_usb_enable();
view_dispatcher_stop(bad_usb->view_dispatcher);
}
}
Expand Down
9 changes: 9 additions & 0 deletions applications/main/infrared/infrared.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ static Infrared* infrared_alloc() {
view_dispatcher_add_view(
view_dispatcher, InfraredViewTextInput, text_input_get_view(infrared->text_input));

infrared->variable_item_list = variable_item_list_alloc();
view_dispatcher_add_view(
infrared->view_dispatcher,
InfraredViewVariableItemList,
variable_item_list_get_view(infrared->variable_item_list));

infrared->dialog_ex = dialog_ex_alloc();
view_dispatcher_add_view(
view_dispatcher, InfraredViewDialogEx, dialog_ex_get_view(infrared->dialog_ex));
Expand Down Expand Up @@ -195,6 +201,9 @@ static void infrared_free(Infrared* infrared) {
view_dispatcher_remove_view(view_dispatcher, InfraredViewTextInput);
text_input_free(infrared->text_input);

view_dispatcher_remove_view(infrared->view_dispatcher, InfraredViewVariableItemList);
variable_item_list_free(infrared->variable_item_list);

view_dispatcher_remove_view(view_dispatcher, InfraredViewDialogEx);
dialog_ex_free(infrared->dialog_ex);

Expand Down
3 changes: 3 additions & 0 deletions applications/main/infrared/infrared_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <gui/modules/popup.h>
#include <gui/modules/loading.h>
#include <gui/modules/submenu.h>
#include <gui/modules/variable_item_list.h>
#include <gui/modules/dialog_ex.h>
#include <gui/modules/text_input.h>
#include <gui/modules/button_menu.h>
Expand Down Expand Up @@ -86,6 +87,7 @@ struct Infrared {

Submenu* submenu;
TextInput* text_input;
VariableItemList* variable_item_list;
DialogEx* dialog_ex;
ButtonMenu* button_menu;
Popup* popup;
Expand All @@ -107,6 +109,7 @@ struct Infrared {
typedef enum {
InfraredViewSubmenu,
InfraredViewTextInput,
InfraredViewVariableItemList,
InfraredViewDialogEx,
InfraredViewButtonMenu,
InfraredViewPopup,
Expand Down
1 change: 1 addition & 0 deletions applications/main/infrared/scenes/infrared_scene_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ ADD_SCENE(infrared, universal_audio, UniversalAudio)
ADD_SCENE(infrared, universal_projector, UniversalProjector)
ADD_SCENE(infrared, debug, Debug)
ADD_SCENE(infrared, error_databases, ErrorDatabases)
ADD_SCENE(infrared, debug_settings, DebugSettings)
ADD_SCENE(infrared, rpc, Rpc)
59 changes: 59 additions & 0 deletions applications/main/infrared/scenes/infrared_scene_debug_settings.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "../infrared_i.h"
#include <furi_hal_infrared.h>

uint8_t value_index_ir;

#define DEB_PINS_COUNT (sizeof(infrared_debug_cfg_variables_text) / sizeof(char* const))
const char* const infrared_debug_cfg_variables_text[] = {
"Internal",
"2 (A7)",
};

static void infrared_scene_debug_settings_changed(VariableItem* item) {
Infrared* infrared = variable_item_get_context(item);
value_index_ir = variable_item_get_current_value_index(item);
UNUSED(infrared);

variable_item_set_current_value_text(item, infrared_debug_cfg_variables_text[value_index_ir]);

furi_hal_infrared_set_debug_out(value_index_ir);
}
static void infrared_debug_settings_start_var_list_enter_callback(void* context, uint32_t index) {
Infrared* infrared = context;
view_dispatcher_send_custom_event(infrared->view_dispatcher, index);
}

void infrared_scene_debug_settings_on_enter(void* context) {
Infrared* infrared = context;

VariableItemList* variable_item_list = infrared->variable_item_list;

value_index_ir = furi_hal_infrared_get_debug_out_status();
VariableItem* item = variable_item_list_add(
variable_item_list,
"Send signal to",
DEB_PINS_COUNT,
infrared_scene_debug_settings_changed,
infrared);

variable_item_list_set_enter_callback(
variable_item_list, infrared_debug_settings_start_var_list_enter_callback, infrared);

variable_item_set_current_value_index(item, value_index_ir);
variable_item_set_current_value_text(item, infrared_debug_cfg_variables_text[value_index_ir]);

view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewVariableItemList);
}

bool infrared_scene_debug_settings_on_event(void* context, SceneManagerEvent event) {
Infrared* infrared = context;
UNUSED(infrared);
UNUSED(event);

return false;
}

void infrared_scene_debug_settings_on_exit(void* context) {
Infrared* infrared = context;
variable_item_list_reset(infrared->variable_item_list);
}
18 changes: 16 additions & 2 deletions applications/main/infrared/scenes/infrared_scene_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ enum SubmenuIndex {
SubmenuIndexLearnNewRemote,
SubmenuIndexLearnNewRemoteRaw,
SubmenuIndexSavedRemotes,
SubmenuIndexDebug
SubmenuIndexDebug,
SubmenuIndexDebugSettings
};

static void infrared_scene_start_submenu_callback(void* context, uint32_t index) {
Expand Down Expand Up @@ -45,7 +46,17 @@ void infrared_scene_start_on_enter(void* context) {
infrared_scene_start_submenu_callback,
infrared);
submenu_add_item(
submenu, "Debug", SubmenuIndexDebug, infrared_scene_start_submenu_callback, infrared);
submenu,
"Debug RX",
SubmenuIndexDebug,
infrared_scene_start_submenu_callback,
infrared);
submenu_add_item(
submenu,
"Debug Settings",
SubmenuIndexDebugSettings,
infrared_scene_start_submenu_callback,
infrared);
}

const uint32_t submenu_index =
Expand Down Expand Up @@ -86,6 +97,9 @@ bool infrared_scene_start_on_event(void* context, SceneManagerEvent event) {
} else if(submenu_index == SubmenuIndexDebug) {
scene_manager_next_scene(scene_manager, InfraredSceneDebug);
consumed = true;
} else if(submenu_index == SubmenuIndexDebugSettings) {
scene_manager_next_scene(scene_manager, InfraredSceneDebugSettings);
consumed = true;
}
}

Expand Down
Loading

0 comments on commit 802035d

Please sign in to comment.