mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-22 05:14:46 -07:00
gpio i2c?
This commit is contained in:
@@ -3,3 +3,5 @@ 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, i2c_scanner, I2CScanner)
|
||||
ADD_SCENE(gpio, i2c_sfp, I2CSfp)
|
||||
|
||||
36
applications/main/gpio/scenes/gpio_scene_i2c_scanner.c
Normal file
36
applications/main/gpio/scenes/gpio_scene_i2c_scanner.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "../gpio_app_i.h"
|
||||
#include <furi_hal_gpio.h>
|
||||
|
||||
static I2CScannerState* i2c_scanner_state;
|
||||
|
||||
void gpio_scene_i2c_scanner_ok_callback(InputType type, void* context) {
|
||||
furi_assert(context);
|
||||
GpioApp* app = context;
|
||||
|
||||
if(type == InputTypeRelease) {
|
||||
notification_message(app->notifications, &sequence_set_green_255);
|
||||
gpio_i2c_scanner_run_once(i2c_scanner_state);
|
||||
notification_message(app->notifications, &sequence_reset_green);
|
||||
gpio_i2c_scanner_update_state(app->gpio_i2c_scanner, i2c_scanner_state);
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_scene_i2c_scanner_on_enter(void* context) {
|
||||
GpioApp* app = context;
|
||||
i2c_scanner_state = malloc(sizeof(I2CScannerState));
|
||||
|
||||
gpio_i2c_scanner_set_ok_callback(
|
||||
app->gpio_i2c_scanner, gpio_scene_i2c_scanner_ok_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewI2CScanner);
|
||||
}
|
||||
|
||||
bool gpio_scene_i2c_scanner_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
void gpio_scene_i2c_scanner_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
free(i2c_scanner_state);
|
||||
}
|
||||
35
applications/main/gpio/scenes/gpio_scene_i2c_sfp.c
Normal file
35
applications/main/gpio/scenes/gpio_scene_i2c_sfp.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "../gpio_app_i.h"
|
||||
#include <furi_hal_gpio.h>
|
||||
|
||||
static I2CSfpState* i2c_sfp_state;
|
||||
|
||||
void gpio_scene_i2c_sfp_ok_callback(InputType type, void* context) {
|
||||
furi_assert(context);
|
||||
GpioApp* app = context;
|
||||
|
||||
if(type == InputTypeRelease) {
|
||||
notification_message(app->notifications, &sequence_set_green_255);
|
||||
gpio_i2c_sfp_run_once(i2c_sfp_state);
|
||||
notification_message(app->notifications, &sequence_reset_green);
|
||||
gpio_i2c_sfp_update_state(app->gpio_i2c_sfp, i2c_sfp_state);
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_scene_i2c_sfp_on_enter(void* context) {
|
||||
GpioApp* app = context;
|
||||
i2c_sfp_state = malloc(sizeof(I2CSfpState));
|
||||
|
||||
gpio_i2c_sfp_set_ok_callback(app->gpio_i2c_sfp, gpio_scene_i2c_sfp_ok_callback, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, GpioAppViewI2CSfp);
|
||||
}
|
||||
|
||||
bool gpio_scene_i2c_sfp_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
void gpio_scene_i2c_sfp_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
free(i2c_sfp_state);
|
||||
}
|
||||
@@ -6,6 +6,8 @@ enum GpioItem {
|
||||
GpioItemUsbUart,
|
||||
GpioItemTest,
|
||||
GpioItemOtg,
|
||||
GpioItemI2CScanner,
|
||||
GpioItemI2CSfp,
|
||||
};
|
||||
|
||||
enum GpioOtg {
|
||||
@@ -26,6 +28,10 @@ static void gpio_scene_start_var_list_enter_callback(void* context, uint32_t ind
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, GpioStartEventManualControl);
|
||||
} else if(index == GpioItemUsbUart) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, GpioStartEventUsbUart);
|
||||
} else if(index == GpioItemI2CScanner) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, GpioStartEventI2CScanner);
|
||||
} else if(index == GpioItemI2CSfp) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, GpioStartEventI2CSfp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +73,9 @@ void gpio_scene_start_on_enter(void* context) {
|
||||
variable_item_set_current_value_text(item, gpio_otg_text[GpioOtgOff]);
|
||||
}
|
||||
|
||||
variable_item_list_add(var_item_list, "I2C-Scanner", 0, NULL, NULL);
|
||||
variable_item_list_add(var_item_list, "I2C-SFP", 0, NULL, NULL);
|
||||
|
||||
variable_item_list_set_selected_item(
|
||||
var_item_list, scene_manager_get_scene_state(app->scene_manager, GpioSceneStart));
|
||||
|
||||
@@ -85,6 +94,12 @@ bool gpio_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
} 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 == GpioStartEventI2CScanner) {
|
||||
scene_manager_set_scene_state(app->scene_manager, GpioSceneStart, GpioItemI2CScanner);
|
||||
scene_manager_next_scene(app->scene_manager, GpioSceneI2CScanner);
|
||||
} else if(event.event == GpioStartEventI2CSfp) {
|
||||
scene_manager_set_scene_state(app->scene_manager, GpioSceneStart, GpioItemI2CSfp);
|
||||
scene_manager_next_scene(app->scene_manager, GpioSceneI2CSfp);
|
||||
} else if(event.event == GpioStartEventUsbUart) {
|
||||
scene_manager_set_scene_state(app->scene_manager, GpioSceneStart, GpioItemUsbUart);
|
||||
if(!furi_hal_usb_is_locked()) {
|
||||
|
||||
Reference in New Issue
Block a user