SubGhz: fix incorrect response in rpc mode. Code cleanup. (#1964)
* Code cleanup * SubGhz: correct logic in RPC * SubGhz: do not blink on app rpc fail Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
d68ac50efd
commit
3bd74b7f01
@ -155,9 +155,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
|||||||
} else if(event.event == SubGhzCustomEventSceneReceiverInfoSave) {
|
} else if(event.event == SubGhzCustomEventSceneReceiverInfoSave) {
|
||||||
//CC1101 Stop RX -> Save
|
//CC1101 Stop RX -> Save
|
||||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||||
if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) {
|
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
|
||||||
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
|
|
||||||
}
|
|
||||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||||
subghz_rx_end(subghz);
|
subghz_rx_end(subghz);
|
||||||
subghz_sleep(subghz);
|
subghz_sleep(subghz);
|
||||||
|
@ -40,9 +40,8 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
if((subghz->txrx->txrx_state == SubGhzTxRxStateSleep) &&
|
if((subghz->txrx->txrx_state == SubGhzTxRxStateSleep) &&
|
||||||
(state == SubGhzRpcStateLoaded)) {
|
(state == SubGhzRpcStateLoaded)) {
|
||||||
subghz_blink_start(subghz);
|
|
||||||
result = subghz_tx_start(subghz, subghz->txrx->fff_data);
|
result = subghz_tx_start(subghz, subghz->txrx->fff_data);
|
||||||
result = true;
|
if(result) subghz_blink_start(subghz);
|
||||||
}
|
}
|
||||||
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventButtonPress, result);
|
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventButtonPress, result);
|
||||||
} else if(event.event == SubGhzCustomEventSceneRpcButtonRelease) {
|
} else if(event.event == SubGhzCustomEventSceneRpcButtonRelease) {
|
||||||
|
@ -72,8 +72,8 @@ void dap_scene_config_on_enter(void* context) {
|
|||||||
variable_item_set_current_value_index(item, config->uart_swap);
|
variable_item_set_current_value_index(item, config->uart_swap);
|
||||||
variable_item_set_current_value_text(item, uart_swap[config->uart_swap]);
|
variable_item_set_current_value_text(item, uart_swap[config->uart_swap]);
|
||||||
|
|
||||||
item = variable_item_list_add(var_item_list, "Help and Pinout", 0, NULL, NULL);
|
variable_item_list_add(var_item_list, "Help and Pinout", 0, NULL, NULL);
|
||||||
item = variable_item_list_add(var_item_list, "About", 0, NULL, NULL);
|
variable_item_list_add(var_item_list, "About", 0, NULL, NULL);
|
||||||
|
|
||||||
variable_item_list_set_selected_item(
|
variable_item_list_set_selected_item(
|
||||||
var_item_list, scene_manager_get_scene_state(app->scene_manager, DapSceneConfig));
|
var_item_list, scene_manager_get_scene_state(app->scene_manager, DapSceneConfig));
|
||||||
|
@ -40,7 +40,7 @@ static bool pin_name_to_int(FuriString* pin_name, size_t* result) {
|
|||||||
bool debug = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug);
|
bool debug = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug);
|
||||||
for(size_t i = 0; i < COUNT_OF(cli_command_gpio_pins); i++) {
|
for(size_t i = 0; i < COUNT_OF(cli_command_gpio_pins); i++) {
|
||||||
if(!furi_string_cmp(pin_name, cli_command_gpio_pins[i].name)) {
|
if(!furi_string_cmp(pin_name, cli_command_gpio_pins[i].name)) {
|
||||||
if(!cli_command_gpio_pins[i].debug || (cli_command_gpio_pins[i].debug && debug)) {
|
if(!cli_command_gpio_pins[i].debug || debug) {
|
||||||
*result = i;
|
*result = i;
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
@ -55,7 +55,7 @@ static void gpio_print_pins(void) {
|
|||||||
printf("Wrong pin name. Available pins: ");
|
printf("Wrong pin name. Available pins: ");
|
||||||
bool debug = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug);
|
bool debug = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug);
|
||||||
for(size_t i = 0; i < COUNT_OF(cli_command_gpio_pins); i++) {
|
for(size_t i = 0; i < COUNT_OF(cli_command_gpio_pins); i++) {
|
||||||
if(!cli_command_gpio_pins[i].debug || (cli_command_gpio_pins[i].debug && debug)) {
|
if(!cli_command_gpio_pins[i].debug || debug) {
|
||||||
printf("%s ", cli_command_gpio_pins[i].name);
|
printf("%s ", cli_command_gpio_pins[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ static bool desktop_view_locked_input(InputEvent* event, void* context) {
|
|||||||
view_commit_model(locked_view->view, is_changed);
|
view_commit_model(locked_view->view, is_changed);
|
||||||
|
|
||||||
if(view_state == DesktopViewLockedStateUnlocked) {
|
if(view_state == DesktopViewLockedStateUnlocked) {
|
||||||
return view_state != DesktopViewLockedStateUnlocked;
|
return false;
|
||||||
} else if(view_state == DesktopViewLockedStateLocked && pin_locked) {
|
} else if(view_state == DesktopViewLockedStateLocked && pin_locked) {
|
||||||
locked_view->callback(DesktopLockedEventShowPinInput, locked_view->context);
|
locked_view->callback(DesktopLockedEventShowPinInput, locked_view->context);
|
||||||
} else if(
|
} else if(
|
||||||
|
@ -304,8 +304,7 @@ void view_dispatcher_handle_custom_event(ViewDispatcher* view_dispatcher, uint32
|
|||||||
}
|
}
|
||||||
// If custom event is not consumed in View, call callback
|
// If custom event is not consumed in View, call callback
|
||||||
if(!is_consumed && view_dispatcher->custom_event_callback) {
|
if(!is_consumed && view_dispatcher->custom_event_callback) {
|
||||||
is_consumed =
|
view_dispatcher->custom_event_callback(view_dispatcher->event_context, event);
|
||||||
view_dispatcher->custom_event_callback(view_dispatcher->event_context, event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ static const uint8_t reset_blink_mask = 1 << 6;
|
|||||||
|
|
||||||
void notification_vibro_on();
|
void notification_vibro_on();
|
||||||
void notification_vibro_off();
|
void notification_vibro_off();
|
||||||
void notification_sound_on(float pwm, float freq);
|
void notification_sound_on(float freq, float volume);
|
||||||
void notification_sound_off();
|
void notification_sound_off();
|
||||||
|
|
||||||
uint8_t notification_settings_get_display_brightness(NotificationApp* app, uint8_t value);
|
uint8_t notification_settings_get_display_brightness(NotificationApp* app, uint8_t value);
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
#include <gui/elements.h>
|
#include <gui/elements.h>
|
||||||
#include <assets_icons.h>
|
#include <assets_icons.h>
|
||||||
|
|
||||||
|
#define LOW_CHARGE_THRESHOLD 10
|
||||||
|
#define HIGH_DRAIN_CURRENT_THRESHOLD 100
|
||||||
|
|
||||||
struct BatteryInfo {
|
struct BatteryInfo {
|
||||||
View* view;
|
View* view;
|
||||||
};
|
};
|
||||||
@ -28,9 +31,9 @@ static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) {
|
|||||||
canvas_draw_icon(canvas, x, y, &I_BatteryBody_52x28);
|
canvas_draw_icon(canvas, x, y, &I_BatteryBody_52x28);
|
||||||
if(charge_current > 0) {
|
if(charge_current > 0) {
|
||||||
canvas_draw_icon(canvas, x + 16, y + 7, &I_FaceCharging_29x14);
|
canvas_draw_icon(canvas, x + 16, y + 7, &I_FaceCharging_29x14);
|
||||||
} else if(drain_current > 100) {
|
} else if(drain_current > HIGH_DRAIN_CURRENT_THRESHOLD) {
|
||||||
canvas_draw_icon(canvas, x + 16, y + 7, &I_FaceConfused_29x14);
|
canvas_draw_icon(canvas, x + 16, y + 7, &I_FaceConfused_29x14);
|
||||||
} else if(data->charge < 10) {
|
} else if(data->charge < LOW_CHARGE_THRESHOLD) {
|
||||||
canvas_draw_icon(canvas, x + 16, y + 7, &I_FaceNopower_29x14);
|
canvas_draw_icon(canvas, x + 16, y + 7, &I_FaceNopower_29x14);
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_icon(canvas, x + 16, y + 7, &I_FaceNormal_29x14);
|
canvas_draw_icon(canvas, x + 16, y + 7, &I_FaceNormal_29x14);
|
||||||
@ -51,11 +54,19 @@ static void draw_battery(Canvas* canvas, BatteryInfoModel* data, int x, int y) {
|
|||||||
(uint32_t)(data->vbus_voltage * 10) % 10,
|
(uint32_t)(data->vbus_voltage * 10) % 10,
|
||||||
charge_current);
|
charge_current);
|
||||||
} else if(drain_current > 0) {
|
} else if(drain_current > 0) {
|
||||||
snprintf(emote, sizeof(emote), "%s", drain_current > 100 ? "Oh no!" : "Om-nom-nom!");
|
snprintf(
|
||||||
|
emote,
|
||||||
|
sizeof(emote),
|
||||||
|
"%s",
|
||||||
|
drain_current > HIGH_DRAIN_CURRENT_THRESHOLD ? "Oh no!" : "Om-nom-nom!");
|
||||||
snprintf(header, sizeof(header), "%s", "Consumption is");
|
snprintf(header, sizeof(header), "%s", "Consumption is");
|
||||||
snprintf(
|
snprintf(
|
||||||
value, sizeof(value), "%ld %s", drain_current, drain_current > 100 ? "mA!" : "mA");
|
value,
|
||||||
} else if(charge_current != 0 || drain_current != 0) {
|
sizeof(value),
|
||||||
|
"%ld %s",
|
||||||
|
drain_current,
|
||||||
|
drain_current > HIGH_DRAIN_CURRENT_THRESHOLD ? "mA!" : "mA");
|
||||||
|
} else if(drain_current != 0) {
|
||||||
snprintf(header, 20, "...");
|
snprintf(header, 20, "...");
|
||||||
} else {
|
} else {
|
||||||
snprintf(header, sizeof(header), "Charged!");
|
snprintf(header, sizeof(header), "Charged!");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user