mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 11:08:36 -07:00
Move gpio pins settings to own protocols menu
This commit is contained in:
@@ -13,6 +13,7 @@ ADD_SCENE(xtreme_app, protocols_freqs, ProtocolsFreqs)
|
|||||||
ADD_SCENE(xtreme_app, protocols_freqs_static, ProtocolsFreqsStatic)
|
ADD_SCENE(xtreme_app, protocols_freqs_static, ProtocolsFreqsStatic)
|
||||||
ADD_SCENE(xtreme_app, protocols_freqs_hopper, ProtocolsFreqsHopper)
|
ADD_SCENE(xtreme_app, protocols_freqs_hopper, ProtocolsFreqsHopper)
|
||||||
ADD_SCENE(xtreme_app, protocols_freqs_add, ProtocolsFreqsAdd)
|
ADD_SCENE(xtreme_app, protocols_freqs_add, ProtocolsFreqsAdd)
|
||||||
|
ADD_SCENE(xtreme_app, protocols_gpio, ProtocolsGpio)
|
||||||
ADD_SCENE(xtreme_app, misc, Misc)
|
ADD_SCENE(xtreme_app, misc, Misc)
|
||||||
ADD_SCENE(xtreme_app, misc_screen, MiscScreen)
|
ADD_SCENE(xtreme_app, misc_screen, MiscScreen)
|
||||||
ADD_SCENE(xtreme_app, misc_dolphin, MiscDolphin)
|
ADD_SCENE(xtreme_app, misc_dolphin, MiscDolphin)
|
||||||
|
|||||||
@@ -5,11 +5,7 @@ enum VarItemListIndex {
|
|||||||
VarItemListIndexBadbtRemember,
|
VarItemListIndexBadbtRemember,
|
||||||
VarItemListIndexSubghzFreqs,
|
VarItemListIndexSubghzFreqs,
|
||||||
VarItemListIndexSubghzExtend,
|
VarItemListIndexSubghzExtend,
|
||||||
VarItemListIndexSpiCc1101Handle,
|
VarItemListIndexGpioPins,
|
||||||
VarItemListIndexSpiNrf24Handle,
|
|
||||||
VarItemListIndexUartEspChannel,
|
|
||||||
VarItemListIndexUartNmeaChannel,
|
|
||||||
VarItemListIndexUartGeneralChannel,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void xtreme_app_scene_protocols_var_item_list_callback(void* context, uint32_t index) {
|
void xtreme_app_scene_protocols_var_item_list_callback(void* context, uint32_t index) {
|
||||||
@@ -40,51 +36,6 @@ static void xtreme_app_scene_protocols_subghz_extend_changed(VariableItem* item)
|
|||||||
app->save_subghz = true;
|
app->save_subghz = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xtreme_app_scene_protocols_cc1101_handle_changed(VariableItem* item) {
|
|
||||||
XtremeApp* app = variable_item_get_context(item);
|
|
||||||
XTREME_SETTINGS()->spi_cc1101_handle =
|
|
||||||
variable_item_get_current_value_index(item) == 0 ? SpiDefault : SpiExtra;
|
|
||||||
variable_item_set_current_value_text(
|
|
||||||
item, XTREME_SETTINGS()->spi_cc1101_handle == SpiDefault ? "Default" : "Extra");
|
|
||||||
app->save_settings = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void xtreme_app_scene_protocols_nrf24_handle_changed(VariableItem* item) {
|
|
||||||
XtremeApp* app = variable_item_get_context(item);
|
|
||||||
XTREME_SETTINGS()->spi_nrf24_handle =
|
|
||||||
variable_item_get_current_value_index(item) == 0 ? SpiDefault : SpiExtra;
|
|
||||||
variable_item_set_current_value_text(
|
|
||||||
item, XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault ? "Default" : "Extra");
|
|
||||||
app->save_settings = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void xtreme_app_scene_protocols_esp32_channel_changed(VariableItem* item) {
|
|
||||||
XtremeApp* app = variable_item_get_context(item);
|
|
||||||
XTREME_SETTINGS()->uart_esp_channel =
|
|
||||||
variable_item_get_current_value_index(item) == 0 ? UARTDefault : UARTExtra;
|
|
||||||
variable_item_set_current_value_text(
|
|
||||||
item, XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? "13,14" : "15,16");
|
|
||||||
app->save_settings = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void xtreme_app_scene_protocols_nmea_channel_changed(VariableItem* item) {
|
|
||||||
XtremeApp* app = variable_item_get_context(item);
|
|
||||||
XTREME_SETTINGS()->uart_nmea_channel =
|
|
||||||
variable_item_get_current_value_index(item) == 0 ? UARTDefault : UARTExtra;
|
|
||||||
variable_item_set_current_value_text(
|
|
||||||
item, XTREME_SETTINGS()->uart_nmea_channel == UARTDefault ? "13,14" : "15,16");
|
|
||||||
app->save_settings = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void xtreme_app_scene_protocols_general_channel_changed(VariableItem* item) {
|
|
||||||
XtremeApp* app = variable_item_get_context(item);
|
|
||||||
XTREME_SETTINGS()->uart_general_channel =
|
|
||||||
variable_item_get_current_value_index(item) == 0 ? UARTDefault : UARTExtra;
|
|
||||||
variable_item_set_current_value_text(
|
|
||||||
item, XTREME_SETTINGS()->uart_general_channel == UARTDefault ? "13,14" : "15,16");
|
|
||||||
app->save_settings = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void xtreme_app_scene_protocols_on_enter(void* context) {
|
void xtreme_app_scene_protocols_on_enter(void* context) {
|
||||||
XtremeApp* app = context;
|
XtremeApp* app = context;
|
||||||
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
||||||
@@ -113,51 +64,8 @@ void xtreme_app_scene_protocols_on_enter(void* context) {
|
|||||||
variable_item_set_current_value_index(item, app->subghz_extend);
|
variable_item_set_current_value_index(item, app->subghz_extend);
|
||||||
variable_item_set_current_value_text(item, app->subghz_extend ? "ON" : "OFF");
|
variable_item_set_current_value_text(item, app->subghz_extend ? "ON" : "OFF");
|
||||||
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(var_item_list, "GPIO Pins", 0, NULL, app);
|
||||||
var_item_list,
|
variable_item_set_current_value_text(item, ">");
|
||||||
"SPI CC1101 Handle",
|
|
||||||
2,
|
|
||||||
xtreme_app_scene_protocols_cc1101_handle_changed,
|
|
||||||
app);
|
|
||||||
variable_item_set_current_value_index(item, xtreme_settings->spi_cc1101_handle);
|
|
||||||
variable_item_set_current_value_text(
|
|
||||||
item, xtreme_settings->spi_cc1101_handle == SpiDefault ? "Default" : "Extra");
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
|
||||||
var_item_list, "SPI NRF24 Handle", 2, xtreme_app_scene_protocols_nrf24_handle_changed, app);
|
|
||||||
variable_item_set_current_value_index(item, xtreme_settings->spi_nrf24_handle);
|
|
||||||
variable_item_set_current_value_text(
|
|
||||||
item, xtreme_settings->spi_nrf24_handle == SpiDefault ? "Default" : "Extra");
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
|
||||||
var_item_list,
|
|
||||||
"UART ESP32/ESP8266 Channel",
|
|
||||||
2,
|
|
||||||
xtreme_app_scene_protocols_esp32_channel_changed,
|
|
||||||
app);
|
|
||||||
variable_item_set_current_value_index(item, xtreme_settings->uart_esp_channel);
|
|
||||||
variable_item_set_current_value_text(
|
|
||||||
item, xtreme_settings->uart_esp_channel == UARTDefault ? "13,14" : "15,16");
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
|
||||||
var_item_list,
|
|
||||||
"UART NMEA Channel",
|
|
||||||
2,
|
|
||||||
xtreme_app_scene_protocols_nmea_channel_changed,
|
|
||||||
app);
|
|
||||||
variable_item_set_current_value_index(item, xtreme_settings->uart_nmea_channel);
|
|
||||||
variable_item_set_current_value_text(
|
|
||||||
item, xtreme_settings->uart_nmea_channel == UARTDefault ? "13,14" : "15,16");
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
|
||||||
var_item_list,
|
|
||||||
"UART General Channel",
|
|
||||||
2,
|
|
||||||
xtreme_app_scene_protocols_general_channel_changed,
|
|
||||||
app);
|
|
||||||
variable_item_set_current_value_index(item, xtreme_settings->uart_general_channel);
|
|
||||||
variable_item_set_current_value_text(
|
|
||||||
item, xtreme_settings->uart_general_channel == UARTDefault ? "13,14" : "15,16");
|
|
||||||
|
|
||||||
variable_item_list_set_enter_callback(
|
variable_item_list_set_enter_callback(
|
||||||
var_item_list, xtreme_app_scene_protocols_var_item_list_callback, app);
|
var_item_list, xtreme_app_scene_protocols_var_item_list_callback, app);
|
||||||
@@ -180,6 +88,10 @@ bool xtreme_app_scene_protocols_on_event(void* context, SceneManagerEvent event)
|
|||||||
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneProtocolsFreqs, 0);
|
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneProtocolsFreqs, 0);
|
||||||
scene_manager_next_scene(app->scene_manager, XtremeAppSceneProtocolsFreqs);
|
scene_manager_next_scene(app->scene_manager, XtremeAppSceneProtocolsFreqs);
|
||||||
break;
|
break;
|
||||||
|
case VarItemListIndexGpioPins:
|
||||||
|
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneProtocolsGpio, 0);
|
||||||
|
scene_manager_next_scene(app->scene_manager, XtremeAppSceneProtocolsGpio);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
#include "../xtreme_app.h"
|
||||||
|
|
||||||
|
enum VarItemListIndex {
|
||||||
|
VarItemListIndexSpiCc1101Handle,
|
||||||
|
VarItemListIndexSpiNrf24Handle,
|
||||||
|
VarItemListIndexUartEspChannel,
|
||||||
|
VarItemListIndexUartNmeaChannel,
|
||||||
|
VarItemListIndexUartGeneralChannel,
|
||||||
|
};
|
||||||
|
|
||||||
|
void xtreme_app_scene_protocols_gpio_var_item_list_callback(void* context, uint32_t index) {
|
||||||
|
XtremeApp* app = context;
|
||||||
|
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xtreme_app_scene_protocols_gpio_cc1101_handle_changed(VariableItem* item) {
|
||||||
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
|
XTREME_SETTINGS()->spi_cc1101_handle =
|
||||||
|
variable_item_get_current_value_index(item) == 0 ? SpiDefault : SpiExtra;
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, XTREME_SETTINGS()->spi_cc1101_handle == SpiDefault ? "Default" : "Extra");
|
||||||
|
app->save_settings = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xtreme_app_scene_protocols_gpio_nrf24_handle_changed(VariableItem* item) {
|
||||||
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
|
XTREME_SETTINGS()->spi_nrf24_handle =
|
||||||
|
variable_item_get_current_value_index(item) == 0 ? SpiDefault : SpiExtra;
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault ? "Default" : "Extra");
|
||||||
|
app->save_settings = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xtreme_app_scene_protocols_gpio_esp32_channel_changed(VariableItem* item) {
|
||||||
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
|
XTREME_SETTINGS()->uart_esp_channel =
|
||||||
|
variable_item_get_current_value_index(item) == 0 ? UARTDefault : UARTExtra;
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? "13,14" : "15,16");
|
||||||
|
app->save_settings = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xtreme_app_scene_protocols_gpio_nmea_channel_changed(VariableItem* item) {
|
||||||
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
|
XTREME_SETTINGS()->uart_nmea_channel =
|
||||||
|
variable_item_get_current_value_index(item) == 0 ? UARTDefault : UARTExtra;
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, XTREME_SETTINGS()->uart_nmea_channel == UARTDefault ? "13,14" : "15,16");
|
||||||
|
app->save_settings = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xtreme_app_scene_protocols_gpio_general_channel_changed(VariableItem* item) {
|
||||||
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
|
XTREME_SETTINGS()->uart_general_channel =
|
||||||
|
variable_item_get_current_value_index(item) == 0 ? UARTDefault : UARTExtra;
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, XTREME_SETTINGS()->uart_general_channel == UARTDefault ? "13,14" : "15,16");
|
||||||
|
app->save_settings = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void xtreme_app_scene_protocols_gpio_on_enter(void* context) {
|
||||||
|
XtremeApp* app = context;
|
||||||
|
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
||||||
|
VariableItemList* var_item_list = app->var_item_list;
|
||||||
|
VariableItem* item;
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
var_item_list,
|
||||||
|
"SPI CC1101 Handle",
|
||||||
|
2,
|
||||||
|
xtreme_app_scene_protocols_gpio_cc1101_handle_changed,
|
||||||
|
app);
|
||||||
|
variable_item_set_current_value_index(item, xtreme_settings->spi_cc1101_handle);
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, xtreme_settings->spi_cc1101_handle == SpiDefault ? "Default" : "Extra");
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
var_item_list,
|
||||||
|
"SPI NRF24 Handle",
|
||||||
|
2,
|
||||||
|
xtreme_app_scene_protocols_gpio_nrf24_handle_changed,
|
||||||
|
app);
|
||||||
|
variable_item_set_current_value_index(item, xtreme_settings->spi_nrf24_handle);
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, xtreme_settings->spi_nrf24_handle == SpiDefault ? "Default" : "Extra");
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
var_item_list,
|
||||||
|
"UART ESP32/ESP8266 Channel",
|
||||||
|
2,
|
||||||
|
xtreme_app_scene_protocols_gpio_esp32_channel_changed,
|
||||||
|
app);
|
||||||
|
variable_item_set_current_value_index(item, xtreme_settings->uart_esp_channel);
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, xtreme_settings->uart_esp_channel == UARTDefault ? "13,14" : "15,16");
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
var_item_list,
|
||||||
|
"UART NMEA Channel",
|
||||||
|
2,
|
||||||
|
xtreme_app_scene_protocols_gpio_nmea_channel_changed,
|
||||||
|
app);
|
||||||
|
variable_item_set_current_value_index(item, xtreme_settings->uart_nmea_channel);
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, xtreme_settings->uart_nmea_channel == UARTDefault ? "13,14" : "15,16");
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
var_item_list,
|
||||||
|
"UART General Channel",
|
||||||
|
2,
|
||||||
|
xtreme_app_scene_protocols_gpio_general_channel_changed,
|
||||||
|
app);
|
||||||
|
variable_item_set_current_value_index(item, xtreme_settings->uart_general_channel);
|
||||||
|
variable_item_set_current_value_text(
|
||||||
|
item, xtreme_settings->uart_general_channel == UARTDefault ? "13,14" : "15,16");
|
||||||
|
|
||||||
|
variable_item_list_set_enter_callback(
|
||||||
|
var_item_list, xtreme_app_scene_protocols_gpio_var_item_list_callback, app);
|
||||||
|
|
||||||
|
variable_item_list_set_selected_item(
|
||||||
|
var_item_list,
|
||||||
|
scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneProtocolsGpio));
|
||||||
|
|
||||||
|
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewVarItemList);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool xtreme_app_scene_protocols_gpio_on_event(void* context, SceneManagerEvent event) {
|
||||||
|
XtremeApp* app = context;
|
||||||
|
bool consumed = false;
|
||||||
|
|
||||||
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
|
scene_manager_set_scene_state(
|
||||||
|
app->scene_manager, XtremeAppSceneProtocolsGpio, event.event);
|
||||||
|
consumed = true;
|
||||||
|
switch(event.event) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return consumed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void xtreme_app_scene_protocols_gpio_on_exit(void* context) {
|
||||||
|
XtremeApp* app = context;
|
||||||
|
variable_item_list_reset(app->var_item_list);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user