This commit is contained in:
Willy-JL
2024-01-30 19:21:44 +00:00
12 changed files with 153 additions and 120 deletions

View File

@@ -24,6 +24,9 @@ static void gpio_app_tick_event_callback(void* context) {
GpioApp* gpio_app_alloc() {
GpioApp* app = malloc(sizeof(GpioApp));
app->expansion = furi_record_open(RECORD_EXPANSION);
expansion_disable(app->expansion);
app->gui = furi_record_open(RECORD_GUI);
app->gpio_items = gpio_items_alloc();
@@ -80,12 +83,7 @@ GpioApp* gpio_app_alloc() {
GpioAppViewUsbUartCfg,
variable_item_list_get_view(app->var_item_list));
if(furi_hal_serial_control_is_busy(FuriHalSerialIdUsart) ||
furi_hal_serial_control_is_busy(FuriHalSerialIdLpuart)) {
scene_manager_next_scene(app->scene_manager, GpioSceneErrorExpansion);
} else {
scene_manager_next_scene(app->scene_manager, GpioSceneStart);
}
scene_manager_next_scene(app->scene_manager, GpioSceneStart);
return app;
}
@@ -118,6 +116,9 @@ void gpio_app_free(GpioApp* app) {
furi_record_close(RECORD_GUI);
furi_record_close(RECORD_NOTIFICATION);
expansion_enable(app->expansion);
furi_record_close(RECORD_EXPANSION);
gpio_items_free(app->gpio_items);
free(app);
}

View File

@@ -19,8 +19,10 @@
#include "views/gpio_i2c_scanner.h"
#include "views/gpio_i2c_sfp.h"
#include <assets_icons.h>
#include <expansion/expansion.h>
struct GpioApp {
Expansion* expansion;
Gui* gui;
NotificationApp* notifications;
ViewDispatcher* view_dispatcher;

View File

@@ -3,7 +3,6 @@ ADD_SCENE(gpio, test, Test)
ADD_SCENE(gpio, usb_uart, UsbUart)
ADD_SCENE(gpio, usb_uart_cfg, UsbUartCfg)
ADD_SCENE(gpio, usb_uart_close_rpc, UsbUartCloseRpc)
ADD_SCENE(gpio, error_expansion, ErrorExpansion)
ADD_SCENE(gpio, exit_confirm, ExitConfirm)
ADD_SCENE(gpio, i2c_scanner, I2CScanner)
ADD_SCENE(gpio, i2c_sfp, I2CSfp)

View File

@@ -1,43 +0,0 @@
#include "../gpio_app_i.h"
#include "../gpio_custom_event.h"
void gpio_scene_error_expansion_on_enter(void* context) {
GpioApp* app = context;
widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
widget_add_string_multiline_element(
app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Ext. Module\nis connected!");
widget_add_string_multiline_element(
app->widget,
3,
30,
AlignLeft,
AlignTop,
FontSecondary,
"Disconnect External\n"
"Module\n"
"to use this function.");
view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewUsbUartCloseRpc);
}
bool gpio_scene_error_expansion_on_event(void* context, SceneManagerEvent event) {
GpioApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GpioCustomEventErrorBack) {
if(!scene_manager_previous_scene(app->scene_manager)) {
scene_manager_stop(app->scene_manager);
view_dispatcher_stop(app->view_dispatcher);
}
consumed = true;
}
}
return consumed;
}
void gpio_scene_error_expansion_on_exit(void* context) {
GpioApp* app = context;
widget_reset(app->widget);
}