Skip to content

Commit

Permalink
Merge branch 'Flipper-XFW:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Ujhhgtg authored Oct 15, 2023
2 parents 529c363 + 3037e8b commit 77dc320
Show file tree
Hide file tree
Showing 27 changed files with 240 additions and 99 deletions.
21 changes: 21 additions & 0 deletions applications/external/barcode_gen/barcode_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include "barcode_app_icons.h"
#include <assets_icons.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
#include <notification/notification_app.h>

/**
* Opens a file browser dialog and returns the filepath of the selected file
Expand All @@ -11,6 +14,9 @@
* file_path will be the folder path is nothing is selected
* @returns true if a file is selected
*/

NotificationApp* notifications = 0;

static bool select_file(const char* folder, FuriString* file_path) {
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
DialogsFileBrowserOptions browser_options;
Expand Down Expand Up @@ -287,6 +293,12 @@ void free_app(BarcodeApp* app) {
free(app);
}

void set_backlight_brightness(float brightness) {
NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION);
notifications->settings.display_brightness = brightness;
notification_message(notifications, &sequence_display_backlight_on);
}

int32_t barcode_main(void* p) {
UNUSED(p);
BarcodeApp* app = malloc(sizeof(BarcodeApp));
Expand All @@ -307,6 +319,13 @@ int32_t barcode_main(void* p) {

submenu_add_item(app->main_menu, "Edit Barcode", EditBarcodeItem, submenu_callback, app);

NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION);
// Save original brightness
float originalBrightness = notifications->settings.display_brightness;
// force backlight and increase brightness
notification_message_block(notifications, &sequence_display_backlight_enforce_on);
set_backlight_brightness(10); // set to highest

/*****************************
* Creating Text Input View
******************************/
Expand Down Expand Up @@ -344,6 +363,8 @@ int32_t barcode_main(void* p) {
view_dispatcher_run(app->view_dispatcher);

free_app(app);
notification_message_block(notifications, &sequence_display_backlight_enforce_auto);
set_backlight_brightness(originalBrightness);

return 0;
}
2 changes: 1 addition & 1 deletion applications/external/radar_scanner/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ App(
fap_category="GPIO",
fap_author="@MatthewKuKanich",
fap_weburl="https://github.com/MatthewKuKanich/flipper-radar",
fap_version="1.0",
fap_version="2.0",
fap_description="Detects the movement of living things using radar",
)
65 changes: 55 additions & 10 deletions applications/external/radar_scanner/radar_scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ static const uint32_t EVENT_PERIOD_MS = 10;
static const float BEEP_FREQ = 1000.0f;
static const float BEEP_VOL = 0.9f;
static const GpioPin* const radarPin = &gpio_ext_pc3; // Pin 7
static const GpioPin* const altRadarPin = &gpio_ext_pa7; // Pin 2
static const GpioPin* const altGroundPin = &gpio_ext_pa6; // Pin 3

bool presenceDetected = false;
bool muted = false;
bool active = false;
bool continuous = false; // Start with no signal from OUT
bool altPinout; // Sets which GPIO pinout config to use

static void start_feedback(NotificationApp* notifications) {
// Set LED to red for detection
Expand Down Expand Up @@ -50,30 +54,44 @@ static void draw_callback(Canvas* canvas, void* ctx) {
canvas_clear(canvas);
canvas_set_font(canvas, FontPrimary);
elements_multiline_text_aligned(canvas, 64, 2, AlignCenter, AlignTop, "Microwave Radar");

canvas_set_font(canvas, FontSecondary);
if(active) {
elements_multiline_text_aligned(canvas, 64, 12, AlignCenter, AlignTop, "Active");
} else {
elements_multiline_text_aligned(canvas, 64, 12, AlignCenter, AlignTop, "On Standby");
}

// Display presence status
canvas_set_font(canvas, FontPrimary);
if(presenceDetected) {
elements_multiline_text_aligned(
canvas, 64, 25, AlignCenter, AlignTop, "Presence Detected");
canvas, 64, 20, AlignCenter, AlignTop, "Presence Detected");
} else {
elements_multiline_text_aligned(canvas, 64, 25, AlignCenter, AlignTop, "No Presence");
elements_multiline_text_aligned(canvas, 64, 20, AlignCenter, AlignTop, "No Presence");
}

canvas_set_font(canvas, FontSecondary);
if(muted) {
elements_multiline_text_aligned(canvas, 64, 35, AlignCenter, AlignTop, "Muted");
elements_multiline_text_aligned(canvas, 64, 32, AlignCenter, AlignTop, "Muted");
}

canvas_set_font(canvas, FontSecondary);
elements_multiline_text_aligned(
canvas, 64, 45, AlignCenter, AlignTop, "RCWL-0516 :: OUT -> Pin7");
elements_multiline_text_aligned(
canvas, 64, 55, AlignCenter, AlignTop, "VIN -> 5v :: GND -> GND");
canvas_set_font(canvas, FontBatteryPercent);

if(altPinout) {
elements_multiline_text_aligned(
canvas, 64, 42, AlignCenter, AlignTop, "Alt-Pinout Enabled");
elements_multiline_text_aligned(
canvas, 64, 49, AlignCenter, AlignTop, "VIN -> 5v :: GND -> Pin 3");
elements_multiline_text_aligned(
canvas, 64, 56, AlignCenter, AlignTop, "OUT -> Pin 2 (A7)");
} else if(!altPinout) {
elements_multiline_text_aligned(
canvas, 64, 42, AlignCenter, AlignTop, "Alt-Pinout Disabled");
elements_multiline_text_aligned(
canvas, 64, 49, AlignCenter, AlignTop, "VIN -> 5v :: GND -> GND");
elements_multiline_text_aligned(
canvas, 64, 56, AlignCenter, AlignTop, "OUT -> Pin 7 (C3)");
}
}

static void input_callback(InputEvent* input_event, void* ctx) {
Expand All @@ -82,6 +100,14 @@ static void input_callback(InputEvent* input_event, void* ctx) {
furi_message_queue_put(event_queue, input_event, FuriWaitForever);
}

static void get_reading() {
if(altPinout) {
continuous = furi_hal_gpio_read(altRadarPin);
} else {
continuous = furi_hal_gpio_read(radarPin);
}
}

int32_t app_radar_scanner(void* p) {
UNUSED(p);
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
Expand All @@ -102,14 +128,25 @@ int32_t app_radar_scanner(void* p) {

// set input to be low; RCWL-0516 outputs High (3v) on detection
furi_hal_gpio_init(radarPin, GpioModeInput, GpioPullDown, GpioSpeedVeryHigh);
furi_hal_gpio_init(altRadarPin, GpioModeInput, GpioPullDown, GpioSpeedVeryHigh);
furi_hal_gpio_init(altGroundPin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
furi_hal_gpio_write(altGroundPin, false);

// Auto 5v power
uint8_t attempts = 0;
bool otg_was_enabled = furi_hal_power_is_otg_enabled();
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
furi_hal_power_enable_otg();
furi_delay_ms(10);
}

bool alarming = false; // Sensor begins in-active until user starts
bool running = true; // to prevent unwanted false positives

while(running) {
if(active) {
// start and stop feedback if sensor state is active
bool continuous = furi_hal_gpio_read(radarPin);
get_reading();

if(continuous && !alarming) {
presenceDetected = true;
Expand Down Expand Up @@ -138,6 +175,9 @@ int32_t app_radar_scanner(void* p) {
muted = !muted; // Toggle the value of 'muted'
stop_feedback(notifications);
}
if(event.key == InputKeyRight) {
altPinout = !altPinout; // Toggle alternate pinout
}
}
}
}
Expand All @@ -146,6 +186,11 @@ int32_t app_radar_scanner(void* p) {
stop_feedback(notifications);
notification_message_block(notifications, &sequence_display_backlight_enforce_auto);

// Disable 5v power
if(furi_hal_power_is_otg_enabled() && !otg_was_enabled) {
furi_hal_power_disable_otg();
}

view_port_enabled_set(view_port, false);
gui_remove_view_port(gui, view_port);
view_port_free(view_port);
Expand Down
4 changes: 2 additions & 2 deletions applications/main/bad_kb/helpers/ducky_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ static int32_t ducky_script_execute_next(BadKbScript* bad_kb, File* script_file)
return delay_val;
} else if(delay_val < 0) { // Script error
bad_kb->st.error_line = bad_kb->st.line_cur - 1;
FURI_LOG_E(WORKER_TAG, "Unknown command at line %u", bad_kb->st.line_cur - 1U);
FURI_LOG_E(WORKER_TAG, "Unknown command at line %zu", bad_kb->st.line_cur - 1U);
return SCRIPT_STATE_ERROR;
} else {
return (delay_val + bad_kb->defdelay);
Expand Down Expand Up @@ -457,7 +457,7 @@ static int32_t ducky_script_execute_next(BadKbScript* bad_kb, File* script_file)
return delay_val;
} else if(delay_val < 0) {
bad_kb->st.error_line = bad_kb->st.line_cur;
FURI_LOG_E(WORKER_TAG, "Unknown command at line %u", bad_kb->st.line_cur);
FURI_LOG_E(WORKER_TAG, "Unknown command at line %zu", bad_kb->st.line_cur);
return SCRIPT_STATE_ERROR;
} else {
return (delay_val + bad_kb->defdelay);
Expand Down
6 changes: 3 additions & 3 deletions applications/main/bad_kb/helpers/ducky_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ struct BadKbState {
BadKbWorkerState state;
bool is_bt;
uint32_t pin;
uint16_t line_cur;
uint16_t line_nb;
size_t line_cur;
size_t line_nb;
uint32_t delay_remain;
uint16_t error_line;
size_t error_line;
char error[64];
uint32_t elapsed;
};
Expand Down
8 changes: 4 additions & 4 deletions applications/main/bad_kb/views/bad_kb_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static void bad_kb_draw_callback(Canvas* canvas, void* _model) {
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(canvas, 127, 33, AlignRight, AlignBottom, "ERROR:");
canvas_set_font(canvas, FontSecondary);
furi_string_printf(disp_str, "line %u", model->state.error_line);
furi_string_printf(disp_str, "line %zu", model->state.error_line);
canvas_draw_str_aligned(
canvas, 127, 46, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
furi_string_reset(disp_str);
Expand All @@ -121,7 +121,7 @@ static void bad_kb_draw_callback(Canvas* canvas, void* _model) {
}
canvas_set_font(canvas, FontBigNumbers);
furi_string_printf(
disp_str, "%u", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
disp_str, "%zu", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
canvas_draw_str_aligned(
canvas, 114, 40, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
furi_string_reset(disp_str);
Expand All @@ -140,7 +140,7 @@ static void bad_kb_draw_callback(Canvas* canvas, void* _model) {
}
canvas_set_font(canvas, FontBigNumbers);
furi_string_printf(
disp_str, "%u", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
disp_str, "%zu", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
canvas_draw_str_aligned(
canvas, 114, 40, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
furi_string_reset(disp_str);
Expand All @@ -159,7 +159,7 @@ static void bad_kb_draw_callback(Canvas* canvas, void* _model) {
}
canvas_set_font(canvas, FontBigNumbers);
furi_string_printf(
disp_str, "%u", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
disp_str, "%zu", ((model->state.line_cur - 1) * 100) / model->state.line_nb);
canvas_draw_str_aligned(
canvas, 114, 40, AlignRight, AlignBottom, furi_string_get_cstr(disp_str));
furi_string_reset(disp_str);
Expand Down
7 changes: 5 additions & 2 deletions applications/main/subghz/scenes/subghz_scene_set_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
subghz->txrx, "AM650", 315000000, SUBGHZ_PROTOCOL_PRINCETON_NAME, key, 24, 400);
break;
case SubmenuIndexNiceFlo12bit:
key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4
key = (key & 0x00000FF0) | 0x1; //btn 0x1, 0x2, 0x4
generated_protocol = subghz_txrx_gen_data_protocol(
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_NICE_FLO_NAME, key, 12);
break;
Expand All @@ -361,7 +361,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_NICE_FLO_NAME, key, 24);
break;
case SubmenuIndexCAME12bit:
key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4
key = (key & 0x00000FF0) | 0x1; //btn 0x1, 0x2, 0x4
generated_protocol = subghz_txrx_gen_data_protocol(
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_CAME_NAME, key, 12);
break;
Expand Down Expand Up @@ -715,14 +715,17 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 433920000);
break;
case SubmenuIndexSecPlus_v2_310_00:
key = (key & 0x7FFFF3FC); // 850LM pairing
generated_protocol = subghz_txrx_gen_secplus_v2_protocol(
subghz->txrx, "AM650", 310000000, key, 0x68, 0xE500000);
break;
case SubmenuIndexSecPlus_v2_315_00:
key = (key & 0x7FFFF3FC); // 850LM pairing
generated_protocol = subghz_txrx_gen_secplus_v2_protocol(
subghz->txrx, "AM650", 315000000, key, 0x68, 0xE500000);
break;
case SubmenuIndexSecPlus_v2_390_00:
key = (key & 0x7FFFF3FC); // 850LM pairing
generated_protocol = subghz_txrx_gen_secplus_v2_protocol(
subghz->txrx, "AM650", 390000000, key, 0x68, 0xE500000);
break;
Expand Down
2 changes: 1 addition & 1 deletion applications/main/subghz/subghz_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
}
}

printf("\r\nPackets received \033[0;32m%u\033[0m\r\n", instance->packet_count);
printf("\r\nPackets received \033[0;32m%zu\033[0m\r\n", instance->packet_count);

// Cleanup
subghz_receiver_free(receiver);
Expand Down
16 changes: 7 additions & 9 deletions applications/main/subghz/subghz_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,14 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
}
}

//Load latitute and longitude if present
if(!flipper_format_read_float(fff_data_file, "Latitute", (float*)&temp_lat, 1)) {
FURI_LOG_E(TAG, "Missing Latitude (optional)");
//Load latitute and longitude if present, strict mode to avoid reading the whole file twice
flipper_format_set_strict_mode(fff_data_file, true);
if(!flipper_format_read_float(fff_data_file, "Latitute", (float*)&temp_lat, 1) ||
!flipper_format_read_float(fff_data_file, "Longitude", (float*)&temp_lon, 1)) {
FURI_LOG_W(TAG, "Missing Latitude and Longitude (optional)");
flipper_format_rewind(fff_data_file);
}
flipper_format_rewind(fff_data_file);

if(!flipper_format_read_float(fff_data_file, "Longitude", (float*)&temp_lon, 1)) {
FURI_LOG_E(TAG, "Missing Longitude (optional)");
}
flipper_format_rewind(fff_data_file);
flipper_format_set_strict_mode(fff_data_file, false);

size_t preset_index =
subghz_setting_get_inx_preset_by_name(setting, furi_string_get_cstr(temp_str));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const char* const menu_style_names[MenuStyleCount] = {
"C64",
"Eurocorp",
"Compact",
"Terminal",
};
static void xtreme_app_scene_interface_mainmenu_menu_style_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
Expand Down
Loading

0 comments on commit 77dc320

Please sign in to comment.