unleashed-firmware/applications/subghz/views/subghz_test_static.c

160 lines
5.0 KiB
C
Raw Normal View History

#include "subghz_test_static.h"
#include "../subghz_i.h"
#include <math.h>
#include <furi.h>
2021-08-08 21:03:25 +03:00
#include <furi-hal.h>
#include <input/input.h>
[FL-1237] Notifications app (#476) * Notification app: init * Notification app: separate message sequences * Notification app: rename notifications to notification * Notification app: rework api * Notification app: new sequences for charger * Power app: add state for better led handling * Power app: NotificationSequence type, notification led process * Blink app: use notifications * Notification app: sound and vibro notifications * Notification app: note messages * Notification app: more messages * Notification app: update note message generator * Blink app: fix state counter * Notification app: fix delay event * App sd-filesystem: notifications * App notifications: headers c++ compatibility * App notifications: Cmaj success chord sequence * App iButton: use notifications * App notification: display backlight notifications * App notification: add "display on" message to success and error sequences * App accessor: use notifications * App ibutton: guard onewire key read * Lib-RFAL: remove api_hal_light usage * App notification: add blocking mode, rework display api * Cli led command: use internal notification instead of direc access to leds. * App unit test: use notifications * App lfrfid: use notifications * Apps: close notification record * App subghz: rough use of notifications * App notificaton: ignore reset flag * App strobe: removed * Lib irda decoder: fix nec decoding * App irda: fix assert, use notifications * Apps: use notifications * Fix IRDA tests * Cli: better var naming * App notification: readable sources Co-authored-by: Albert Kharisov <albert@flipperdevices.com> Co-authored-by: あく <alleteam@gmail.com>
2021-05-24 16:44:14 +03:00
#include <notification/notification-messages.h>
2021-08-12 17:42:56 +03:00
#include <lib/subghz/protocols/subghz_protocol_princeton.h>
static const uint32_t subghz_test_static_keys[] = {
2021-08-12 17:42:56 +03:00
0x0074BADE,
0x0074BADD,
0x0074BADB,
0x00E34A4E,
};
struct SubghzTestStatic {
View* view;
2021-08-12 17:42:56 +03:00
SubGhzEncoderPrinceton* encoder;
};
typedef enum {
SubghzTestStaticStatusRx,
SubghzTestStaticStatusTx,
} SubghzTestStaticStatus;
typedef struct {
uint8_t frequency;
uint32_t real_frequency;
uint8_t button;
} SubghzTestStaticModel;
void subghz_test_static_draw(Canvas* canvas, SubghzTestStaticModel* model) {
char buffer[64];
canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 0, 8, "CC1101 Static");
canvas_set_font(canvas, FontSecondary);
// Frequency
snprintf(
buffer,
sizeof(buffer),
"Freq: %03ld.%03ld.%03ld Hz",
model->real_frequency / 1000000 % 1000,
model->real_frequency / 1000 % 1000,
model->real_frequency % 1000);
canvas_draw_str(canvas, 0, 20, buffer);
snprintf(buffer, sizeof(buffer), "Key: %d", model->button);
canvas_draw_str(canvas, 0, 31, buffer);
}
bool subghz_test_static_input(InputEvent* event, void* context) {
furi_assert(context);
SubghzTestStatic* instance = context;
if(event->key == InputKeyBack) {
return false;
}
with_view_model(
instance->view, (SubghzTestStaticModel * model) {
if(event->type == InputTypeShort) {
if(event->key == InputKeyLeft) {
if(model->frequency > 0) model->frequency--;
} else if(event->key == InputKeyRight) {
if(model->frequency < subghz_frequencies_count - 1) model->frequency++;
} else if(event->key == InputKeyDown) {
if(model->button > 0) model->button--;
} else if(event->key == InputKeyUp) {
if(model->button < 3) model->button++;
}
}
model->real_frequency = subghz_frequencies[model->frequency];
if(event->key == InputKeyOk) {
NotificationApp* notification = furi_record_open("notification");
if(event->type == InputTypePress) {
[FL-1237] Notifications app (#476) * Notification app: init * Notification app: separate message sequences * Notification app: rename notifications to notification * Notification app: rework api * Notification app: new sequences for charger * Power app: add state for better led handling * Power app: NotificationSequence type, notification led process * Blink app: use notifications * Notification app: sound and vibro notifications * Notification app: note messages * Notification app: more messages * Notification app: update note message generator * Blink app: fix state counter * Notification app: fix delay event * App sd-filesystem: notifications * App notifications: headers c++ compatibility * App notifications: Cmaj success chord sequence * App iButton: use notifications * App notification: display backlight notifications * App notification: add "display on" message to success and error sequences * App accessor: use notifications * App ibutton: guard onewire key read * Lib-RFAL: remove api_hal_light usage * App notification: add blocking mode, rework display api * Cli led command: use internal notification instead of direc access to leds. * App unit test: use notifications * App lfrfid: use notifications * Apps: close notification record * App subghz: rough use of notifications * App notificaton: ignore reset flag * App strobe: removed * Lib irda decoder: fix nec decoding * App irda: fix assert, use notifications * Apps: use notifications * Fix IRDA tests * Cli: better var naming * App notification: readable sources Co-authored-by: Albert Kharisov <albert@flipperdevices.com> Co-authored-by: あく <alleteam@gmail.com>
2021-05-24 16:44:14 +03:00
notification_message_block(notification, &sequence_set_red_255);
2021-08-12 17:42:56 +03:00
FURI_LOG_I("SubghzTestStatic", "TX Start");
furi_hal_subghz_idle();
furi_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]);
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 22:56:23 +03:00
subghz_encoder_princeton_set(
instance->encoder, subghz_test_static_keys[model->button], 10000);
2021-08-12 17:42:56 +03:00
furi_hal_subghz_start_async_tx(
subghz_encoder_princeton_yield, instance->encoder);
} else if(event->type == InputTypeRelease) {
FURI_LOG_I("SubghzTestStatic", "TX Stop");
2021-08-12 17:42:56 +03:00
furi_hal_subghz_stop_async_tx();
[FL-1237] Notifications app (#476) * Notification app: init * Notification app: separate message sequences * Notification app: rename notifications to notification * Notification app: rework api * Notification app: new sequences for charger * Power app: add state for better led handling * Power app: NotificationSequence type, notification led process * Blink app: use notifications * Notification app: sound and vibro notifications * Notification app: note messages * Notification app: more messages * Notification app: update note message generator * Blink app: fix state counter * Notification app: fix delay event * App sd-filesystem: notifications * App notifications: headers c++ compatibility * App notifications: Cmaj success chord sequence * App iButton: use notifications * App notification: display backlight notifications * App notification: add "display on" message to success and error sequences * App accessor: use notifications * App ibutton: guard onewire key read * Lib-RFAL: remove api_hal_light usage * App notification: add blocking mode, rework display api * Cli led command: use internal notification instead of direc access to leds. * App unit test: use notifications * App lfrfid: use notifications * Apps: close notification record * App subghz: rough use of notifications * App notificaton: ignore reset flag * App strobe: removed * Lib irda decoder: fix nec decoding * App irda: fix assert, use notifications * Apps: use notifications * Fix IRDA tests * Cli: better var naming * App notification: readable sources Co-authored-by: Albert Kharisov <albert@flipperdevices.com> Co-authored-by: あく <alleteam@gmail.com>
2021-05-24 16:44:14 +03:00
notification_message(notification, &sequence_reset_red);
}
furi_record_close("notification");
}
return true;
});
return true;
}
void subghz_test_static_enter(void* context) {
furi_assert(context);
SubghzTestStatic* instance = context;
2021-08-08 21:03:25 +03:00
furi_hal_subghz_reset();
Skorp subghz signal archive (#667) * SubGhz: Add millis() furi, add subghz history struct * SubGhz: Fix subghz history * Gubghz: Fix code repeat history, add clean history * SubGhz: reading and adding keys to history * Gui: Renaming Sub 1-Ghz -> SubGhz * Archive: Renaming Sub 1-Ghz -> SubGhz * SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol * Archive: Fix name subghz * SubGhz: Menu navigation * Assets: Add assets/SubGHz/icon.png * Assets: add new icons for subghz * SubGhz: Fix name Add manually scene * SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol * SubGhz: fix memory leak * SubGhz: change of receiving frequency for read scene * SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene * SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser * Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter * Fix formatting and release build * SubGhz: Delete read scene * SubGhz: Fix frequency add manualli scene, refactoring code * SubGhz: 2 profiles for OOK, fix broken build. * SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code * SubGhz: fix assert on worker double stop. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
2021-05-08 22:24:05 +03:00
hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
hal_gpio_write(&gpio_cc1101_g0, false);
with_view_model(
instance->view, (SubghzTestStaticModel * model) {
model->frequency = subghz_frequencies_433_92;
model->real_frequency = subghz_frequencies[model->frequency];
model->button = 0;
return true;
});
}
void subghz_test_static_exit(void* context) {
furi_assert(context);
2021-08-08 21:03:25 +03:00
furi_hal_subghz_sleep();
}
SubghzTestStatic* subghz_test_static_alloc() {
SubghzTestStatic* instance = furi_alloc(sizeof(SubghzTestStatic));
// View allocation and configuration
2021-08-12 17:42:56 +03:00
instance->view = view_alloc();
view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(SubghzTestStaticModel));
2021-08-12 17:42:56 +03:00
view_set_context(instance->view, instance);
view_set_draw_callback(instance->view, (ViewDrawCallback)subghz_test_static_draw);
view_set_input_callback(instance->view, subghz_test_static_input);
view_set_enter_callback(instance->view, subghz_test_static_enter);
view_set_exit_callback(instance->view, subghz_test_static_exit);
2021-08-12 17:42:56 +03:00
instance->encoder = subghz_encoder_princeton_alloc();
return instance;
}
void subghz_test_static_free(SubghzTestStatic* instance) {
2021-08-12 17:42:56 +03:00
furi_assert(instance);
subghz_encoder_princeton_free(instance->encoder);
view_free(instance->view);
free(instance);
}
View* subghz_test_static_get_view(SubghzTestStatic* instance) {
2021-08-12 17:42:56 +03:00
furi_assert(instance);
return instance->view;
}