mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-13 05:06:30 +04:00
Option to disable auto 5v power for external radio module
Now you can use 3.3v modules without wasting a battery (bonus a bit low noise on power line)
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
uint8_t value_index_exm;
|
uint8_t value_index_exm;
|
||||||
uint8_t value_index_dpin;
|
uint8_t value_index_dpin;
|
||||||
uint8_t value_index_cnt;
|
uint8_t value_index_cnt;
|
||||||
|
uint8_t value_index_pwr;
|
||||||
|
|
||||||
#define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const))
|
#define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const))
|
||||||
const char* const radio_modules_variables_text[] = {
|
const char* const radio_modules_variables_text[] = {
|
||||||
@@ -11,6 +12,12 @@ const char* const radio_modules_variables_text[] = {
|
|||||||
"External",
|
"External",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define EXT_MOD_POWER_COUNT 2
|
||||||
|
const char* const ext_mod_power_text[EXT_MOD_POWER_COUNT] = {
|
||||||
|
"ON",
|
||||||
|
"OFF",
|
||||||
|
};
|
||||||
|
|
||||||
#define DEBUG_P_COUNT 2
|
#define DEBUG_P_COUNT 2
|
||||||
const char* const debug_pin_text[DEBUG_P_COUNT] = {
|
const char* const debug_pin_text[DEBUG_P_COUNT] = {
|
||||||
"OFF",
|
"OFF",
|
||||||
@@ -77,6 +84,14 @@ static void subghz_scene_receiver_config_set_debug_counter(VariableItem* item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void subghz_scene_receiver_config_set_ext_mod_power(VariableItem* item) {
|
||||||
|
uint8_t index = variable_item_get_current_value_index(item);
|
||||||
|
|
||||||
|
variable_item_set_current_value_text(item, ext_mod_power_text[index]);
|
||||||
|
|
||||||
|
furi_hal_subghz_set_external_power_disable(index == 1);
|
||||||
|
}
|
||||||
|
|
||||||
void subghz_scene_ext_module_settings_on_enter(void* context) {
|
void subghz_scene_ext_module_settings_on_enter(void* context) {
|
||||||
SubGhz* subghz = context;
|
SubGhz* subghz = context;
|
||||||
|
|
||||||
@@ -92,10 +107,20 @@ void subghz_scene_ext_module_settings_on_enter(void* context) {
|
|||||||
variable_item_set_current_value_index(item, value_index_exm);
|
variable_item_set_current_value_index(item, value_index_exm);
|
||||||
variable_item_set_current_value_text(item, radio_modules_variables_text[value_index_exm]);
|
variable_item_set_current_value_text(item, radio_modules_variables_text[value_index_exm]);
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
subghz->variable_item_list,
|
||||||
|
"Ext Radio 5v",
|
||||||
|
EXT_MOD_POWER_COUNT,
|
||||||
|
subghz_scene_receiver_config_set_ext_mod_power,
|
||||||
|
subghz);
|
||||||
|
value_index_pwr = furi_hal_subghz_get_external_power_disable();
|
||||||
|
variable_item_set_current_value_index(item, value_index_pwr);
|
||||||
|
variable_item_set_current_value_text(item, ext_mod_power_text[value_index_pwr]);
|
||||||
|
|
||||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
subghz->variable_item_list,
|
subghz->variable_item_list,
|
||||||
"Debug Pin:",
|
"Debug Pin",
|
||||||
DEBUG_P_COUNT,
|
DEBUG_P_COUNT,
|
||||||
subghz_scene_receiver_config_set_debug_pin,
|
subghz_scene_receiver_config_set_debug_pin,
|
||||||
subghz);
|
subghz);
|
||||||
@@ -105,7 +130,7 @@ void subghz_scene_ext_module_settings_on_enter(void* context) {
|
|||||||
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
subghz->variable_item_list,
|
subghz->variable_item_list,
|
||||||
"Counter Mult:",
|
"Counter incr.",
|
||||||
DEBUG_COUNTER_COUNT,
|
DEBUG_COUNTER_COUNT,
|
||||||
subghz_scene_receiver_config_set_debug_counter,
|
subghz_scene_receiver_config_set_debug_counter,
|
||||||
subghz);
|
subghz);
|
||||||
|
|||||||
@@ -1357,6 +1357,7 @@ Function,-,furi_hal_subghz_dump_state,void,
|
|||||||
Function,+,furi_hal_subghz_enable_ext_power,_Bool,
|
Function,+,furi_hal_subghz_enable_ext_power,_Bool,
|
||||||
Function,+,furi_hal_subghz_flush_rx,void,
|
Function,+,furi_hal_subghz_flush_rx,void,
|
||||||
Function,+,furi_hal_subghz_flush_tx,void,
|
Function,+,furi_hal_subghz_flush_tx,void,
|
||||||
|
Function,+,furi_hal_subghz_get_external_power_disable,_Bool,
|
||||||
Function,+,furi_hal_subghz_get_lqi,uint8_t,
|
Function,+,furi_hal_subghz_get_lqi,uint8_t,
|
||||||
Function,+,furi_hal_subghz_get_radio_type,SubGhzRadioType,
|
Function,+,furi_hal_subghz_get_radio_type,SubGhzRadioType,
|
||||||
Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t,
|
Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t,
|
||||||
@@ -1377,6 +1378,7 @@ Function,+,furi_hal_subghz_reset,void,
|
|||||||
Function,+,furi_hal_subghz_rx,void,
|
Function,+,furi_hal_subghz_rx,void,
|
||||||
Function,+,furi_hal_subghz_rx_pipe_not_empty,_Bool,
|
Function,+,furi_hal_subghz_rx_pipe_not_empty,_Bool,
|
||||||
Function,+,furi_hal_subghz_set_async_mirror_pin,void,const GpioPin*
|
Function,+,furi_hal_subghz_set_async_mirror_pin,void,const GpioPin*
|
||||||
|
Function,+,furi_hal_subghz_set_external_power_disable,void,_Bool
|
||||||
Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t
|
Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t
|
||||||
Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t
|
Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t
|
||||||
Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
||||||
|
|||||||
|
@@ -39,6 +39,7 @@ volatile FuriHalSubGhz furi_hal_subghz = {
|
|||||||
.spi_bus_handle = &furi_hal_spi_bus_handle_subghz,
|
.spi_bus_handle = &furi_hal_spi_bus_handle_subghz,
|
||||||
.cc1101_g0_pin = &gpio_cc1101_g0,
|
.cc1101_g0_pin = &gpio_cc1101_g0,
|
||||||
.rolling_counter_mult = 1,
|
.rolling_counter_mult = 1,
|
||||||
|
.ext_module_power_disabled = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool furi_hal_subghz_set_radio_type(SubGhzRadioType state) {
|
bool furi_hal_subghz_set_radio_type(SubGhzRadioType state) {
|
||||||
@@ -70,6 +71,14 @@ void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult) {
|
|||||||
furi_hal_subghz.rolling_counter_mult = mult;
|
furi_hal_subghz.rolling_counter_mult = mult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void furi_hal_subghz_set_external_power_disable(bool state) {
|
||||||
|
furi_hal_subghz.ext_module_power_disabled = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool furi_hal_subghz_get_external_power_disable(void) {
|
||||||
|
return furi_hal_subghz.ext_module_power_disabled;
|
||||||
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
|
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
|
||||||
furi_hal_subghz.async_mirror_pin = pin;
|
furi_hal_subghz.async_mirror_pin = pin;
|
||||||
}
|
}
|
||||||
@@ -79,6 +88,9 @@ void furi_hal_subghz_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_subghz_enable_ext_power(void) {
|
bool furi_hal_subghz_enable_ext_power(void) {
|
||||||
|
if(furi_hal_subghz.ext_module_power_disabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if(furi_hal_subghz.radio_type != SubGhzRadioInternal) {
|
if(furi_hal_subghz.radio_type != SubGhzRadioInternal) {
|
||||||
uint8_t attempts = 0;
|
uint8_t attempts = 0;
|
||||||
while(!furi_hal_power_is_otg_enabled() && attempts++ < 2) {
|
while(!furi_hal_power_is_otg_enabled() && attempts++ < 2) {
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ typedef struct {
|
|||||||
FuriHalSpiBusHandle* spi_bus_handle;
|
FuriHalSpiBusHandle* spi_bus_handle;
|
||||||
const GpioPin* cc1101_g0_pin;
|
const GpioPin* cc1101_g0_pin;
|
||||||
uint8_t rolling_counter_mult;
|
uint8_t rolling_counter_mult;
|
||||||
|
bool ext_module_power_disabled;
|
||||||
} FuriHalSubGhz;
|
} FuriHalSubGhz;
|
||||||
|
|
||||||
extern volatile FuriHalSubGhz furi_hal_subghz;
|
extern volatile FuriHalSubGhz furi_hal_subghz;
|
||||||
@@ -321,6 +322,14 @@ uint8_t furi_hal_subghz_get_rolling_counter_mult(void);
|
|||||||
*/
|
*/
|
||||||
void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult);
|
void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult);
|
||||||
|
|
||||||
|
/** If true - disable 5v power of the external radio module
|
||||||
|
*/
|
||||||
|
void furi_hal_subghz_set_external_power_disable(bool state);
|
||||||
|
|
||||||
|
/** Get the current state of the external power disable flag
|
||||||
|
*/
|
||||||
|
bool furi_hal_subghz_get_external_power_disable(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user