[FL-1610] SubGhz: scene based application, PT save and replay (#630)
* SubGhz: scene based application * SubGhz: encoder/decoder separation, DMA streaming, update app and cli. * SubGhz: 2 stage async tx complete, minor cleanup * SubGhz: 2 stage async tx complete, FIX state pin end transmit * SubGhz: Pricenton, receive TE signal * SubGhz: Pricenton, add save data, add load data * SubGhz: Add Read scene, Fix pricenton save, load funtion * SubGhz: Add Read, Receiver, SaveName scene * SubGhz: Read and Save (pricenton) * SubGhz: add Load scence * SubGhz: Fix select file scene, add load scene, add transmitter view, add send tx pricenton * SubGhz: Fix pricenton encoder, fix transmitter send * SubGhz: modified Pricenton Encoder (added guard time at the beginning), modified CC1101 config, code refactoring * SubGhz: Fix pricenton encoder defalut TE * Archive: Fix path and name SubGhz * Archive: Fix name app SubGhz * GubGhz: Came: add Save, Load key * GubGhz: GateTX: add Save, Load key * GubGhz: NeroSketch: add Save, Load key * Github: better linters triggers * SubGhz: adding fast loading keys Archive -> Run in app * GubGhz: KeeLog: add Save, Load key, key generation from the serial number of the meter and the button * SubGhz: format sources and fix compilation * FuriHal: add subghz configuration description for AGC section * SubGhz: save only protocols that can be saved. Cleanup. * Github: lint on pull requests Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -6,20 +6,18 @@
|
||||
#include <furi-hal.h>
|
||||
#include <input/input.h>
|
||||
#include <notification/notification-messages.h>
|
||||
#include <lib/subghz/protocols/subghz_protocol_princeton.h>
|
||||
|
||||
static const uint8_t subghz_static_keys[][4] = {
|
||||
{0x74, 0xBA, 0xDE},
|
||||
{0x74, 0xBA, 0xDD},
|
||||
{0x74, 0xBA, 0xDB},
|
||||
{0xE3, 0x4A, 0x4E},
|
||||
static const uint32_t subghz_static_keys[] = {
|
||||
0x0074BADE,
|
||||
0x0074BADD,
|
||||
0x0074BADB,
|
||||
0x00E34A4E,
|
||||
};
|
||||
|
||||
#define SUBGHZ_PT_SHORT 376
|
||||
#define SUBGHZ_PT_LONG (SUBGHZ_PT_SHORT * 3)
|
||||
#define SUBGHZ_PT_GUARD 10600
|
||||
|
||||
struct SubghzStatic {
|
||||
View* view;
|
||||
SubGhzEncoderPrinceton* encoder;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@@ -56,14 +54,14 @@ void subghz_static_draw(Canvas* canvas, SubghzStaticModel* model) {
|
||||
|
||||
bool subghz_static_input(InputEvent* event, void* context) {
|
||||
furi_assert(context);
|
||||
SubghzStatic* subghz_static = context;
|
||||
SubghzStatic* instance = context;
|
||||
|
||||
if(event->key == InputKeyBack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
with_view_model(
|
||||
subghz_static->view, (SubghzStaticModel * model) {
|
||||
instance->view, (SubghzStaticModel * model) {
|
||||
bool reconfigure = false;
|
||||
if(event->type == InputTypeShort) {
|
||||
if(event->key == InputKeyLeft) {
|
||||
@@ -88,31 +86,16 @@ bool subghz_static_input(InputEvent* event, void* context) {
|
||||
|
||||
if(event->key == InputKeyOk) {
|
||||
if(event->type == InputTypePress) {
|
||||
const uint8_t* key = subghz_static_keys[model->button];
|
||||
|
||||
NotificationApp* notification = furi_record_open("notification");
|
||||
notification_message_block(notification, &sequence_set_red_255);
|
||||
__disable_irq();
|
||||
for(uint8_t r = 0; r < 20; r++) {
|
||||
//Payload
|
||||
for(uint8_t i = 0; i < 24; i++) {
|
||||
uint8_t byte = i / 8;
|
||||
uint8_t bit = i % 8;
|
||||
bool value = (key[byte] >> (7 - bit)) & 1;
|
||||
// Payload send
|
||||
hal_gpio_write(&gpio_cc1101_g0, true);
|
||||
delay_us(value ? SUBGHZ_PT_SHORT : SUBGHZ_PT_LONG);
|
||||
hal_gpio_write(&gpio_cc1101_g0, false);
|
||||
delay_us(value ? SUBGHZ_PT_LONG : SUBGHZ_PT_SHORT);
|
||||
}
|
||||
// Last bit
|
||||
hal_gpio_write(&gpio_cc1101_g0, true);
|
||||
delay_us(SUBGHZ_PT_SHORT);
|
||||
hal_gpio_write(&gpio_cc1101_g0, false);
|
||||
// Guard time
|
||||
delay_us(10600);
|
||||
}
|
||||
__enable_irq();
|
||||
|
||||
subghz_encoder_princeton_reset(
|
||||
instance->encoder, subghz_static_keys[model->button], 20);
|
||||
furi_hal_subghz_start_async_tx(
|
||||
subghz_encoder_princeton_yield, instance->encoder);
|
||||
while(!furi_hal_subghz_is_async_tx_complete()) osDelay(33);
|
||||
furi_hal_subghz_stop_async_tx();
|
||||
|
||||
notification_message(notification, &sequence_reset_red);
|
||||
furi_record_close("notification");
|
||||
}
|
||||
@@ -126,7 +109,7 @@ bool subghz_static_input(InputEvent* event, void* context) {
|
||||
|
||||
void subghz_static_enter(void* context) {
|
||||
furi_assert(context);
|
||||
SubghzStatic* subghz_static = context;
|
||||
SubghzStatic* instance = context;
|
||||
|
||||
furi_hal_subghz_reset();
|
||||
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOokAsync);
|
||||
@@ -135,7 +118,7 @@ void subghz_static_enter(void* context) {
|
||||
hal_gpio_write(&gpio_cc1101_g0, false);
|
||||
|
||||
with_view_model(
|
||||
subghz_static->view, (SubghzStaticModel * model) {
|
||||
instance->view, (SubghzStaticModel * model) {
|
||||
model->frequency = subghz_frequencies_433_92;
|
||||
model->real_frequency =
|
||||
furi_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]);
|
||||
@@ -148,39 +131,34 @@ void subghz_static_enter(void* context) {
|
||||
|
||||
void subghz_static_exit(void* context) {
|
||||
furi_assert(context);
|
||||
// SubghzStatic* subghz_static = context;
|
||||
|
||||
// Reinitialize IC to default state
|
||||
furi_hal_subghz_sleep();
|
||||
}
|
||||
|
||||
uint32_t subghz_static_back(void* context) {
|
||||
return SubGhzViewMenu;
|
||||
}
|
||||
|
||||
SubghzStatic* subghz_static_alloc() {
|
||||
SubghzStatic* subghz_static = furi_alloc(sizeof(SubghzStatic));
|
||||
SubghzStatic* instance = furi_alloc(sizeof(SubghzStatic));
|
||||
|
||||
// View allocation and configuration
|
||||
subghz_static->view = view_alloc();
|
||||
view_allocate_model(subghz_static->view, ViewModelTypeLockFree, sizeof(SubghzStaticModel));
|
||||
view_set_context(subghz_static->view, subghz_static);
|
||||
view_set_draw_callback(subghz_static->view, (ViewDrawCallback)subghz_static_draw);
|
||||
view_set_input_callback(subghz_static->view, subghz_static_input);
|
||||
view_set_enter_callback(subghz_static->view, subghz_static_enter);
|
||||
view_set_exit_callback(subghz_static->view, subghz_static_exit);
|
||||
view_set_previous_callback(subghz_static->view, subghz_static_back);
|
||||
instance->view = view_alloc();
|
||||
view_allocate_model(instance->view, ViewModelTypeLockFree, sizeof(SubghzStaticModel));
|
||||
view_set_context(instance->view, instance);
|
||||
view_set_draw_callback(instance->view, (ViewDrawCallback)subghz_static_draw);
|
||||
view_set_input_callback(instance->view, subghz_static_input);
|
||||
view_set_enter_callback(instance->view, subghz_static_enter);
|
||||
view_set_exit_callback(instance->view, subghz_static_exit);
|
||||
|
||||
return subghz_static;
|
||||
instance->encoder = subghz_encoder_princeton_alloc();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_static_free(SubghzStatic* subghz_static) {
|
||||
furi_assert(subghz_static);
|
||||
view_free(subghz_static->view);
|
||||
free(subghz_static);
|
||||
void subghz_static_free(SubghzStatic* instance) {
|
||||
furi_assert(instance);
|
||||
subghz_encoder_princeton_free(instance->encoder);
|
||||
view_free(instance->view);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
View* subghz_static_get_view(SubghzStatic* subghz_static) {
|
||||
furi_assert(subghz_static);
|
||||
return subghz_static->view;
|
||||
View* subghz_static_get_view(SubghzStatic* instance) {
|
||||
furi_assert(instance);
|
||||
return instance->view;
|
||||
}
|
||||
|
Reference in New Issue
Block a user