mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-02 17:29:14 +00:00
224d0aefe4
* First part of multitarget porting * Delete firmware/targets/f7/Inc directory * Delete firmware/targets/f7/Src directory * gpio: cli fixes; about: using version from HAL * sdk: path fixes * gui: include fixes * applications: more include fixes * gpio: ported to new apis * hal: introduced furi_hal_target_hw.h; libs: added one_wire * hal: f18 target * github: also build f18 by default * typo fix * fbt: removed extra checks on app list * api: explicitly bundling select mlib headers with sdk * hal: f18: changed INPUT_DEBOUNCE_TICKS to match f7 * cleaned up commented out code * docs: added info on hw targets * docs: targets: formatting fixes * f18: fixed link error * f18: fixed API version to match f7 * docs: hardware: minor wording fixes * faploader: added fw target check * docs: typo fixes * github: not building komi target by default * fbt: support for `targets` field for built-in apps * github: reworked build flow to exclude app_set; fbt: removed komi-specific appset; added additional target buildset check * github: fixed build; nfc: fixed pvs warnings * attempt to fix target id * f7, f18: removed certain HAL function from public API * apps: debug: enabled bt_debug_app for f18 * Targets: backport input pins configuration routine from F7 to F18 Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
106 lines
3.6 KiB
C
106 lines
3.6 KiB
C
#include "../gpio_app_i.h"
|
|
#include <furi_hal_power.h>
|
|
#include <furi_hal_usb.h>
|
|
#include <dolphin/dolphin.h>
|
|
|
|
enum GpioItem {
|
|
GpioItemUsbUart,
|
|
GpioItemTest,
|
|
GpioItemOtg,
|
|
};
|
|
|
|
enum GpioOtg {
|
|
GpioOtgOff,
|
|
GpioOtgOn,
|
|
GpioOtgSettingsNum,
|
|
};
|
|
|
|
const char* const gpio_otg_text[GpioOtgSettingsNum] = {
|
|
"OFF",
|
|
"ON",
|
|
};
|
|
|
|
static void gpio_scene_start_var_list_enter_callback(void* context, uint32_t index) {
|
|
furi_assert(context);
|
|
GpioApp* app = context;
|
|
if(index == GpioItemTest) {
|
|
view_dispatcher_send_custom_event(app->view_dispatcher, GpioStartEventManualControl);
|
|
} else if(index == GpioItemUsbUart) {
|
|
view_dispatcher_send_custom_event(app->view_dispatcher, GpioStartEventUsbUart);
|
|
}
|
|
}
|
|
|
|
static void gpio_scene_start_var_list_change_callback(VariableItem* item) {
|
|
GpioApp* app = variable_item_get_context(item);
|
|
uint8_t index = variable_item_get_current_value_index(item);
|
|
|
|
variable_item_set_current_value_text(item, gpio_otg_text[index]);
|
|
if(index == GpioOtgOff) {
|
|
view_dispatcher_send_custom_event(app->view_dispatcher, GpioStartEventOtgOff);
|
|
} else if(index == GpioOtgOn) {
|
|
view_dispatcher_send_custom_event(app->view_dispatcher, GpioStartEventOtgOn);
|
|
}
|
|
}
|
|
|
|
void gpio_scene_start_on_enter(void* context) {
|
|
GpioApp* app = context;
|
|
VariableItemList* var_item_list = app->var_item_list;
|
|
|
|
VariableItem* item;
|
|
variable_item_list_set_enter_callback(
|
|
var_item_list, gpio_scene_start_var_list_enter_callback, app);
|
|
|
|
variable_item_list_add(var_item_list, "USB-UART Bridge", 0, NULL, NULL);
|
|
|
|
variable_item_list_add(var_item_list, "GPIO Manual Control", 0, NULL, NULL);
|
|
|
|
item = variable_item_list_add(
|
|
var_item_list,
|
|
"5V on GPIO",
|
|
GpioOtgSettingsNum,
|
|
gpio_scene_start_var_list_change_callback,
|
|
app);
|
|
if(furi_hal_power_is_otg_enabled()) {
|
|
variable_item_set_current_value_index(item, GpioOtgOn);
|
|
variable_item_set_current_value_text(item, gpio_otg_text[GpioOtgOn]);
|
|
} else {
|
|
variable_item_set_current_value_index(item, GpioOtgOff);
|
|
variable_item_set_current_value_text(item, gpio_otg_text[GpioOtgOff]);
|
|
}
|
|
|
|
variable_item_list_set_selected_item(
|
|
var_item_list, scene_manager_get_scene_state(app->scene_manager, GpioSceneStart));
|
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewVarItemList);
|
|
}
|
|
|
|
bool gpio_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|
GpioApp* app = context;
|
|
bool consumed = false;
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
if(event.event == GpioStartEventOtgOn) {
|
|
furi_hal_power_enable_otg();
|
|
} else if(event.event == GpioStartEventOtgOff) {
|
|
furi_hal_power_disable_otg();
|
|
} else if(event.event == GpioStartEventManualControl) {
|
|
scene_manager_set_scene_state(app->scene_manager, GpioSceneStart, GpioItemTest);
|
|
scene_manager_next_scene(app->scene_manager, GpioSceneTest);
|
|
} else if(event.event == GpioStartEventUsbUart) {
|
|
scene_manager_set_scene_state(app->scene_manager, GpioSceneStart, GpioItemUsbUart);
|
|
if(!furi_hal_usb_is_locked()) {
|
|
DOLPHIN_DEED(DolphinDeedGpioUartBridge);
|
|
scene_manager_next_scene(app->scene_manager, GpioSceneUsbUart);
|
|
} else {
|
|
scene_manager_next_scene(app->scene_manager, GpioSceneUsbUartCloseRpc);
|
|
}
|
|
}
|
|
consumed = true;
|
|
}
|
|
return consumed;
|
|
}
|
|
|
|
void gpio_scene_start_on_exit(void* context) {
|
|
GpioApp* app = context;
|
|
variable_item_list_reset(app->var_item_list);
|
|
}
|