flipperzero-firmware/applications/main/subghz/scenes/subghz_scene_transmitter.c

109 lines
4.3 KiB
C
Raw Normal View History

2021-08-12 14:42:56 +00:00
#include "../subghz_i.h"
#include "../views/transmitter.h"
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965) * Desktop: cleanup headers * Get loader pubsub via record * [FL-2183] Dolphin refactoring 2022.01 * Restruct animations assets structure * Rename assets * Cleanup headers * Update Recording animation * Add BadBattery animation * Provide loader's pubsub via record * Fix load/unload animations * Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin. * Sync internal meta.txt and manifest.txt * Reorder, rename dolphin assets * Split essential generated assets * Add ReadMe for dolphin assets * Separate essential blocking animations * Scripts: full dolphin validation before packaging * Assets, Scripts: dolphin external resources packer * Github: update codeowners * Scripts: proper slots handling in dolphin animation meta * Scripts: correct frames enumeration and fix compiled assets. * [FL-2209] Add Dolphin Deeds points and many more * Remove excess frame_rate * Change dolphin assets directory * Scripts: add internal resource support to dolphin compiler * Scripts: add internal assets generation, renaming * Scripts: correct assert, renaming * Code cleanup, documentation, fixes * Update Levelup animations * Rename essential -> blocking * Fix Unlocked hint * Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates. * Documentation: add key combos description and use information * Scripts: cleanup templit, more debug info and add dev comment Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 09:20:41 +00:00
#include <dolphin/dolphin.h>
2021-08-12 14:42:56 +00:00
void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) {
2021-08-12 14:42:56 +00:00
furi_assert(context);
SubGhz* subghz = context;
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
}
bool subghz_scene_transmitter_update_data_show(void* context) {
2021-08-12 14:42:56 +00:00
SubGhz* subghz = context;
bool ret = false;
if(subghz->txrx->decoder_result) {
FuriString* key_str;
FuriString* frequency_str;
FuriString* modulation_str;
key_str = furi_string_alloc();
frequency_str = furi_string_alloc();
modulation_str = furi_string_alloc();
uint8_t show_button = 0;
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646) * SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited * SubGhz: Fix displaying Nice FlorS in the Raed scene * SubGhz: Fix displaying Faac SLH in the Raed scene * SubGhz: Fix displaying iDo in the Raed scene * SubGhz: Fix displaying Star Line in the Raed scene * SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control) * SubGhz: subghz_beginadded common encoder upload signal * SubGhz: add Came encoder * SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder * SubGhz: add nice flo encoder, need testing no remote control * SubGhz: add gate_tx encoder * SubGhz: add nero_sketch encoder * SubGhz: add keelog encoder * SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions) * SubGhz: fix max upload * SubGhz: Fix structure subghz add encoder * SubGhz: add generating and sending a dynamic keelog key, refactoring the code * SubGhz: add notifications * SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan) * SubGhz: Fix load file, fix scene start * Subghz: Fix show key * SubGhz: Fix subghz_cli * SubGhz: Fix furi-hal-subghz * Format sources * SubGhz: standard notification scheme, fix broken assert in DMA. * SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
if(subghz_protocol_decoder_base_deserialize(
subghz->txrx->decoder_result, subghz->txrx->fff_data) == SubGhzProtocolStatusOk) {
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, key_str);
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646) * SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited * SubGhz: Fix displaying Nice FlorS in the Raed scene * SubGhz: Fix displaying Faac SLH in the Raed scene * SubGhz: Fix displaying iDo in the Raed scene * SubGhz: Fix displaying Star Line in the Raed scene * SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control) * SubGhz: subghz_beginadded common encoder upload signal * SubGhz: add Came encoder * SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder * SubGhz: add nice flo encoder, need testing no remote control * SubGhz: add gate_tx encoder * SubGhz: add nero_sketch encoder * SubGhz: add keelog encoder * SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions) * SubGhz: fix max upload * SubGhz: Fix structure subghz add encoder * SubGhz: add generating and sending a dynamic keelog key, refactoring the code * SubGhz: add notifications * SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan) * SubGhz: Fix load file, fix scene start * Subghz: Fix show key * SubGhz: Fix subghz_cli * SubGhz: Fix furi-hal-subghz * Format sources * SubGhz: standard notification scheme, fix broken assert in DMA. * SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Send) ==
SubGhzProtocolFlag_Send) {
show_button = 1;
}
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
subghz_view_transmitter_add_data_to_show(
subghz->subghz_transmitter,
furi_string_get_cstr(key_str),
furi_string_get_cstr(frequency_str),
furi_string_get_cstr(modulation_str),
show_button);
ret = true;
}
furi_string_free(frequency_str);
furi_string_free(modulation_str);
furi_string_free(key_str);
}
return ret;
}
void subghz_scene_transmitter_on_enter(void* context) {
SubGhz* subghz = context;
if(!subghz_scene_transmitter_update_data_show(subghz)) {
view_dispatcher_send_custom_event(
subghz->view_dispatcher, SubGhzCustomEventViewTransmitterError);
}
subghz_view_transmitter_set_callback(
subghz->subghz_transmitter, subghz_scene_transmitter_callback, subghz);
subghz->state_notifications = SubGhzNotificationStateIDLE;
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTransmitter);
2021-08-12 14:42:56 +00:00
}
bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
2021-08-12 14:42:56 +00:00
SubGhz* subghz = context;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzCustomEventViewTransmitterSendStart) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
subghz_rx_end(subghz);
}
if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) ||
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
if(subghz_tx_start(subghz, subghz->txrx->fff_data)) {
subghz->state_notifications = SubGhzNotificationStateTx;
subghz_scene_transmitter_update_data_show(subghz);
DOLPHIN_DEED(DolphinDeedSubGhzSend);
}
}
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646) * SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited * SubGhz: Fix displaying Nice FlorS in the Raed scene * SubGhz: Fix displaying Faac SLH in the Raed scene * SubGhz: Fix displaying iDo in the Raed scene * SubGhz: Fix displaying Star Line in the Raed scene * SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control) * SubGhz: subghz_beginadded common encoder upload signal * SubGhz: add Came encoder * SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder * SubGhz: add nice flo encoder, need testing no remote control * SubGhz: add gate_tx encoder * SubGhz: add nero_sketch encoder * SubGhz: add keelog encoder * SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions) * SubGhz: fix max upload * SubGhz: Fix structure subghz add encoder * SubGhz: add generating and sending a dynamic keelog key, refactoring the code * SubGhz: add notifications * SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan) * SubGhz: Fix load file, fix scene start * Subghz: Fix show key * SubGhz: Fix subghz_cli * SubGhz: Fix furi-hal-subghz * Format sources * SubGhz: standard notification scheme, fix broken assert in DMA. * SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
return true;
} else if(event.event == SubGhzCustomEventViewTransmitterSendStop) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
subghz_tx_stop(subghz);
subghz_sleep(subghz);
}
2021-08-12 14:42:56 +00:00
return true;
} else if(event.event == SubGhzCustomEventViewTransmitterBack) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
2021-08-12 14:42:56 +00:00
scene_manager_search_and_switch_to_previous_scene(
subghz->scene_manager, SubGhzSceneStart);
return true;
} else if(event.event == SubGhzCustomEventViewTransmitterError) {
furi_string_set(subghz->error_str, "Protocol not\nfound!");
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
2021-08-12 14:42:56 +00:00
}
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646) * SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited * SubGhz: Fix displaying Nice FlorS in the Raed scene * SubGhz: Fix displaying Faac SLH in the Raed scene * SubGhz: Fix displaying iDo in the Raed scene * SubGhz: Fix displaying Star Line in the Raed scene * SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control) * SubGhz: subghz_beginadded common encoder upload signal * SubGhz: add Came encoder * SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder * SubGhz: add nice flo encoder, need testing no remote control * SubGhz: add gate_tx encoder * SubGhz: add nero_sketch encoder * SubGhz: add keelog encoder * SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions) * SubGhz: fix max upload * SubGhz: Fix structure subghz add encoder * SubGhz: add generating and sending a dynamic keelog key, refactoring the code * SubGhz: add notifications * SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan) * SubGhz: Fix load file, fix scene start * Subghz: Fix show key * SubGhz: Fix subghz_cli * SubGhz: Fix furi-hal-subghz * Format sources * SubGhz: standard notification scheme, fix broken assert in DMA. * SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
} else if(event.type == SceneManagerEventTypeTick) {
if(subghz->state_notifications == SubGhzNotificationStateTx) {
notification_message(subghz->notifications, &sequence_blink_magenta_10);
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646) * SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited * SubGhz: Fix displaying Nice FlorS in the Raed scene * SubGhz: Fix displaying Faac SLH in the Raed scene * SubGhz: Fix displaying iDo in the Raed scene * SubGhz: Fix displaying Star Line in the Raed scene * SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control) * SubGhz: subghz_beginadded common encoder upload signal * SubGhz: add Came encoder * SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder * SubGhz: add nice flo encoder, need testing no remote control * SubGhz: add gate_tx encoder * SubGhz: add nero_sketch encoder * SubGhz: add keelog encoder * SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions) * SubGhz: fix max upload * SubGhz: Fix structure subghz add encoder * SubGhz: add generating and sending a dynamic keelog key, refactoring the code * SubGhz: add notifications * SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan) * SubGhz: Fix load file, fix scene start * Subghz: Fix show key * SubGhz: Fix subghz_cli * SubGhz: Fix furi-hal-subghz * Format sources * SubGhz: standard notification scheme, fix broken assert in DMA. * SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
}
return true;
2021-08-12 14:42:56 +00:00
}
return false;
}
void subghz_scene_transmitter_on_exit(void* context) {
2021-08-12 14:42:56 +00:00
SubGhz* subghz = context;
subghz->state_notifications = SubGhzNotificationStateIDLE;
2021-08-12 14:42:56 +00:00
}