mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 03:18:35 -07:00
[FL-1756, FL-1769, FL-1776, FL-1759] Gui: input events complementary V3, refactoring. SubGhz: read/emulate fixes. Cleanup. (#684)
* Gui: move rotation logic to ViewPort, replace delayed View switch in ViewDispatcher with event filtering and redirection to previous view. * SubGhz: add function description * Gui, Input: add event id to input events. * SubGhz: fix "crashing on ?" * SubGhz: add icon scanning * SubGhz: updated interface read scene, updated interface config scene * Assets: update subghz assets * SubGhz: replaced the picture in the read scene, changed the paths to additional files * SubGhz: fix deadlock in timer callback * SubGhz: fix icon read scene * SubGhz: fix icon read scene * SubGhz: fix duble text transmitter scene * SubGhz: correct spelling. Gui: bigger queue for ViewDispatcher. * SubGhz: fix creation and transmission of dynamic code without the presence of a manufactory key * SubGhz: fix keelog, setting a name in the absence of a manufactory key * SubGhz: fix load bad keelog key * Format sources * Furi: remove garbage from core. GpioTester: fix memory leak and cleanup * Accessor: remove obsolete notification code * MusicPlayer: remove input event injection * Input: rename id to sequence Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ ADD_SCENE(subghz, save_name, SaveName)
|
||||
ADD_SCENE(subghz, save_success, SaveSuccess)
|
||||
ADD_SCENE(subghz, saved, Saved)
|
||||
ADD_SCENE(subghz, transmitter, Transmitter)
|
||||
ADD_SCENE(subghz, no_man, NoMan)
|
||||
ADD_SCENE(subghz, test, Test)
|
||||
ADD_SCENE(subghz, test_static, TestStatic)
|
||||
ADD_SCENE(subghz, test_carrier, TestCarrier)
|
||||
|
||||
48
applications/subghz/scenes/subghz_scene_no_man.c
Normal file
48
applications/subghz/scenes/subghz_scene_no_man.c
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "../subghz_i.h"
|
||||
|
||||
#define SCENE_NO_MAN_CUSTOM_EVENT (11UL)
|
||||
|
||||
void subghz_scene_no_man_popup_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SCENE_NO_MAN_CUSTOM_EVENT);
|
||||
}
|
||||
|
||||
const void subghz_scene_no_man_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Setup view
|
||||
Popup* popup = subghz->popup;
|
||||
popup_set_icon(popup, 32, 12, &I_DolphinFirstStart7_61x51);
|
||||
popup_set_header(popup, "No manufactory key", 13, 8, AlignLeft, AlignBottom);
|
||||
popup_set_timeout(popup, 1500);
|
||||
popup_set_context(popup, subghz);
|
||||
popup_set_callback(popup, subghz_scene_no_man_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewPopup);
|
||||
}
|
||||
|
||||
const bool subghz_scene_no_man_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_NO_MAN_CUSTOM_EVENT) {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const void subghz_scene_no_man_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
// Clear view
|
||||
Popup* popup = subghz->popup;
|
||||
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
|
||||
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 0, NULL);
|
||||
popup_set_callback(popup, NULL);
|
||||
popup_set_context(popup, NULL);
|
||||
popup_set_timeout(popup, 0);
|
||||
popup_disable_timeout(popup);
|
||||
}
|
||||
@@ -57,6 +57,10 @@ const bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event
|
||||
subghz->state_notifications = NOTIFICATION_IDLE_STATE;
|
||||
return true;
|
||||
break;
|
||||
case SubghzReceverEventSendHistoryFull:
|
||||
subghz->state_notifications = NOTIFICATION_IDLE_STATE;
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -146,11 +146,15 @@ const bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event
|
||||
subghz->protocol_result->serial = key & 0x0FFFFFFF;
|
||||
subghz->protocol_result->btn = 0x2; //btn 0x1, 0x2, 0x4, 0x8
|
||||
subghz->protocol_result->cnt = 0x0003;
|
||||
subghz_protocol_keeloq_set_manufacture_name(subghz->protocol_result, "DoorHan");
|
||||
subghz->protocol_result->code_last_found =
|
||||
subghz_protocol_keeloq_gen_key(subghz->protocol_result);
|
||||
|
||||
generated_protocol = true;
|
||||
if(subghz_protocol_keeloq_set_manufacture_name(
|
||||
subghz->protocol_result, "DoorHan")) {
|
||||
subghz->protocol_result->code_last_found =
|
||||
subghz_protocol_keeloq_gen_key(subghz->protocol_result);
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNoMan);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -38,6 +38,11 @@ const bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent ev
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
return true;
|
||||
} else if(event.event == SubghzTransmitterEventNoMan) {
|
||||
subghz->state_notifications = NOTIFICATION_IDLE_STATE;
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneNoMan);
|
||||
return true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
if(subghz->state_notifications == NOTIFICATION_TX_STATE) {
|
||||
|
||||
@@ -129,8 +129,8 @@ SubGhz* subghz_alloc() {
|
||||
subghz->worker, (SubGhzWorkerPairCallback)subghz_protocol_parse);
|
||||
subghz_worker_set_context(subghz->worker, subghz->protocol);
|
||||
|
||||
subghz_protocol_load_keeloq_file(subghz->protocol, "/ext/assets/subghz/keeloq_mfcodes");
|
||||
subghz_protocol_load_nice_flor_s_file(subghz->protocol, "/ext/assets/subghz/nice_floor_s_rx");
|
||||
subghz_protocol_load_keeloq_file(subghz->protocol, "/ext/subghz/keeloq_mfcodes");
|
||||
subghz_protocol_load_nice_flor_s_file(subghz->protocol, "/ext/subghz/nice_floor_s_rx");
|
||||
|
||||
//subghz_protocol_enable_dump_text(subghz->protocol, subghz_text_callback, subghz);
|
||||
|
||||
|
||||
@@ -206,8 +206,8 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
|
||||
furi_check(instance->stream);
|
||||
|
||||
SubGhzProtocol* protocol = subghz_protocol_alloc();
|
||||
subghz_protocol_load_keeloq_file(protocol, "/ext/assets/subghz/keeloq_mfcodes");
|
||||
subghz_protocol_load_nice_flor_s_file(protocol, "/ext/assets/subghz/nice_floor_s_rx");
|
||||
subghz_protocol_load_keeloq_file(protocol, "/ext/subghz/keeloq_mfcodes");
|
||||
subghz_protocol_load_nice_flor_s_file(protocol, "/ext/subghz/nice_floor_s_rx");
|
||||
subghz_protocol_enable_dump_text(protocol, subghz_cli_command_rx_text_callback, instance);
|
||||
|
||||
// Configure radio
|
||||
|
||||
@@ -88,9 +88,15 @@ SubGhzProtocolCommonLoad* subghz_history_get_raw_data(SubGhzHistory* instance, u
|
||||
instance->data.param1 = instance->history[idx].te;
|
||||
return &instance->data;
|
||||
}
|
||||
void subghz_history_get_text_space_left(SubGhzHistory* instance, string_t output) {
|
||||
bool subghz_history_get_text_space_left(SubGhzHistory* instance, string_t output) {
|
||||
furi_assert(instance);
|
||||
string_printf(output, "%02u/%02u", instance->last_index_write, SUBGHZ_HISTORY_MAX);
|
||||
if(instance->last_index_write == SUBGHZ_HISTORY_MAX) {
|
||||
if(output != NULL) string_printf(output, "Memory is FULL");
|
||||
return true;
|
||||
}
|
||||
if(output != NULL)
|
||||
string_printf(output, "%02u/%02u", instance->last_index_write, SUBGHZ_HISTORY_MAX);
|
||||
return false;
|
||||
}
|
||||
void subghz_history_get_text_item_menu(SubGhzHistory* instance, string_t output, uint16_t idx) {
|
||||
if(instance->history[idx].code_count_bit < 33) {
|
||||
@@ -144,10 +150,10 @@ void subghz_history_add_to_history(SubGhzHistory* instance, void* context) {
|
||||
instance->history[instance->last_index_write].code_found = protocol->code_last_found;
|
||||
if(strcmp(protocol->name, "KeeLoq") == 0) {
|
||||
instance->history[instance->last_index_write].manufacture_name =
|
||||
subghz_protocol_keeloq_get_manufacture_name(protocol);
|
||||
subghz_protocol_keeloq_find_and_get_manufacture_name(protocol);
|
||||
} else if(strcmp(protocol->name, "Star Line") == 0) {
|
||||
instance->history[instance->last_index_write].manufacture_name =
|
||||
subghz_protocol_star_line_get_manufacture_name(protocol);
|
||||
subghz_protocol_star_line_find_and_get_manufacture_name(protocol);
|
||||
} else if(strcmp(protocol->name, "Princeton") == 0) {
|
||||
instance->history[instance->last_index_write].te =
|
||||
subghz_protocol_princeton_get_te(protocol);
|
||||
|
||||
@@ -4,20 +4,103 @@
|
||||
|
||||
typedef struct SubGhzHistory SubGhzHistory;
|
||||
|
||||
/** Allocate SubGhzHistory
|
||||
*
|
||||
* @return SubGhzHistory*
|
||||
*/
|
||||
SubGhzHistory* subghz_history_alloc(void);
|
||||
|
||||
/** Free SubGhzHistory
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
*/
|
||||
void subghz_history_free(SubGhzHistory* instance);
|
||||
|
||||
/** Clear history
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
*/
|
||||
void subghz_history_clean(SubGhzHistory* instance);
|
||||
|
||||
/** Set frequency and preset to history[idx]
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @param idx - record index
|
||||
* @param frequency - frequency Hz
|
||||
* @param preset - FuriHalSubGhzPreset preset
|
||||
*/
|
||||
void subghz_history_set_frequency_preset(
|
||||
SubGhzHistory* instance,
|
||||
uint16_t idx,
|
||||
uint32_t frequency,
|
||||
FuriHalSubGhzPreset preset);
|
||||
|
||||
/** Get frequency to history[idx]
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @param idx - record index
|
||||
* @return frequency - frequency Hz
|
||||
*/
|
||||
uint32_t subghz_history_get_frequency(SubGhzHistory* instance, uint16_t idx);
|
||||
|
||||
/** Get preset to history[idx]
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @param idx - record index
|
||||
* @return preset - FuriHalSubGhzPreset preset
|
||||
*/
|
||||
FuriHalSubGhzPreset subghz_history_get_preset(SubGhzHistory* instance, uint16_t idx);
|
||||
|
||||
/** Get history index write
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @return idx - current record index
|
||||
*/
|
||||
uint16_t subghz_history_get_item(SubGhzHistory* instance);
|
||||
|
||||
/** Get type protocol to history[idx]
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @param idx - record index
|
||||
* @return type - type protocol
|
||||
*/
|
||||
uint8_t subghz_history_get_type_protocol(SubGhzHistory* instance, uint16_t idx);
|
||||
|
||||
/** Get name protocol to history[idx]
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @param idx - record index
|
||||
* @return name - const char* name protocol
|
||||
*/
|
||||
const char* subghz_history_get_name(SubGhzHistory* instance, uint16_t idx);
|
||||
|
||||
/** Get string item menu to history[idx]
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @param output - string_t output
|
||||
* @param idx - record index
|
||||
*/
|
||||
void subghz_history_get_text_item_menu(SubGhzHistory* instance, string_t output, uint16_t idx);
|
||||
void subghz_history_get_text_space_left(SubGhzHistory* instance, string_t output);
|
||||
|
||||
/** Get string the remaining number of records to history
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @param output - string_t output
|
||||
* @return bool - is FUUL
|
||||
*/
|
||||
bool subghz_history_get_text_space_left(SubGhzHistory* instance, string_t output);
|
||||
|
||||
/** Add protocol to history
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @param context - SubGhzProtocolCommon context
|
||||
*/
|
||||
void subghz_history_add_to_history(SubGhzHistory* instance, void* context);
|
||||
|
||||
/** Get SubGhzProtocolCommonLoad to load into the protocol decoder bin data
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @param idx - record index
|
||||
* @return SubGhzProtocolCommonLoad*
|
||||
*/
|
||||
SubGhzProtocolCommonLoad* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx);
|
||||
|
||||
@@ -39,9 +39,9 @@ typedef enum {
|
||||
} SubGhzHopperState;
|
||||
|
||||
static const Icon* ReceiverItemIcons[] = {
|
||||
[TYPE_PROTOCOL_UNKNOWN] = &I_quest_7x8,
|
||||
[TYPE_PROTOCOL_STATIC] = &I_unlock_7x8,
|
||||
[TYPE_PROTOCOL_DYNAMIC] = &I_lock_7x8,
|
||||
[TYPE_PROTOCOL_UNKNOWN] = &I_Quest_7x8,
|
||||
[TYPE_PROTOCOL_STATIC] = &I_Unlock_7x8,
|
||||
[TYPE_PROTOCOL_DYNAMIC] = &I_Lock_7x8,
|
||||
};
|
||||
|
||||
struct SubghzReceiver {
|
||||
@@ -53,6 +53,7 @@ struct SubghzReceiver {
|
||||
osTimerId timer;
|
||||
SubGhzHopperState hopper_state;
|
||||
uint8_t hopper_timeout;
|
||||
uint32_t event_key_sequence;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -172,44 +173,40 @@ void subghz_receiver_draw(Canvas* canvas, SubghzReceiverModel* model) {
|
||||
string_clean(str_buff);
|
||||
}
|
||||
if(scrollbar) {
|
||||
elements_scrollbar_pos(canvas, 126, 0, 49, model->idx, model->history_item);
|
||||
elements_scrollbar_pos(canvas, 128, 0, 49, model->idx, model->history_item);
|
||||
}
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
|
||||
elements_button_left(canvas, "Conf");
|
||||
if((model->real_frequency / 1000 % 10) > 4) {
|
||||
frequency = model->real_frequency + 10000;
|
||||
elements_button_left(canvas, "Config");
|
||||
canvas_draw_line(canvas, 46, 51, 125, 51);
|
||||
if(subghz_history_get_text_space_left(model->history, str_buff)) {
|
||||
canvas_draw_str(canvas, 54, 62, string_get_cstr(str_buff));
|
||||
} else {
|
||||
frequency = model->real_frequency;
|
||||
if((model->real_frequency / 1000 % 10) > 4) {
|
||||
frequency = model->real_frequency + 10000;
|
||||
} else {
|
||||
frequency = model->real_frequency;
|
||||
}
|
||||
snprintf(
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
"%03ld.%02ld",
|
||||
frequency / 1000000 % 1000,
|
||||
frequency / 10000 % 100);
|
||||
canvas_draw_str(canvas, 44, 62, buffer);
|
||||
canvas_draw_str(canvas, 79, 62, "AM");
|
||||
canvas_draw_str(canvas, 96, 62, string_get_cstr(str_buff));
|
||||
}
|
||||
snprintf(
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
"%03ld.%02ld",
|
||||
frequency / 1000000 % 1000,
|
||||
frequency / 10000 % 100);
|
||||
canvas_draw_str(canvas, 40, 62, buffer);
|
||||
canvas_draw_str(canvas, 75, 62, "AM");
|
||||
subghz_history_get_text_space_left(model->history, str_buff);
|
||||
canvas_draw_str(canvas, 94, 62, string_get_cstr(str_buff));
|
||||
canvas_draw_line(canvas, 38, 51, 125, 51);
|
||||
break;
|
||||
|
||||
case ReceiverSceneStart:
|
||||
canvas_draw_icon(canvas, 0, 0, &I_RFIDDolphinReceive_97x61);
|
||||
canvas_invert_color(canvas);
|
||||
canvas_draw_box(canvas, 80, 2, 20, 20);
|
||||
canvas_invert_color(canvas);
|
||||
canvas_draw_icon(canvas, 75, 8, &I_sub1_10px);
|
||||
canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 63, 40, "Scanning...");
|
||||
canvas_draw_str(canvas, 63, 46, "Scanning...");
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
elements_button_left(canvas, "Conf");
|
||||
canvas_invert_color(canvas);
|
||||
canvas_draw_box(canvas, 38, 52, 10, 10);
|
||||
canvas_invert_color(canvas);
|
||||
elements_button_left(canvas, "Config");
|
||||
if((model->real_frequency / 1000 % 10) > 4) {
|
||||
frequency = model->real_frequency + 10000;
|
||||
} else {
|
||||
@@ -221,11 +218,11 @@ void subghz_receiver_draw(Canvas* canvas, SubghzReceiverModel* model) {
|
||||
"%03ld.%02ld",
|
||||
frequency / 1000000 % 1000,
|
||||
frequency / 10000 % 100);
|
||||
canvas_draw_str(canvas, 40, 62, buffer);
|
||||
canvas_draw_str(canvas, 75, 62, "AM");
|
||||
canvas_draw_str(canvas, 44, 62, buffer);
|
||||
canvas_draw_str(canvas, 79, 62, "AM");
|
||||
subghz_history_get_text_space_left(model->history, str_buff);
|
||||
canvas_draw_str(canvas, 94, 62, string_get_cstr(str_buff));
|
||||
canvas_draw_line(canvas, 48, 51, 125, 51);
|
||||
canvas_draw_str(canvas, 96, 62, string_get_cstr(str_buff));
|
||||
canvas_draw_line(canvas, 46, 51, 125, 51);
|
||||
break;
|
||||
|
||||
case ReceiverSceneConfig:
|
||||
@@ -237,9 +234,12 @@ void subghz_receiver_draw(Canvas* canvas, SubghzReceiverModel* model) {
|
||||
model->real_frequency / 1000000 % 1000,
|
||||
model->real_frequency / 1000 % 1000);
|
||||
canvas_draw_str(canvas, 0, 8, buffer);
|
||||
canvas_draw_str(canvas, 0, 18, "Frequency Hopping: <OFF>");
|
||||
} else {
|
||||
canvas_draw_str(canvas, 0, 8, "Frequency: <auto>");
|
||||
canvas_draw_str(canvas, 0, 8, "Frequency: < --- >");
|
||||
canvas_draw_str(canvas, 0, 18, "Frequency Hopping: <ON>");
|
||||
}
|
||||
canvas_draw_str(canvas, 0, 28, "Modulation: <AM>");
|
||||
|
||||
elements_button_center(canvas, "Save");
|
||||
break;
|
||||
@@ -269,6 +269,13 @@ void subghz_receiver_draw(Canvas* canvas, SubghzReceiverModel* model) {
|
||||
string_clear(str_buff);
|
||||
}
|
||||
|
||||
void subghz_receiver_history_full(void* context) {
|
||||
furi_assert(context);
|
||||
SubghzReceiver* subghz_receiver = context;
|
||||
subghz_receiver->callback(SubghzReceverEventSendHistoryFull, subghz_receiver->context);
|
||||
subghz_receiver->hopper_state = SubGhzHopperStateOFF;
|
||||
}
|
||||
|
||||
bool subghz_receiver_input(InputEvent* event, void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
@@ -280,13 +287,11 @@ bool subghz_receiver_input(InputEvent* event, void* context) {
|
||||
return false;
|
||||
});
|
||||
|
||||
if(scene != ReceiverSceneInfo && event->type != InputTypeShort) return false;
|
||||
|
||||
bool can_be_saved = false;
|
||||
|
||||
switch(scene) {
|
||||
case ReceiverSceneMain:
|
||||
if(event->key == InputKeyBack) {
|
||||
if(event->key == InputKeyBack && event->type == InputTypeShort) {
|
||||
with_view_model(
|
||||
subghz_receiver->view, (SubghzReceiverModel * model) {
|
||||
model->idx = 0;
|
||||
@@ -296,19 +301,23 @@ bool subghz_receiver_input(InputEvent* event, void* context) {
|
||||
return true;
|
||||
});
|
||||
return false;
|
||||
} else if(event->key == InputKeyUp) {
|
||||
} else if(
|
||||
event->key == InputKeyUp &&
|
||||
(event->type == InputTypeShort || event->type == InputTypeRepeat)) {
|
||||
with_view_model(
|
||||
subghz_receiver->view, (SubghzReceiverModel * model) {
|
||||
if(model->idx != 0) model->idx--;
|
||||
return true;
|
||||
});
|
||||
} else if(event->key == InputKeyDown) {
|
||||
} else if(
|
||||
event->key == InputKeyDown &&
|
||||
(event->type == InputTypeShort || event->type == InputTypeRepeat)) {
|
||||
with_view_model(
|
||||
subghz_receiver->view, (SubghzReceiverModel * model) {
|
||||
if(model->idx != subghz_history_get_item(model->history) - 1) model->idx++;
|
||||
return true;
|
||||
});
|
||||
} else if(event->key == InputKeyLeft) {
|
||||
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
|
||||
subghz_receiver->hopper_state = SubGhzHopperStatePause;
|
||||
with_view_model(
|
||||
subghz_receiver->view, (SubghzReceiverModel * model) {
|
||||
@@ -317,7 +326,8 @@ bool subghz_receiver_input(InputEvent* event, void* context) {
|
||||
return true;
|
||||
});
|
||||
subghz_receiver->callback(SubghzReceverEventConfig, subghz_receiver->context);
|
||||
} else if(event->key == InputKeyOk) {
|
||||
} else if(event->key == InputKeyOk && event->type == InputTypeShort) {
|
||||
subghz_receiver->event_key_sequence = event->sequence;
|
||||
with_view_model(
|
||||
subghz_receiver->view, (SubghzReceiverModel * model) {
|
||||
string_clean(model->text);
|
||||
@@ -358,18 +368,23 @@ bool subghz_receiver_input(InputEvent* event, void* context) {
|
||||
} else if(can_be_saved && event->key == InputKeyRight) {
|
||||
subghz_receiver->callback(SubghzReceverEventSave, subghz_receiver->context);
|
||||
return false;
|
||||
} else if(can_be_saved && event->key == InputKeyOk && event->type == InputTypePress) {
|
||||
} else if(
|
||||
can_be_saved && event->key == InputKeyOk && event->type == InputTypePress &&
|
||||
subghz_receiver->event_key_sequence != event->sequence) {
|
||||
subghz_receiver->hopper_state = SubGhzHopperStatePause;
|
||||
subghz_rx_end(subghz_receiver->worker);
|
||||
subghz_receiver->callback(SubghzReceverEventSendStart, subghz_receiver->context);
|
||||
return true;
|
||||
} else if(can_be_saved && event->key == InputKeyOk && event->type == InputTypeRelease) {
|
||||
} else if(
|
||||
can_be_saved && event->key == InputKeyOk && event->type == InputTypeRelease &&
|
||||
subghz_receiver->event_key_sequence != event->sequence) {
|
||||
subghz_receiver->callback(SubghzReceverEventSendStop, subghz_receiver->context);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case ReceiverSceneConfig:
|
||||
if(event->type != InputTypeShort) return false;
|
||||
if(event->key == InputKeyBack) {
|
||||
with_view_model(
|
||||
subghz_receiver->view, (SubghzReceiverModel * model) {
|
||||
@@ -396,7 +411,6 @@ bool subghz_receiver_input(InputEvent* event, void* context) {
|
||||
osTimerStart(subghz_receiver->timer, 1024 / 10);
|
||||
subghz_receiver->hopper_state = SubGhzHopperStateRunnig;
|
||||
}
|
||||
|
||||
if(subghz_history_get_item(model->history) == 0) {
|
||||
model->scene = ReceiverSceneStart;
|
||||
} else {
|
||||
@@ -426,6 +440,7 @@ bool subghz_receiver_input(InputEvent* event, void* context) {
|
||||
break;
|
||||
|
||||
case ReceiverSceneStart:
|
||||
if(event->type != InputTypeShort) return false;
|
||||
if(event->key == InputKeyBack) {
|
||||
return false;
|
||||
} else if(event->key == InputKeyLeft) {
|
||||
@@ -445,6 +460,16 @@ bool subghz_receiver_input(InputEvent* event, void* context) {
|
||||
}
|
||||
|
||||
subghz_receiver_update_offset(subghz_receiver);
|
||||
if(scene != ReceiverSceneInfo) {
|
||||
with_view_model(
|
||||
subghz_receiver->view, (SubghzReceiverModel * model) {
|
||||
if(subghz_history_get_text_space_left(model->history, NULL)) {
|
||||
subghz_receiver_history_full(subghz_receiver);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -476,6 +501,9 @@ void subghz_receiver_protocol_callback(SubGhzProtocolCommon* parser, void* conte
|
||||
|
||||
model->history_item = subghz_history_get_item(model->history);
|
||||
model->scene = ReceiverSceneMain;
|
||||
if(subghz_history_get_text_space_left(model->history, NULL)) {
|
||||
subghz_receiver_history_full(subghz_receiver);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
subghz_protocol_reset(subghz_receiver->protocol);
|
||||
@@ -528,10 +556,11 @@ static void subghz_receiver_timer_callback(void* context) {
|
||||
}
|
||||
|
||||
// Restart radio
|
||||
subghz_rx_end(subghz_receiver->worker);
|
||||
furi_hal_subghz_idle();
|
||||
subghz_protocol_reset(subghz_receiver->protocol);
|
||||
model->real_frequency =
|
||||
subghz_rx(subghz_receiver->worker, subghz_frequencies_hopper[model->frequency]);
|
||||
model->real_frequency = furi_hal_subghz_set_frequency_and_path(
|
||||
subghz_frequencies_hopper[model->frequency]);
|
||||
furi_hal_subghz_rx();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -14,7 +14,8 @@ typedef enum {
|
||||
SubghzReceverEventBack,
|
||||
SubghzReceverEventMore,
|
||||
SubghzReceverEventSendStart,
|
||||
SubghzReceverEventSendStop
|
||||
SubghzReceverEventSendStop,
|
||||
SubghzReceverEventSendHistoryFull,
|
||||
} SubghzReceverEvent;
|
||||
|
||||
typedef struct SubghzReceiver SubghzReceiver;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <input/input.h>
|
||||
#include <gui/elements.h>
|
||||
#include <notification/notification-messages.h>
|
||||
#include <lib/subghz/protocols/subghz_protocol_keeloq.h>
|
||||
|
||||
struct SubghzTransmitter {
|
||||
View* view;
|
||||
@@ -100,6 +101,10 @@ void subghz_transmitter_draw(Canvas* canvas, SubghzTransmitterModel* model) {
|
||||
canvas_draw_str(canvas, 90, 8, buffer);
|
||||
|
||||
if(model->protocol && model->protocol->get_upload_protocol) {
|
||||
if((!strcmp(model->protocol->name, "KeeLoq")) &&
|
||||
(!strcmp(subghz_protocol_keeloq_get_manufacture_name(model->protocol), "Unknown"))) {
|
||||
return;
|
||||
}
|
||||
subghz_transmitter_button_right(canvas, "Send");
|
||||
}
|
||||
}
|
||||
@@ -107,22 +112,33 @@ void subghz_transmitter_draw(Canvas* canvas, SubghzTransmitterModel* model) {
|
||||
bool subghz_transmitter_input(InputEvent* event, void* context) {
|
||||
furi_assert(context);
|
||||
SubghzTransmitter* subghz_transmitter = context;
|
||||
bool can_be_send = false;
|
||||
bool can_be_sent = false;
|
||||
|
||||
if(event->key == InputKeyBack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
with_view_model(
|
||||
subghz_transmitter->view, (SubghzTransmitterModel * model) {
|
||||
can_be_send = (model->protocol && model->protocol->get_upload_protocol);
|
||||
if(model->protocol && model->protocol->get_upload_protocol) {
|
||||
if((!strcmp(model->protocol->name, "KeeLoq")) &&
|
||||
(!strcmp(
|
||||
subghz_protocol_keeloq_get_manufacture_name(model->protocol), "Unknown"))) {
|
||||
return false;
|
||||
}
|
||||
can_be_sent = true;
|
||||
}
|
||||
//can_be_sent = (model->protocol && model->protocol->get_upload_protocol);
|
||||
string_clean(model->text);
|
||||
model->protocol->to_string(model->protocol, model->text);
|
||||
return true;
|
||||
});
|
||||
//if(event->type != InputTypeShort) return false;
|
||||
|
||||
if(event->key == InputKeyBack) {
|
||||
return false;
|
||||
} else if(can_be_send && event->key == InputKeyOk && event->type == InputTypePress) {
|
||||
if(can_be_sent && event->key == InputKeyOk && event->type == InputTypePress) {
|
||||
subghz_transmitter->callback(SubghzTransmitterEventSendStart, subghz_transmitter->context);
|
||||
return true;
|
||||
} else if(can_be_send && event->key == InputKeyOk && event->type == InputTypeRelease) {
|
||||
} else if(can_be_sent && event->key == InputKeyOk && event->type == InputTypeRelease) {
|
||||
subghz_transmitter->callback(SubghzTransmitterEventSendStop, subghz_transmitter->context);
|
||||
return true;
|
||||
}
|
||||
@@ -147,6 +163,7 @@ void subghz_transmitter_enter(void* context) {
|
||||
SubghzTransmitter* subghz_transmitter = context;
|
||||
with_view_model(
|
||||
subghz_transmitter->view, (SubghzTransmitterModel * model) {
|
||||
string_clean(model->text);
|
||||
model->protocol->to_string(model->protocol, model->text);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ typedef enum {
|
||||
SubghzTransmitterEventSendStart,
|
||||
SubghzTransmitterEventSendStop,
|
||||
SubghzTransmitterEventBack,
|
||||
SubghzTransmitterEventNoMan,
|
||||
} SubghzTransmitterEvent;
|
||||
|
||||
typedef struct SubghzTransmitter SubghzTransmitter;
|
||||
|
||||
Reference in New Issue
Block a user