mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 22:32:29 +03:00
post merge fixes p2 [ci skip]
This commit is contained in:
parent
7c0939ad52
commit
fda8370255
@ -16,7 +16,7 @@
|
|||||||
#include "views/bad_usb_view.h"
|
#include "views/bad_usb_view.h"
|
||||||
#include <furi_hal_usb.h>
|
#include <furi_hal_usb.h>
|
||||||
|
|
||||||
#define BAD_USB_APP_BASE_FOLDER ANY_PATH("badusb")
|
#define BAD_USB_APP_BASE_FOLDER EXT_PATH("badusb")
|
||||||
#define BAD_USB_APP_PATH_LAYOUT_FOLDER BAD_USB_APP_BASE_FOLDER "/assets/layouts"
|
#define BAD_USB_APP_PATH_LAYOUT_FOLDER BAD_USB_APP_BASE_FOLDER "/assets/layouts"
|
||||||
#define BAD_USB_APP_SCRIPT_EXTENSION ".txt"
|
#define BAD_USB_APP_SCRIPT_EXTENSION ".txt"
|
||||||
#define BAD_USB_APP_LAYOUT_EXTENSION ".kl"
|
#define BAD_USB_APP_LAYOUT_EXTENSION ".kl"
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#include "infrared_app_i.h"
|
#include "infrared_app_i.h"
|
||||||
|
|
||||||
|
#include <furi_hal_power.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <toolbox/path.h>
|
#include <toolbox/path.h>
|
||||||
|
#include <toolbox/saved_struct.h>
|
||||||
#include <dolphin/dolphin.h>
|
#include <dolphin/dolphin.h>
|
||||||
|
|
||||||
#define TAG "InfraredApp"
|
#define TAG "InfraredApp"
|
||||||
@ -9,6 +12,14 @@
|
|||||||
#define INFRARED_TX_MIN_INTERVAL_MS (50U)
|
#define INFRARED_TX_MIN_INTERVAL_MS (50U)
|
||||||
#define INFRARED_TASK_STACK_SIZE (2048UL)
|
#define INFRARED_TASK_STACK_SIZE (2048UL)
|
||||||
|
|
||||||
|
#define INFRARED_SETTINGS_PATH EXT_PATH("infrared/.infrared.settings")
|
||||||
|
#define INFRARED_SETTINGS_VERSION (0)
|
||||||
|
#define INFRARED_SETTINGS_MAGIC (0x1F)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t tx_pin;
|
||||||
|
} InfraredSettings;
|
||||||
|
|
||||||
static const NotificationSequence*
|
static const NotificationSequence*
|
||||||
infrared_notification_sequences[InfraredNotificationMessageCount] = {
|
infrared_notification_sequences[InfraredNotificationMessageCount] = {
|
||||||
&sequence_success,
|
&sequence_success,
|
||||||
@ -174,12 +185,6 @@ static InfraredApp* infrared_alloc(void) {
|
|||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
view_dispatcher, InfraredViewDialogEx, dialog_ex_get_view(infrared->dialog_ex));
|
view_dispatcher, InfraredViewDialogEx, dialog_ex_get_view(infrared->dialog_ex));
|
||||||
|
|
||||||
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->button_menu = button_menu_alloc();
|
infrared->button_menu = button_menu_alloc();
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
view_dispatcher, InfraredViewButtonMenu, button_menu_get_view(infrared->button_menu));
|
view_dispatcher, InfraredViewButtonMenu, button_menu_get_view(infrared->button_menu));
|
||||||
@ -187,6 +192,12 @@ static InfraredApp* infrared_alloc(void) {
|
|||||||
infrared->popup = popup_alloc();
|
infrared->popup = popup_alloc();
|
||||||
view_dispatcher_add_view(view_dispatcher, InfraredViewPopup, popup_get_view(infrared->popup));
|
view_dispatcher_add_view(view_dispatcher, InfraredViewPopup, popup_get_view(infrared->popup));
|
||||||
|
|
||||||
|
infrared->var_item_list = variable_item_list_alloc();
|
||||||
|
view_dispatcher_add_view(
|
||||||
|
view_dispatcher,
|
||||||
|
InfraredViewVariableList,
|
||||||
|
variable_item_list_get_view(infrared->var_item_list));
|
||||||
|
|
||||||
infrared->view_stack = view_stack_alloc();
|
infrared->view_stack = view_stack_alloc();
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
view_dispatcher, InfraredViewStack, view_stack_get_view(infrared->view_stack));
|
view_dispatcher, InfraredViewStack, view_stack_get_view(infrared->view_stack));
|
||||||
@ -237,15 +248,15 @@ static void infrared_free(InfraredApp* infrared) {
|
|||||||
view_dispatcher_remove_view(view_dispatcher, InfraredViewDialogEx);
|
view_dispatcher_remove_view(view_dispatcher, InfraredViewDialogEx);
|
||||||
dialog_ex_free(infrared->dialog_ex);
|
dialog_ex_free(infrared->dialog_ex);
|
||||||
|
|
||||||
view_dispatcher_remove_view(infrared->view_dispatcher, InfraredViewVariableItemList);
|
|
||||||
variable_item_list_free(infrared->variable_item_list);
|
|
||||||
|
|
||||||
view_dispatcher_remove_view(view_dispatcher, InfraredViewButtonMenu);
|
view_dispatcher_remove_view(view_dispatcher, InfraredViewButtonMenu);
|
||||||
button_menu_free(infrared->button_menu);
|
button_menu_free(infrared->button_menu);
|
||||||
|
|
||||||
view_dispatcher_remove_view(view_dispatcher, InfraredViewPopup);
|
view_dispatcher_remove_view(view_dispatcher, InfraredViewPopup);
|
||||||
popup_free(infrared->popup);
|
popup_free(infrared->popup);
|
||||||
|
|
||||||
|
view_dispatcher_remove_view(view_dispatcher, InfraredViewVariableList);
|
||||||
|
variable_item_list_free(infrared->var_item_list);
|
||||||
|
|
||||||
view_dispatcher_remove_view(view_dispatcher, InfraredViewStack);
|
view_dispatcher_remove_view(view_dispatcher, InfraredViewStack);
|
||||||
view_stack_free(infrared->view_stack);
|
view_stack_free(infrared->view_stack);
|
||||||
|
|
||||||
@ -440,6 +451,60 @@ void infrared_show_error_message(const InfraredApp* infrared, const char* fmt, .
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void infrared_set_tx_pin(InfraredApp* infrared, FuriHalInfraredTxPin tx_pin) {
|
||||||
|
if(tx_pin < FuriHalInfraredTxPinMax) {
|
||||||
|
furi_hal_infrared_set_tx_output(tx_pin);
|
||||||
|
} else {
|
||||||
|
FuriHalInfraredTxPin tx_pin_detected = furi_hal_infrared_detect_tx_output();
|
||||||
|
furi_hal_infrared_set_tx_output(tx_pin_detected);
|
||||||
|
if(tx_pin_detected != FuriHalInfraredTxPinInternal) {
|
||||||
|
infrared_enable_otg(infrared, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
infrared->app_state.tx_pin = tx_pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void infrared_enable_otg(InfraredApp* infrared, bool enable) {
|
||||||
|
if(enable) {
|
||||||
|
furi_hal_power_enable_otg();
|
||||||
|
} else {
|
||||||
|
furi_hal_power_disable_otg();
|
||||||
|
}
|
||||||
|
infrared->app_state.is_otg_enabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void infrared_load_settings(InfraredApp* infrared) {
|
||||||
|
InfraredSettings settings = {0};
|
||||||
|
|
||||||
|
if(!saved_struct_load(
|
||||||
|
INFRARED_SETTINGS_PATH,
|
||||||
|
&settings,
|
||||||
|
sizeof(InfraredSettings),
|
||||||
|
INFRARED_SETTINGS_MAGIC,
|
||||||
|
INFRARED_SETTINGS_VERSION)) {
|
||||||
|
FURI_LOG_D(TAG, "Failed to load settings, using defaults");
|
||||||
|
infrared_save_settings(infrared);
|
||||||
|
}
|
||||||
|
|
||||||
|
infrared_set_tx_pin(infrared, settings.tx_pin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void infrared_save_settings(InfraredApp* infrared) {
|
||||||
|
InfraredSettings settings = {
|
||||||
|
.tx_pin = infrared->app_state.tx_pin,
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!saved_struct_save(
|
||||||
|
INFRARED_SETTINGS_PATH,
|
||||||
|
&settings,
|
||||||
|
sizeof(InfraredSettings),
|
||||||
|
INFRARED_SETTINGS_MAGIC,
|
||||||
|
INFRARED_SETTINGS_VERSION)) {
|
||||||
|
FURI_LOG_E(TAG, "Failed to save settings");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void infrared_signal_received_callback(void* context, InfraredWorkerSignal* received_signal) {
|
void infrared_signal_received_callback(void* context, InfraredWorkerSignal* received_signal) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
InfraredApp* infrared = context;
|
InfraredApp* infrared = context;
|
||||||
@ -480,6 +545,7 @@ void infrared_popup_closed_callback(void* context) {
|
|||||||
int32_t infrared_app(void* p) {
|
int32_t infrared_app(void* p) {
|
||||||
InfraredApp* infrared = infrared_alloc();
|
InfraredApp* infrared = infrared_alloc();
|
||||||
|
|
||||||
|
infrared_load_settings(infrared);
|
||||||
infrared_make_app_folder(infrared);
|
infrared_make_app_folder(infrared);
|
||||||
|
|
||||||
bool is_remote_loaded = false;
|
bool is_remote_loaded = false;
|
||||||
@ -522,6 +588,9 @@ int32_t infrared_app(void* p) {
|
|||||||
|
|
||||||
view_dispatcher_run(infrared->view_dispatcher);
|
view_dispatcher_run(infrared->view_dispatcher);
|
||||||
|
|
||||||
|
infrared_set_tx_pin(infrared, FuriHalInfraredTxPinInternal);
|
||||||
|
infrared_enable_otg(infrared, false);
|
||||||
infrared_free(infrared);
|
infrared_free(infrared);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <furi_hal_infrared.h>
|
||||||
|
|
||||||
#include <gui/gui.h>
|
#include <gui/gui.h>
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
#include <assets_icons.h>
|
#include <assets_icons.h>
|
||||||
@ -25,7 +27,6 @@
|
|||||||
#include <dialogs/dialogs.h>
|
#include <dialogs/dialogs.h>
|
||||||
|
|
||||||
#include <notification/notification_messages.h>
|
#include <notification/notification_messages.h>
|
||||||
|
|
||||||
#include <infrared/worker/infrared_worker.h>
|
#include <infrared/worker/infrared_worker.h>
|
||||||
|
|
||||||
#include "infrared_app.h"
|
#include "infrared_app.h"
|
||||||
@ -83,11 +84,13 @@ typedef struct {
|
|||||||
bool is_learning_new_remote; /**< Learning new remote or adding to an existing one. */
|
bool is_learning_new_remote; /**< Learning new remote or adding to an existing one. */
|
||||||
bool is_debug_enabled; /**< Whether to enable or disable debugging features. */
|
bool is_debug_enabled; /**< Whether to enable or disable debugging features. */
|
||||||
bool is_transmitting; /**< Whether a signal is currently being transmitted. */
|
bool is_transmitting; /**< Whether a signal is currently being transmitted. */
|
||||||
|
bool is_otg_enabled; /**< Whether OTG power (external 5V) is enabled. */
|
||||||
InfraredEditTarget edit_target : 8; /**< Selected editing target (a remote or a button). */
|
InfraredEditTarget edit_target : 8; /**< Selected editing target (a remote or a button). */
|
||||||
InfraredEditMode edit_mode : 8; /**< Selected editing operation (rename or delete). */
|
InfraredEditMode edit_mode : 8; /**< Selected editing operation (rename or delete). */
|
||||||
int32_t current_button_index; /**< Selected button index (move destination). */
|
int32_t current_button_index; /**< Selected button index (move destination). */
|
||||||
int32_t prev_button_index; /**< Previous button index (move source). */
|
int32_t prev_button_index; /**< Previous button index (move source). */
|
||||||
uint32_t last_transmit_time; /**< Lat time a signal was transmitted. */
|
uint32_t last_transmit_time; /**< Lat time a signal was transmitted. */
|
||||||
|
FuriHalInfraredTxPin tx_pin;
|
||||||
} InfraredAppState;
|
} InfraredAppState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,7 +114,7 @@ struct InfraredApp {
|
|||||||
DialogEx* dialog_ex; /**< Standard view for displaying dialogs. */
|
DialogEx* dialog_ex; /**< Standard view for displaying dialogs. */
|
||||||
ButtonMenu* button_menu; /**< Custom view for interacting with IR remotes. */
|
ButtonMenu* button_menu; /**< Custom view for interacting with IR remotes. */
|
||||||
Popup* popup; /**< Standard view for displaying messages. */
|
Popup* popup; /**< Standard view for displaying messages. */
|
||||||
VariableItemList* variable_item_list;
|
VariableItemList* var_item_list; /**< Standard view for displaying menus of choice items. */
|
||||||
|
|
||||||
ViewStack* view_stack; /**< Standard view for displaying stacked interfaces. */
|
ViewStack* view_stack; /**< Standard view for displaying stacked interfaces. */
|
||||||
InfraredDebugView* debug_view; /**< Custom view for displaying debug information. */
|
InfraredDebugView* debug_view; /**< Custom view for displaying debug information. */
|
||||||
@ -140,10 +143,10 @@ typedef enum {
|
|||||||
InfraredViewDialogEx,
|
InfraredViewDialogEx,
|
||||||
InfraredViewButtonMenu,
|
InfraredViewButtonMenu,
|
||||||
InfraredViewPopup,
|
InfraredViewPopup,
|
||||||
|
InfraredViewVariableList,
|
||||||
InfraredViewStack,
|
InfraredViewStack,
|
||||||
InfraredViewDebugView,
|
InfraredViewDebugView,
|
||||||
InfraredViewMove,
|
InfraredViewMove,
|
||||||
InfraredViewVariableItemList,
|
|
||||||
InfraredViewLoading,
|
InfraredViewLoading,
|
||||||
} InfraredView;
|
} InfraredView;
|
||||||
|
|
||||||
@ -276,6 +279,32 @@ void infrared_play_notification_message(
|
|||||||
void infrared_show_error_message(const InfraredApp* infrared, const char* fmt, ...)
|
void infrared_show_error_message(const InfraredApp* infrared, const char* fmt, ...)
|
||||||
_ATTRIBUTE((__format__(__printf__, 2, 3)));
|
_ATTRIBUTE((__format__(__printf__, 2, 3)));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set which pin will be used to transmit infrared signals.
|
||||||
|
*
|
||||||
|
* Setting tx_pin to InfraredTxPinInternal will enable transmission via
|
||||||
|
* the built-in infrared LEDs.
|
||||||
|
*
|
||||||
|
* @param[in] infrared pointer to the application instance.
|
||||||
|
* @param[in] tx_pin pin to be used for signal transmission.
|
||||||
|
*/
|
||||||
|
void infrared_set_tx_pin(InfraredApp* infrared, FuriHalInfraredTxPin tx_pin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable or disable 5V at the GPIO pin 1.
|
||||||
|
*
|
||||||
|
* @param[in] infrared pointer to the application instance.
|
||||||
|
* @param[in] enable boolean value corresponding to OTG state (true = enable, false = disable)
|
||||||
|
*/
|
||||||
|
void infrared_enable_otg(InfraredApp* infrared, bool enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Save current settings to a file.
|
||||||
|
*
|
||||||
|
* @param[in] infrared pointer to the application instance.
|
||||||
|
*/
|
||||||
|
void infrared_save_settings(InfraredApp* infrared);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Common received signal callback.
|
* @brief Common received signal callback.
|
||||||
*
|
*
|
||||||
|
@ -22,6 +22,9 @@ enum InfraredCustomEventType {
|
|||||||
InfraredCustomEventTypeRpcButtonPressIndex,
|
InfraredCustomEventTypeRpcButtonPressIndex,
|
||||||
InfraredCustomEventTypeRpcButtonRelease,
|
InfraredCustomEventTypeRpcButtonRelease,
|
||||||
InfraredCustomEventTypeRpcSessionClose,
|
InfraredCustomEventTypeRpcSessionClose,
|
||||||
|
|
||||||
|
InfraredCustomEventTypeGpioTxPinChanged,
|
||||||
|
InfraredCustomEventTypeGpioOtgChanged,
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
@ -20,7 +20,7 @@ ADD_SCENE(infrared, universal_ac, UniversalAC)
|
|||||||
ADD_SCENE(infrared, universal_fan, UniversalFan)
|
ADD_SCENE(infrared, universal_fan, UniversalFan)
|
||||||
ADD_SCENE(infrared, universal_audio, UniversalAudio)
|
ADD_SCENE(infrared, universal_audio, UniversalAudio)
|
||||||
ADD_SCENE(infrared, universal_projector, UniversalProjector)
|
ADD_SCENE(infrared, universal_projector, UniversalProjector)
|
||||||
|
ADD_SCENE(infrared, gpio_settings, GpioSettings)
|
||||||
ADD_SCENE(infrared, debug, Debug)
|
ADD_SCENE(infrared, debug, Debug)
|
||||||
ADD_SCENE(infrared, error_databases, ErrorDatabases)
|
ADD_SCENE(infrared, error_databases, ErrorDatabases)
|
||||||
ADD_SCENE(infrared, debug_settings, DebugSettings)
|
|
||||||
ADD_SCENE(infrared, rpc, Rpc)
|
ADD_SCENE(infrared, rpc, Rpc)
|
||||||
|
@ -1,85 +0,0 @@
|
|||||||
#include "../infrared_app_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) {
|
|
||||||
InfraredApp* 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_scene_debug_settings_power_changed(VariableItem* item) {
|
|
||||||
bool value = variable_item_get_current_value_index(item);
|
|
||||||
if(value) {
|
|
||||||
for(int i = 0; i < 5 && !furi_hal_power_is_otg_enabled(); i++) {
|
|
||||||
furi_hal_power_enable_otg();
|
|
||||||
furi_delay_ms(10);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(furi_hal_power_is_otg_enabled()) {
|
|
||||||
furi_hal_power_disable_otg();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void infrared_debug_settings_start_var_list_enter_callback(void* context, uint32_t index) {
|
|
||||||
InfraredApp* infrared = context;
|
|
||||||
view_dispatcher_send_custom_event(infrared->view_dispatcher, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void infrared_scene_debug_settings_on_enter(void* context) {
|
|
||||||
InfraredApp* 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]);
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
|
||||||
variable_item_list,
|
|
||||||
"Ext Module 5v",
|
|
||||||
2,
|
|
||||||
infrared_scene_debug_settings_power_changed,
|
|
||||||
infrared);
|
|
||||||
bool enabled = furi_hal_power_is_otg_enabled();
|
|
||||||
variable_item_set_current_value_index(item, enabled);
|
|
||||||
variable_item_set_current_value_text(item, enabled ? "ON" : "OFF");
|
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewVariableItemList);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool infrared_scene_debug_settings_on_event(void* context, SceneManagerEvent event) {
|
|
||||||
InfraredApp* infrared = context;
|
|
||||||
UNUSED(infrared);
|
|
||||||
UNUSED(event);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void infrared_scene_debug_settings_on_exit(void* context) {
|
|
||||||
InfraredApp* infrared = context;
|
|
||||||
variable_item_list_reset(infrared->variable_item_list);
|
|
||||||
}
|
|
102
applications/main/infrared/scenes/infrared_scene_gpio_settings.c
Normal file
102
applications/main/infrared/scenes/infrared_scene_gpio_settings.c
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
#include "../infrared_app_i.h"
|
||||||
|
|
||||||
|
static const char* infrared_scene_gpio_settings_pin_text[] = {
|
||||||
|
"Flipper",
|
||||||
|
"2 (A7)",
|
||||||
|
"Detect",
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* infrared_scene_gpio_settings_otg_text[] = {
|
||||||
|
"OFF",
|
||||||
|
"ON",
|
||||||
|
};
|
||||||
|
|
||||||
|
static void infrared_scene_gpio_settings_pin_change_callback(VariableItem* item) {
|
||||||
|
InfraredApp* infrared = variable_item_get_context(item);
|
||||||
|
const uint8_t index = variable_item_get_current_value_index(item);
|
||||||
|
|
||||||
|
variable_item_set_current_value_text(item, infrared_scene_gpio_settings_pin_text[index]);
|
||||||
|
view_dispatcher_send_custom_event(
|
||||||
|
infrared->view_dispatcher,
|
||||||
|
infrared_custom_event_pack(InfraredCustomEventTypeGpioTxPinChanged, index));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void infrared_scene_gpio_settings_otg_change_callback(VariableItem* item) {
|
||||||
|
InfraredApp* infrared = variable_item_get_context(item);
|
||||||
|
const uint8_t index = variable_item_get_current_value_index(item);
|
||||||
|
|
||||||
|
variable_item_set_current_value_text(item, infrared_scene_gpio_settings_otg_text[index]);
|
||||||
|
view_dispatcher_send_custom_event(
|
||||||
|
infrared->view_dispatcher,
|
||||||
|
infrared_custom_event_pack(InfraredCustomEventTypeGpioOtgChanged, index));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void infrared_scene_gpio_settings_init(InfraredApp* infrared) {
|
||||||
|
VariableItemList* var_item_list = infrared->var_item_list;
|
||||||
|
VariableItem* item;
|
||||||
|
uint8_t value_index;
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
var_item_list,
|
||||||
|
"Signal Output",
|
||||||
|
COUNT_OF(infrared_scene_gpio_settings_pin_text),
|
||||||
|
infrared_scene_gpio_settings_pin_change_callback,
|
||||||
|
infrared);
|
||||||
|
|
||||||
|
value_index = infrared->app_state.tx_pin;
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, infrared_scene_gpio_settings_pin_text[value_index]);
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
var_item_list,
|
||||||
|
"5V on GPIO",
|
||||||
|
COUNT_OF(infrared_scene_gpio_settings_otg_text),
|
||||||
|
infrared_scene_gpio_settings_otg_change_callback,
|
||||||
|
infrared);
|
||||||
|
|
||||||
|
if(infrared->app_state.tx_pin < FuriHalInfraredTxPinMax) {
|
||||||
|
value_index = infrared->app_state.is_otg_enabled;
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, infrared_scene_gpio_settings_otg_text[value_index]);
|
||||||
|
} else {
|
||||||
|
variable_item_set_values_count(item, 1);
|
||||||
|
variable_item_set_current_value_index(item, 0);
|
||||||
|
variable_item_set_current_value_text(item, "Auto");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void infrared_scene_gpio_settings_on_enter(void* context) {
|
||||||
|
InfraredApp* infrared = context;
|
||||||
|
infrared_scene_gpio_settings_init(infrared);
|
||||||
|
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewVariableList);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool infrared_scene_gpio_settings_on_event(void* context, SceneManagerEvent event) {
|
||||||
|
bool consumed = false;
|
||||||
|
|
||||||
|
InfraredApp* infrared = context;
|
||||||
|
|
||||||
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
|
const uint16_t custom_event_type = infrared_custom_event_get_type(event.event);
|
||||||
|
const uint16_t custom_event_value = infrared_custom_event_get_value(event.event);
|
||||||
|
|
||||||
|
if(custom_event_type == InfraredCustomEventTypeGpioTxPinChanged) {
|
||||||
|
infrared_set_tx_pin(infrared, custom_event_value);
|
||||||
|
variable_item_list_reset(infrared->var_item_list);
|
||||||
|
infrared_scene_gpio_settings_init(infrared);
|
||||||
|
} else if(custom_event_type == InfraredCustomEventTypeGpioOtgChanged) {
|
||||||
|
infrared_enable_otg(infrared, custom_event_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
consumed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return consumed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void infrared_scene_gpio_settings_on_exit(void* context) {
|
||||||
|
InfraredApp* infrared = context;
|
||||||
|
variable_item_list_reset(infrared->var_item_list);
|
||||||
|
infrared_save_settings(infrared);
|
||||||
|
}
|
@ -4,7 +4,7 @@ enum SubmenuIndex {
|
|||||||
SubmenuIndexUniversalRemotes,
|
SubmenuIndexUniversalRemotes,
|
||||||
SubmenuIndexLearnNewRemote,
|
SubmenuIndexLearnNewRemote,
|
||||||
SubmenuIndexSavedRemotes,
|
SubmenuIndexSavedRemotes,
|
||||||
SubmenuIndexDebugSettings,
|
SubmenuIndexGpioSettings,
|
||||||
SubmenuIndexLearnNewRemoteRaw,
|
SubmenuIndexLearnNewRemoteRaw,
|
||||||
SubmenuIndexDebug
|
SubmenuIndexDebug
|
||||||
};
|
};
|
||||||
@ -40,7 +40,7 @@ void infrared_scene_start_on_enter(void* context) {
|
|||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu,
|
submenu,
|
||||||
"GPIO Settings",
|
"GPIO Settings",
|
||||||
SubmenuIndexDebugSettings,
|
SubmenuIndexGpioSettings,
|
||||||
infrared_scene_start_submenu_callback,
|
infrared_scene_start_submenu_callback,
|
||||||
infrared);
|
infrared);
|
||||||
|
|
||||||
@ -78,7 +78,6 @@ bool infrared_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|||||||
scene_manager_set_scene_state(scene_manager, InfraredSceneStart, submenu_index);
|
scene_manager_set_scene_state(scene_manager, InfraredSceneStart, submenu_index);
|
||||||
if(submenu_index == SubmenuIndexUniversalRemotes) {
|
if(submenu_index == SubmenuIndexUniversalRemotes) {
|
||||||
scene_manager_next_scene(scene_manager, InfraredSceneUniversal);
|
scene_manager_next_scene(scene_manager, InfraredSceneUniversal);
|
||||||
consumed = true;
|
|
||||||
} else if(
|
} else if(
|
||||||
submenu_index == SubmenuIndexLearnNewRemote ||
|
submenu_index == SubmenuIndexLearnNewRemote ||
|
||||||
submenu_index == SubmenuIndexLearnNewRemoteRaw) {
|
submenu_index == SubmenuIndexLearnNewRemoteRaw) {
|
||||||
@ -89,18 +88,16 @@ bool infrared_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|||||||
|
|
||||||
infrared->app_state.is_learning_new_remote = true;
|
infrared->app_state.is_learning_new_remote = true;
|
||||||
scene_manager_next_scene(scene_manager, InfraredSceneLearn);
|
scene_manager_next_scene(scene_manager, InfraredSceneLearn);
|
||||||
consumed = true;
|
|
||||||
} else if(submenu_index == SubmenuIndexSavedRemotes) {
|
} else if(submenu_index == SubmenuIndexSavedRemotes) {
|
||||||
furi_string_set(infrared->file_path, INFRARED_APP_FOLDER);
|
furi_string_set(infrared->file_path, INFRARED_APP_FOLDER);
|
||||||
scene_manager_next_scene(scene_manager, InfraredSceneRemoteList);
|
scene_manager_next_scene(scene_manager, InfraredSceneRemoteList);
|
||||||
consumed = true;
|
} else if(submenu_index == SubmenuIndexGpioSettings) {
|
||||||
|
scene_manager_next_scene(scene_manager, InfraredSceneGpioSettings);
|
||||||
} else if(submenu_index == SubmenuIndexDebug) {
|
} else if(submenu_index == SubmenuIndexDebug) {
|
||||||
scene_manager_next_scene(scene_manager, InfraredSceneDebug);
|
scene_manager_next_scene(scene_manager, InfraredSceneDebug);
|
||||||
consumed = true;
|
|
||||||
} else if(submenu_index == SubmenuIndexDebugSettings) {
|
|
||||||
scene_manager_next_scene(scene_manager, InfraredSceneDebugSettings);
|
|
||||||
consumed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
consumed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return consumed;
|
return consumed;
|
||||||
|
@ -789,6 +789,7 @@ Function,+,calloc,void*,"size_t, size_t"
|
|||||||
Function,+,canvas_clear,void,Canvas*
|
Function,+,canvas_clear,void,Canvas*
|
||||||
Function,+,canvas_commit,void,Canvas*
|
Function,+,canvas_commit,void,Canvas*
|
||||||
Function,+,canvas_current_font_height,size_t,const Canvas*
|
Function,+,canvas_current_font_height,size_t,const Canvas*
|
||||||
|
Function,+,canvas_current_font_width,size_t,const Canvas*
|
||||||
Function,+,canvas_draw_bitmap,void,"Canvas*, int32_t, int32_t, size_t, size_t, const uint8_t*"
|
Function,+,canvas_draw_bitmap,void,"Canvas*, int32_t, int32_t, size_t, size_t, const uint8_t*"
|
||||||
Function,+,canvas_draw_box,void,"Canvas*, int32_t, int32_t, size_t, size_t"
|
Function,+,canvas_draw_box,void,"Canvas*, int32_t, int32_t, size_t, size_t"
|
||||||
Function,+,canvas_draw_circle,void,"Canvas*, int32_t, int32_t, size_t"
|
Function,+,canvas_draw_circle,void,"Canvas*, int32_t, int32_t, size_t"
|
||||||
@ -798,6 +799,7 @@ Function,+,canvas_draw_frame,void,"Canvas*, int32_t, int32_t, size_t, size_t"
|
|||||||
Function,+,canvas_draw_glyph,void,"Canvas*, int32_t, int32_t, uint16_t"
|
Function,+,canvas_draw_glyph,void,"Canvas*, int32_t, int32_t, uint16_t"
|
||||||
Function,+,canvas_draw_icon,void,"Canvas*, int32_t, int32_t, const Icon*"
|
Function,+,canvas_draw_icon,void,"Canvas*, int32_t, int32_t, const Icon*"
|
||||||
Function,+,canvas_draw_icon_animation,void,"Canvas*, int32_t, int32_t, IconAnimation*"
|
Function,+,canvas_draw_icon_animation,void,"Canvas*, int32_t, int32_t, IconAnimation*"
|
||||||
|
Function,+,canvas_draw_icon_bitmap,void,"Canvas*, uint8_t, uint8_t, int16_t, int16_t, const Icon*"
|
||||||
Function,+,canvas_draw_icon_ex,void,"Canvas*, int32_t, int32_t, const Icon*, IconRotation"
|
Function,+,canvas_draw_icon_ex,void,"Canvas*, int32_t, int32_t, const Icon*, IconRotation"
|
||||||
Function,+,canvas_draw_line,void,"Canvas*, int32_t, int32_t, int32_t, int32_t"
|
Function,+,canvas_draw_line,void,"Canvas*, int32_t, int32_t, int32_t, int32_t"
|
||||||
Function,+,canvas_draw_rbox,void,"Canvas*, int32_t, int32_t, size_t, size_t, size_t"
|
Function,+,canvas_draw_rbox,void,"Canvas*, int32_t, int32_t, size_t, size_t, size_t"
|
||||||
@ -941,6 +943,7 @@ Function,+,elements_multiline_text_framed,void,"Canvas*, int32_t, int32_t, const
|
|||||||
Function,+,elements_progress_bar,void,"Canvas*, int32_t, int32_t, size_t, float"
|
Function,+,elements_progress_bar,void,"Canvas*, int32_t, int32_t, size_t, float"
|
||||||
Function,+,elements_progress_bar_with_text,void,"Canvas*, int32_t, int32_t, size_t, float, const char*"
|
Function,+,elements_progress_bar_with_text,void,"Canvas*, int32_t, int32_t, size_t, float, const char*"
|
||||||
Function,+,elements_scrollable_text_line,void,"Canvas*, int32_t, int32_t, size_t, FuriString*, size_t, _Bool"
|
Function,+,elements_scrollable_text_line,void,"Canvas*, int32_t, int32_t, size_t, FuriString*, size_t, _Bool"
|
||||||
|
Function,+,elements_scrollable_text_line_str,void,"Canvas*, uint8_t, uint8_t, uint8_t, const char*, size_t, _Bool, _Bool"
|
||||||
Function,+,elements_scrollbar,void,"Canvas*, size_t, size_t"
|
Function,+,elements_scrollbar,void,"Canvas*, size_t, size_t"
|
||||||
Function,+,elements_scrollbar_pos,void,"Canvas*, int32_t, int32_t, size_t, size_t, size_t"
|
Function,+,elements_scrollbar_pos,void,"Canvas*, int32_t, int32_t, size_t, size_t, size_t"
|
||||||
Function,+,elements_slightly_rounded_box,void,"Canvas*, int32_t, int32_t, size_t, size_t"
|
Function,+,elements_slightly_rounded_box,void,"Canvas*, int32_t, int32_t, size_t, size_t"
|
||||||
|
|
@ -80,7 +80,6 @@ static FuriHalInfraredTxPin infrared_tx_output = FuriHalInfraredTxPinInternal;
|
|||||||
static volatile InfraredState furi_hal_infrared_state = InfraredStateIdle;
|
static volatile InfraredState furi_hal_infrared_state = InfraredStateIdle;
|
||||||
static InfraredTimTx infrared_tim_tx;
|
static InfraredTimTx infrared_tim_tx;
|
||||||
static InfraredTimRx infrared_tim_rx;
|
static InfraredTimRx infrared_tim_rx;
|
||||||
static bool infrared_external_output;
|
|
||||||
|
|
||||||
static const GpioPin* infrared_tx_pins[FuriHalInfraredTxPinMax] = {
|
static const GpioPin* infrared_tx_pins[FuriHalInfraredTxPinMax] = {
|
||||||
[FuriHalInfraredTxPinInternal] = &gpio_infrared_tx,
|
[FuriHalInfraredTxPinInternal] = &gpio_infrared_tx,
|
||||||
@ -96,14 +95,6 @@ static uint8_t furi_hal_infrared_get_current_dma_tx_buffer(void);
|
|||||||
static void furi_hal_infrared_tx_dma_polarity_isr();
|
static void furi_hal_infrared_tx_dma_polarity_isr();
|
||||||
static void furi_hal_infrared_tx_dma_isr();
|
static void furi_hal_infrared_tx_dma_isr();
|
||||||
|
|
||||||
void furi_hal_infrared_set_debug_out(bool enable) {
|
|
||||||
infrared_external_output = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool furi_hal_infrared_get_debug_out_status(void) {
|
|
||||||
return infrared_external_output;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void furi_hal_infrared_tim_rx_isr(void* context) {
|
static void furi_hal_infrared_tim_rx_isr(void* context) {
|
||||||
UNUSED(context);
|
UNUSED(context);
|
||||||
|
|
||||||
|
@ -54,12 +54,6 @@ typedef void (*FuriHalInfraredRxCaptureCallback)(void* ctx, bool level, uint32_t
|
|||||||
*/
|
*/
|
||||||
typedef void (*FuriHalInfraredRxTimeoutCallback)(void* ctx);
|
typedef void (*FuriHalInfraredRxTimeoutCallback)(void* ctx);
|
||||||
|
|
||||||
// Debug TX pin set
|
|
||||||
void furi_hal_infrared_set_debug_out(bool enable);
|
|
||||||
|
|
||||||
// Debug TX pin get status
|
|
||||||
bool furi_hal_infrared_get_debug_out_status(void);
|
|
||||||
|
|
||||||
/** Initialize INFRARED RX timer to receive interrupts.
|
/** Initialize INFRARED RX timer to receive interrupts.
|
||||||
*
|
*
|
||||||
* It provides interrupts for every RX-signal edge changing with its duration.
|
* It provides interrupts for every RX-signal edge changing with its duration.
|
||||||
|
Loading…
Reference in New Issue
Block a user