Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSkorpionm <85568270+Skorpionm@users.noreply.github.com>2022-03-03 12:48:56 +0300
committerGitHub <noreply@github.com>2022-03-03 12:48:56 +0300
commit3164184bbcb0a31f6c510fbd0bdab94f6760b4e7 (patch)
tree49632f1269eb2af063c87aea3778a26834f4bb69 /applications/subghz/views
parent052237f8c9bb34bc244abcbf108cdf1ec6ec58ec (diff)
[FL-2230] SubGhz: protocol API refactoring (#969)
* SubGhz: protocols library refactoring * SubGhz: new architecture and refactoring * SubGhz: simplify protocol structure, remove unused types * SubGhz: rename Subghz to SubGhz * SubGhz: add environment concept Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com> Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
Diffstat (limited to 'applications/subghz/views')
-rw-r--r--applications/subghz/views/receiver.c (renamed from applications/subghz/views/subghz_receiver.c)105
-rw-r--r--applications/subghz/views/receiver.h36
-rw-r--r--applications/subghz/views/subghz_frequency_analyzer.c42
-rw-r--r--applications/subghz/views/subghz_frequency_analyzer.h14
-rw-r--r--applications/subghz/views/subghz_read_raw.c234
-rw-r--r--applications/subghz/views/subghz_read_raw.h50
-rw-r--r--applications/subghz/views/subghz_receiver.h36
-rw-r--r--applications/subghz/views/subghz_test_carrier.c60
-rw-r--r--applications/subghz/views/subghz_test_carrier.h18
-rw-r--r--applications/subghz/views/subghz_test_packet.c112
-rw-r--r--applications/subghz/views/subghz_test_packet.h18
-rw-r--r--applications/subghz/views/subghz_test_static.c62
-rw-r--r--applications/subghz/views/subghz_test_static.h18
-rw-r--r--applications/subghz/views/subghz_transmitter.h26
-rw-r--r--applications/subghz/views/transmitter.c (renamed from applications/subghz/views/subghz_transmitter.c)67
-rw-r--r--applications/subghz/views/transmitter.h26
16 files changed, 461 insertions, 463 deletions
diff --git a/applications/subghz/views/subghz_receiver.c b/applications/subghz/views/receiver.c
index 92bfbb53..20ee37d3 100644
--- a/applications/subghz/views/subghz_receiver.c
+++ b/applications/subghz/views/receiver.c
@@ -1,4 +1,4 @@
-#include "subghz_receiver.h"
+#include "receiver.h"
#include "../subghz_i.h"
#include <math.h>
@@ -29,14 +29,14 @@ struct SubGhzReceiverHistory {
typedef struct SubGhzReceiverHistory SubGhzReceiverHistory;
static const Icon* ReceiverItemIcons[] = {
- [SubGhzProtocolCommonTypeUnknown] = &I_Quest_7x8,
- [SubGhzProtocolCommonTypeStatic] = &I_Unlock_7x8,
- [SubGhzProtocolCommonTypeDynamic] = &I_Lock_7x8,
+ [SubGhzProtocolTypeUnknown] = &I_Quest_7x8,
+ [SubGhzProtocolTypeStatic] = &I_Unlock_7x8,
+ [SubGhzProtocolTypeDynamic] = &I_Lock_7x8,
};
-struct SubghzReceiver {
+struct SubGhzViewReceiver {
View* view;
- SubghzReceiverCallback callback;
+ SubGhzViewReceiverCallback callback;
void* context;
};
@@ -48,11 +48,11 @@ typedef struct {
uint16_t idx;
uint16_t list_offset;
uint16_t history_item;
-} SubghzReceiverModel;
+} SubGhzViewReceiverModel;
-void subghz_receiver_set_callback(
- SubghzReceiver* subghz_receiver,
- SubghzReceiverCallback callback,
+void subghz_view_receiver_set_callback(
+ SubGhzViewReceiver* subghz_receiver,
+ SubGhzViewReceiverCallback callback,
void* context) {
furi_assert(subghz_receiver);
furi_assert(callback);
@@ -60,11 +60,11 @@ void subghz_receiver_set_callback(
subghz_receiver->context = context;
}
-static void subghz_receiver_update_offset(SubghzReceiver* subghz_receiver) {
+static void subghz_view_receiver_update_offset(SubGhzViewReceiver* subghz_receiver) {
furi_assert(subghz_receiver);
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
size_t history_item = model->history_item;
uint16_t bounds = history_item > 3 ? 2 : history_item;
@@ -79,13 +79,13 @@ static void subghz_receiver_update_offset(SubghzReceiver* subghz_receiver) {
});
}
-void subghz_receiver_add_item_to_menu(
- SubghzReceiver* subghz_receiver,
+void subghz_view_receiver_add_item_to_menu(
+ SubGhzViewReceiver* subghz_receiver,
const char* name,
uint8_t type) {
furi_assert(subghz_receiver);
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
SubGhzReceiverMenuItem* item_menu =
SubGhzReceiverMenuItemArray_push_raw(model->history->data);
string_init_set_str(item_menu->item_str, name);
@@ -99,17 +99,17 @@ void subghz_receiver_add_item_to_menu(
return true;
});
- subghz_receiver_update_offset(subghz_receiver);
+ subghz_view_receiver_update_offset(subghz_receiver);
}
-void subghz_receiver_add_data_statusbar(
- SubghzReceiver* subghz_receiver,
+void subghz_view_receiver_add_data_statusbar(
+ SubGhzViewReceiver* subghz_receiver,
const char* frequency_str,
const char* preset_str,
const char* history_stat_str) {
furi_assert(subghz_receiver);
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
string_set(model->frequency_str, frequency_str);
string_set(model->preset_str, preset_str);
string_set(model->history_stat_str, history_stat_str);
@@ -117,7 +117,7 @@ void subghz_receiver_add_data_statusbar(
});
}
-static void subghz_receiver_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) {
+static void subghz_view_receiver_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) {
canvas_set_color(canvas, ColorBlack);
canvas_draw_box(canvas, 0, 0 + idx * FRAME_HEIGHT, scrollbar ? 122 : 127, FRAME_HEIGHT);
@@ -131,7 +131,7 @@ static void subghz_receiver_draw_frame(Canvas* canvas, uint16_t idx, bool scroll
canvas_draw_dot(canvas, scrollbar ? 121 : 126, (0 + idx * FRAME_HEIGHT) + 11);
}
-void subghz_receiver_draw(Canvas* canvas, SubghzReceiverModel* model) {
+void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
canvas_clear(canvas);
canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontSecondary);
@@ -162,7 +162,7 @@ void subghz_receiver_draw(Canvas* canvas, SubghzReceiverModel* model) {
string_set(str_buff, item_menu->item_str);
elements_string_fit_width(canvas, str_buff, scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX);
if(model->idx == idx) {
- subghz_receiver_draw_frame(canvas, i, scrollbar);
+ subghz_view_receiver_draw_frame(canvas, i, scrollbar);
} else {
canvas_set_color(canvas, ColorBlack);
}
@@ -176,17 +176,17 @@ void subghz_receiver_draw(Canvas* canvas, SubghzReceiverModel* model) {
string_clear(str_buff);
}
-bool subghz_receiver_input(InputEvent* event, void* context) {
+bool subghz_view_receiver_input(InputEvent* event, void* context) {
furi_assert(context);
- SubghzReceiver* subghz_receiver = context;
+ SubGhzViewReceiver* subghz_receiver = context;
if(event->key == InputKeyBack && event->type == InputTypeShort) {
- subghz_receiver->callback(SubghzCustomEventViewReceverBack, subghz_receiver->context);
+ subghz_receiver->callback(SubGhzCustomEventViewReceverBack, subghz_receiver->context);
} else if(
event->key == InputKeyUp &&
(event->type == InputTypeShort || event->type == InputTypeRepeat)) {
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
if(model->idx != 0) model->idx--;
return true;
});
@@ -194,38 +194,38 @@ bool subghz_receiver_input(InputEvent* event, void* context) {
event->key == InputKeyDown &&
(event->type == InputTypeShort || event->type == InputTypeRepeat)) {
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
if(model->idx != model->history_item - 1) model->idx++;
return true;
});
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
- subghz_receiver->callback(SubghzCustomEventViewReceverConfig, subghz_receiver->context);
+ subghz_receiver->callback(SubGhzCustomEventViewReceverConfig, subghz_receiver->context);
} else if(event->key == InputKeyOk && event->type == InputTypeShort) {
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
if(model->history_item != 0) {
subghz_receiver->callback(
- SubghzCustomEventViewReceverOK, subghz_receiver->context);
+ SubGhzCustomEventViewReceverOK, subghz_receiver->context);
}
return false;
});
}
- subghz_receiver_update_offset(subghz_receiver);
+ subghz_view_receiver_update_offset(subghz_receiver);
return true;
}
-void subghz_receiver_enter(void* context) {
+void subghz_view_receiver_enter(void* context) {
furi_assert(context);
- //SubghzReceiver* subghz_receiver = context;
+ //SubGhzViewReceiver* subghz_receiver = context;
}
-void subghz_receiver_exit(void* context) {
+void subghz_view_receiver_exit(void* context) {
furi_assert(context);
- SubghzReceiver* subghz_receiver = context;
+ SubGhzViewReceiver* subghz_receiver = context;
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
string_reset(model->frequency_str);
string_reset(model->preset_str);
string_reset(model->history_stat_str);
@@ -242,20 +242,21 @@ void subghz_receiver_exit(void* context) {
});
}
-SubghzReceiver* subghz_receiver_alloc() {
- SubghzReceiver* subghz_receiver = malloc(sizeof(SubghzReceiver));
+SubGhzViewReceiver* subghz_view_receiver_alloc() {
+ SubGhzViewReceiver* subghz_receiver = malloc(sizeof(SubGhzViewReceiver));
// View allocation and configuration
subghz_receiver->view = view_alloc();
- view_allocate_model(subghz_receiver->view, ViewModelTypeLocking, sizeof(SubghzReceiverModel));
+ view_allocate_model(
+ subghz_receiver->view, ViewModelTypeLocking, sizeof(SubGhzViewReceiverModel));
view_set_context(subghz_receiver->view, subghz_receiver);
- view_set_draw_callback(subghz_receiver->view, (ViewDrawCallback)subghz_receiver_draw);
- view_set_input_callback(subghz_receiver->view, subghz_receiver_input);
- view_set_enter_callback(subghz_receiver->view, subghz_receiver_enter);
- view_set_exit_callback(subghz_receiver->view, subghz_receiver_exit);
+ view_set_draw_callback(subghz_receiver->view, (ViewDrawCallback)subghz_view_receiver_draw);
+ view_set_input_callback(subghz_receiver->view, subghz_view_receiver_input);
+ view_set_enter_callback(subghz_receiver->view, subghz_view_receiver_enter);
+ view_set_exit_callback(subghz_receiver->view, subghz_view_receiver_exit);
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
string_init(model->frequency_str);
string_init(model->preset_str);
string_init(model->history_stat_str);
@@ -267,11 +268,11 @@ SubghzReceiver* subghz_receiver_alloc() {
return subghz_receiver;
}
-void subghz_receiver_free(SubghzReceiver* subghz_receiver) {
+void subghz_view_receiver_free(SubGhzViewReceiver* subghz_receiver) {
furi_assert(subghz_receiver);
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
string_clear(model->frequency_str);
string_clear(model->preset_str);
string_clear(model->history_stat_str);
@@ -288,29 +289,29 @@ void subghz_receiver_free(SubghzReceiver* subghz_receiver) {
free(subghz_receiver);
}
-View* subghz_receiver_get_view(SubghzReceiver* subghz_receiver) {
+View* subghz_view_receiver_get_view(SubGhzViewReceiver* subghz_receiver) {
furi_assert(subghz_receiver);
return subghz_receiver->view;
}
-uint16_t subghz_receiver_get_idx_menu(SubghzReceiver* subghz_receiver) {
+uint16_t subghz_view_receiver_get_idx_menu(SubGhzViewReceiver* subghz_receiver) {
furi_assert(subghz_receiver);
uint32_t idx = 0;
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
idx = model->idx;
return false;
});
return idx;
}
-void subghz_receiver_set_idx_menu(SubghzReceiver* subghz_receiver, uint16_t idx) {
+void subghz_view_receiver_set_idx_menu(SubGhzViewReceiver* subghz_receiver, uint16_t idx) {
furi_assert(subghz_receiver);
with_view_model(
- subghz_receiver->view, (SubghzReceiverModel * model) {
+ subghz_receiver->view, (SubGhzViewReceiverModel * model) {
model->idx = idx;
if(model->idx > 2) model->list_offset = idx - 2;
return true;
});
- subghz_receiver_update_offset(subghz_receiver);
+ subghz_view_receiver_update_offset(subghz_receiver);
}
diff --git a/applications/subghz/views/receiver.h b/applications/subghz/views/receiver.h
new file mode 100644
index 00000000..87065ef0
--- /dev/null
+++ b/applications/subghz/views/receiver.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <gui/view.h>
+#include "../helpers/subghz_custom_event.h"
+
+typedef struct SubGhzViewReceiver SubGhzViewReceiver;
+
+typedef void (*SubGhzViewReceiverCallback)(SubGhzCustomEvent event, void* context);
+
+void subghz_view_receiver_set_callback(
+ SubGhzViewReceiver* subghz_receiver,
+ SubGhzViewReceiverCallback callback,
+ void* context);
+
+SubGhzViewReceiver* subghz_view_receiver_alloc();
+
+void subghz_view_receiver_free(SubGhzViewReceiver* subghz_receiver);
+
+View* subghz_view_receiver_get_view(SubGhzViewReceiver* subghz_receiver);
+
+void subghz_view_receiver_add_data_statusbar(
+ SubGhzViewReceiver* subghz_receiver,
+ const char* frequency_str,
+ const char* preset_str,
+ const char* history_stat_str);
+
+void subghz_view_receiver_add_item_to_menu(
+ SubGhzViewReceiver* subghz_receiver,
+ const char* name,
+ uint8_t type);
+
+uint16_t subghz_view_receiver_get_idx_menu(SubGhzViewReceiver* subghz_receiver);
+
+void subghz_view_receiver_set_idx_menu(SubGhzViewReceiver* subghz_receiver, uint16_t idx);
+
+void subghz_view_receiver_exit(void* context);
diff --git a/applications/subghz/views/subghz_frequency_analyzer.c b/applications/subghz/views/subghz_frequency_analyzer.c
index afb7b012..4e645edb 100644
--- a/applications/subghz/views/subghz_frequency_analyzer.c
+++ b/applications/subghz/views/subghz_frequency_analyzer.c
@@ -6,30 +6,29 @@
#include <furi_hal.h>
#include <input/input.h>
#include <notification/notification_messages.h>
-#include <lib/subghz/protocols/subghz_protocol_princeton.h>
#include "../helpers/subghz_frequency_analyzer_worker.h"
#include <assets_icons.h>
typedef enum {
- SubghzFrequencyAnalyzerStatusIDLE,
-} SubghzFrequencyAnalyzerStatus;
+ SubGhzFrequencyAnalyzerStatusIDLE,
+} SubGhzFrequencyAnalyzerStatus;
-struct SubghzFrequencyAnalyzer {
+struct SubGhzFrequencyAnalyzer {
View* view;
SubGhzFrequencyAnalyzerWorker* worker;
- SubghzFrequencyAnalyzerCallback callback;
+ SubGhzFrequencyAnalyzerCallback callback;
void* context;
};
typedef struct {
uint32_t frequency;
float rssi;
-} SubghzFrequencyAnalyzerModel;
+} SubGhzFrequencyAnalyzerModel;
void subghz_frequency_analyzer_set_callback(
- SubghzFrequencyAnalyzer* subghz_frequency_analyzer,
- SubghzFrequencyAnalyzerCallback callback,
+ SubGhzFrequencyAnalyzer* subghz_frequency_analyzer,
+ SubGhzFrequencyAnalyzerCallback callback,
void* context) {
furi_assert(subghz_frequency_analyzer);
furi_assert(callback);
@@ -53,7 +52,7 @@ void subghz_frequency_analyzer_draw_rssi(Canvas* canvas, float rssi) {
}
}
-void subghz_frequency_analyzer_draw(Canvas* canvas, SubghzFrequencyAnalyzerModel* model) {
+void subghz_frequency_analyzer_draw(Canvas* canvas, SubGhzFrequencyAnalyzerModel* model) {
char buffer[64];
canvas_set_color(canvas, ColorBlack);
@@ -77,7 +76,6 @@ void subghz_frequency_analyzer_draw(Canvas* canvas, SubghzFrequencyAnalyzerModel
bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
furi_assert(context);
- //SubghzFrequencyAnalyzer* instance = context;
if(event->key == InputKeyBack) {
return false;
@@ -87,9 +85,9 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
}
void subghz_frequency_analyzer_pair_callback(void* context, uint32_t frequency, float rssi) {
- SubghzFrequencyAnalyzer* instance = context;
+ SubGhzFrequencyAnalyzer* instance = context;
with_view_model(
- instance->view, (SubghzFrequencyAnalyzerModel * model) {
+ instance->view, (SubGhzFrequencyAnalyzerModel * model) {
model->rssi = rssi;
model->frequency = frequency;
return true;
@@ -98,7 +96,7 @@ void subghz_frequency_analyzer_pair_callback(void* context, uint32_t frequency,
void subghz_frequency_analyzer_enter(void* context) {
furi_assert(context);
- SubghzFrequencyAnalyzer* instance = context;
+ SubGhzFrequencyAnalyzer* instance = context;
//Start worker
instance->worker = subghz_frequency_analyzer_worker_alloc();
@@ -111,7 +109,7 @@ void subghz_frequency_analyzer_enter(void* context) {
subghz_frequency_analyzer_worker_start(instance->worker);
with_view_model(
- instance->view, (SubghzFrequencyAnalyzerModel * model) {
+ instance->view, (SubGhzFrequencyAnalyzerModel * model) {
model->rssi = 0;
model->frequency = 0;
return true;
@@ -120,7 +118,7 @@ void subghz_frequency_analyzer_enter(void* context) {
void subghz_frequency_analyzer_exit(void* context) {
furi_assert(context);
- SubghzFrequencyAnalyzer* instance = context;
+ SubGhzFrequencyAnalyzer* instance = context;
//Stop worker
if(subghz_frequency_analyzer_worker_is_running(instance->worker)) {
@@ -129,19 +127,19 @@ void subghz_frequency_analyzer_exit(void* context) {
subghz_frequency_analyzer_worker_free(instance->worker);
with_view_model(
- instance->view, (SubghzFrequencyAnalyzerModel * model) {
+ instance->view, (SubGhzFrequencyAnalyzerModel * model) {
model->rssi = 0;
return true;
});
}
-SubghzFrequencyAnalyzer* subghz_frequency_analyzer_alloc() {
- SubghzFrequencyAnalyzer* instance = malloc(sizeof(SubghzFrequencyAnalyzer));
+SubGhzFrequencyAnalyzer* subghz_frequency_analyzer_alloc() {
+ SubGhzFrequencyAnalyzer* instance = malloc(sizeof(SubGhzFrequencyAnalyzer));
// View allocation and configuration
instance->view = view_alloc();
view_allocate_model(
- instance->view, ViewModelTypeLocking, sizeof(SubghzFrequencyAnalyzerModel));
+ instance->view, ViewModelTypeLocking, sizeof(SubGhzFrequencyAnalyzerModel));
view_set_context(instance->view, instance);
view_set_draw_callback(instance->view, (ViewDrawCallback)subghz_frequency_analyzer_draw);
view_set_input_callback(instance->view, subghz_frequency_analyzer_input);
@@ -149,7 +147,7 @@ SubghzFrequencyAnalyzer* subghz_frequency_analyzer_alloc() {
view_set_exit_callback(instance->view, subghz_frequency_analyzer_exit);
with_view_model(
- instance->view, (SubghzFrequencyAnalyzerModel * model) {
+ instance->view, (SubGhzFrequencyAnalyzerModel * model) {
model->rssi = 0;
return true;
});
@@ -157,14 +155,14 @@ SubghzFrequencyAnalyzer* subghz_frequency_analyzer_alloc() {
return instance;
}
-void subghz_frequency_analyzer_free(SubghzFrequencyAnalyzer* instance) {
+void subghz_frequency_analyzer_free(SubGhzFrequencyAnalyzer* instance) {
furi_assert(instance);
view_free(instance->view);
free(instance);
}
-View* subghz_frequency_analyzer_get_view(SubghzFrequencyAnalyzer* instance) {
+View* subghz_frequency_analyzer_get_view(SubGhzFrequencyAnalyzer* instance) {
furi_assert(instance);
return instance->view;
}
diff --git a/applications/subghz/views/subghz_frequency_analyzer.h b/applications/subghz/views/subghz_frequency_analyzer.h
index 78280503..3de003bf 100644
--- a/applications/subghz/views/subghz_frequency_analyzer.h
+++ b/applications/subghz/views/subghz_frequency_analyzer.h
@@ -3,17 +3,17 @@
#include <gui/view.h>
#include "../helpers/subghz_custom_event.h"
-typedef struct SubghzFrequencyAnalyzer SubghzFrequencyAnalyzer;
+typedef struct SubGhzFrequencyAnalyzer SubGhzFrequencyAnalyzer;
-typedef void (*SubghzFrequencyAnalyzerCallback)(SubghzCustomEvent event, void* context);
+typedef void (*SubGhzFrequencyAnalyzerCallback)(SubGhzCustomEvent event, void* context);
void subghz_frequency_analyzer_set_callback(
- SubghzFrequencyAnalyzer* subghz_frequency_analyzer,
- SubghzFrequencyAnalyzerCallback callback,
+ SubGhzFrequencyAnalyzer* subghz_frequency_analyzer,
+ SubGhzFrequencyAnalyzerCallback callback,
void* context);
-SubghzFrequencyAnalyzer* subghz_frequency_analyzer_alloc();
+SubGhzFrequencyAnalyzer* subghz_frequency_analyzer_alloc();
-void subghz_frequency_analyzer_free(SubghzFrequencyAnalyzer* subghz_static);
+void subghz_frequency_analyzer_free(SubGhzFrequencyAnalyzer* subghz_static);
-View* subghz_frequency_analyzer_get_view(SubghzFrequencyAnalyzer* subghz_static);
+View* subghz_frequency_analyzer_get_view(SubGhzFrequencyAnalyzer* subghz_static);
diff --git a/applications/subghz/views/subghz_read_raw.c b/applications/subghz/views/subghz_read_raw.c
index f786b7a0..c5b1f09b 100644
--- a/applications/subghz/views/subghz_read_raw.c
+++ b/applications/subghz/views/subghz_read_raw.c
@@ -6,15 +6,14 @@
#include <furi_hal.h>
#include <input/input.h>
#include <gui/elements.h>
-#include <lib/subghz/protocols/subghz_protocol_princeton.h>
#include <assets_icons.h>
#define SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE 100
-#define TAG "SubghzReadRAW"
+#define TAG "SubGhzReadRAW"
-struct SubghzReadRAW {
+struct SubGhzReadRAW {
View* view;
- SubghzReadRAWCallback callback;
+ SubGhzReadRAWCallback callback;
void* context;
};
@@ -27,12 +26,12 @@ typedef struct {
bool rssi_history_end;
uint8_t ind_write;
uint8_t ind_sin;
- SubghzReadRAWStatus satus;
-} SubghzReadRAWModel;
+ SubGhzReadRAWStatus satus;
+} SubGhzReadRAWModel;
void subghz_read_raw_set_callback(
- SubghzReadRAW* subghz_read_raw,
- SubghzReadRAWCallback callback,
+ SubGhzReadRAW* subghz_read_raw,
+ SubGhzReadRAWCallback callback,
void* context) {
furi_assert(subghz_read_raw);
furi_assert(callback);
@@ -41,19 +40,19 @@ void subghz_read_raw_set_callback(
}
void subghz_read_raw_add_data_statusbar(
- SubghzReadRAW* instance,
+ SubGhzReadRAW* instance,
const char* frequency_str,
const char* preset_str) {
furi_assert(instance);
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
+ instance->view, (SubGhzReadRAWModel * model) {
string_set(model->frequency_str, frequency_str);
string_set(model->preset_str, preset_str);
return true;
});
}
-void subghz_read_raw_add_data_rssi(SubghzReadRAW* instance, float rssi) {
+void subghz_read_raw_add_data_rssi(SubGhzReadRAW* instance, float rssi) {
furi_assert(instance);
uint8_t u_rssi = 0;
@@ -62,10 +61,9 @@ void subghz_read_raw_add_data_rssi(SubghzReadRAW* instance, float rssi) {
} else {
u_rssi = (uint8_t)((rssi + 90) / 2.7);
}
- //if(u_rssi > 34) u_rssi = 34;
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
+ instance->view, (SubGhzReadRAWModel * model) {
model->rssi_history[model->ind_write++] = u_rssi;
if(model->ind_write > SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE) {
model->rssi_history_end = true;
@@ -75,46 +73,46 @@ void subghz_read_raw_add_data_rssi(SubghzReadRAW* instance, float rssi) {
});
}
-void subghz_read_raw_update_sample_write(SubghzReadRAW* instance, size_t sample) {
+void subghz_read_raw_update_sample_write(SubGhzReadRAW* instance, size_t sample) {
furi_assert(instance);
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
+ instance->view, (SubGhzReadRAWModel * model) {
string_printf(model->sample_write, "%d spl.", sample);
return false;
});
}
-void subghz_read_raw_stop_send(SubghzReadRAW* instance) {
+void subghz_read_raw_stop_send(SubGhzReadRAW* instance) {
furi_assert(instance);
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
+ instance->view, (SubGhzReadRAWModel * model) {
switch(model->satus) {
- case SubghzReadRAWStatusTXRepeat:
- case SubghzReadRAWStatusLoadKeyTXRepeat:
- instance->callback(SubghzCustomEventViewReadRAWSendStart, instance->context);
+ case SubGhzReadRAWStatusTXRepeat:
+ case SubGhzReadRAWStatusLoadKeyTXRepeat:
+ instance->callback(SubGhzCustomEventViewReadRAWSendStart, instance->context);
break;
- case SubghzReadRAWStatusTX:
- model->satus = SubghzReadRAWStatusIDLE;
+ case SubGhzReadRAWStatusTX:
+ model->satus = SubGhzReadRAWStatusIDLE;
break;
- case SubghzReadRAWStatusLoadKeyTX:
- model->satus = SubghzReadRAWStatusLoadKeyIDLE;
+ case SubGhzReadRAWStatusLoadKeyTX:
+ model->satus = SubGhzReadRAWStatusLoadKeyIDLE;
break;
default:
FURI_LOG_W(TAG, "unknown status");
- model->satus = SubghzReadRAWStatusIDLE;
+ model->satus = SubGhzReadRAWStatusIDLE;
break;
}
return true;
});
}
-void subghz_read_raw_update_sin(SubghzReadRAW* instance) {
+void subghz_read_raw_update_sin(SubGhzReadRAW* instance) {
furi_assert(instance);
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
+ instance->view, (SubGhzReadRAWModel * model) {
if(model->ind_sin++ > 62) {
model->ind_sin = 0;
}
@@ -134,7 +132,7 @@ static int8_t subghz_read_raw_tab_sin(uint8_t x) {
return r;
}
-void subghz_read_raw_draw_sin(Canvas* canvas, SubghzReadRAWModel* model) {
+void subghz_read_raw_draw_sin(Canvas* canvas, SubGhzReadRAWModel* model) {
#define SUBGHZ_RAW_SIN_AMPLITUDE 11
for(int i = 113; i > 0; i--) {
canvas_draw_line(
@@ -154,7 +152,7 @@ void subghz_read_raw_draw_sin(Canvas* canvas, SubghzReadRAWModel* model) {
}
}
-void subghz_read_raw_draw_scale(Canvas* canvas, SubghzReadRAWModel* model) {
+void subghz_read_raw_draw_scale(Canvas* canvas, SubGhzReadRAWModel* model) {
#define SUBGHZ_RAW_TOP_SCALE 14
#define SUBGHZ_RAW_END_SCALE 115
@@ -178,7 +176,7 @@ void subghz_read_raw_draw_scale(Canvas* canvas, SubghzReadRAWModel* model) {
}
}
-void subghz_read_raw_draw_rssi(Canvas* canvas, SubghzReadRAWModel* model) {
+void subghz_read_raw_draw_rssi(Canvas* canvas, SubGhzReadRAWModel* model) {
int ind = 0;
int base = 0;
if(model->rssi_history_end == false) {
@@ -214,7 +212,7 @@ void subghz_read_raw_draw_rssi(Canvas* canvas, SubghzReadRAWModel* model) {
}
}
-void subghz_read_raw_draw(Canvas* canvas, SubghzReadRAWModel* model) {
+void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) {
uint8_t graphics_mode = 1;
canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontSecondary);
@@ -228,12 +226,12 @@ void subghz_read_raw_draw(Canvas* canvas, SubghzReadRAWModel* model) {
canvas_draw_line(canvas, 115, 14, 115, 48);
switch(model->satus) {
- case SubghzReadRAWStatusIDLE:
+ case SubGhzReadRAWStatusIDLE:
elements_button_left(canvas, "Erase");
elements_button_center(canvas, "Send");
elements_button_right(canvas, "Save");
break;
- case SubghzReadRAWStatusLoadKeyIDLE:
+ case SubGhzReadRAWStatusLoadKeyIDLE:
elements_button_left(canvas, "New");
elements_button_center(canvas, "Send");
elements_button_right(canvas, "More");
@@ -241,15 +239,15 @@ void subghz_read_raw_draw(Canvas* canvas, SubghzReadRAWModel* model) {
canvas, 4, 12, 110, 44, AlignCenter, AlignCenter, string_get_cstr(model->file_name));
break;
- case SubghzReadRAWStatusTX:
- case SubghzReadRAWStatusTXRepeat:
- case SubghzReadRAWStatusLoadKeyTX:
- case SubghzReadRAWStatusLoadKeyTXRepeat:
+ case SubGhzReadRAWStatusTX:
+ case SubGhzReadRAWStatusTXRepeat:
+ case SubGhzReadRAWStatusLoadKeyTX:
+ case SubGhzReadRAWStatusLoadKeyTXRepeat:
graphics_mode = 0;
elements_button_center(canvas, "Send");
break;
- case SubghzReadRAWStatusStart:
+ case SubGhzReadRAWStatusStart:
elements_button_left(canvas, "Config");
elements_button_center(canvas, "REC");
break;
@@ -272,7 +270,7 @@ void subghz_read_raw_draw(Canvas* canvas, SubghzReadRAWModel* model) {
bool subghz_read_raw_input(InputEvent* event, void* context) {
furi_assert(context);
- SubghzReadRAW* instance = context;
+ SubGhzReadRAW* instance = context;
if((event->key == InputKeyOk) &&
(event->type == InputTypeLong || event->type == InputTypeRepeat)) {
@@ -281,30 +279,30 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
return false;
} else if(event->key == InputKeyOk && event->type == InputTypePress) {
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
+ instance->view, (SubGhzReadRAWModel * model) {
uint8_t ret = false;
switch(model->satus) {
- case SubghzReadRAWStatusIDLE:
+ case SubGhzReadRAWStatusIDLE:
// Start TX
- instance->callback(SubghzCustomEventViewReadRAWSendStart, instance->context);
- instance->callback(SubghzCustomEventViewReadRAWVibro, instance->context);
- model->satus = SubghzReadRAWStatusTXRepeat;
+ instance->callback(SubGhzCustomEventViewReadRAWSendStart, instance->context);
+ instance->callback(SubGhzCustomEventViewReadRAWVibro, instance->context);
+ model->satus = SubGhzReadRAWStatusTXRepeat;
ret = true;
break;
- case SubghzReadRAWStatusTX:
+ case SubGhzReadRAWStatusTX:
// Start TXRepeat
- model->satus = SubghzReadRAWStatusTXRepeat;
+ model->satus = SubGhzReadRAWStatusTXRepeat;
break;
- case SubghzReadRAWStatusLoadKeyIDLE:
+ case SubGhzReadRAWStatusLoadKeyIDLE:
// Start Load Key TX
- instance->callback(SubghzCustomEventViewReadRAWSendStart, instance->context);
- instance->callback(SubghzCustomEventViewReadRAWVibro, instance->context);
- model->satus = SubghzReadRAWStatusLoadKeyTXRepeat;
+ instance->callback(SubGhzCustomEventViewReadRAWSendStart, instance->context);
+ instance->callback(SubGhzCustomEventViewReadRAWVibro, instance->context);
+ model->satus = SubGhzReadRAWStatusLoadKeyTXRepeat;
ret = true;
break;
- case SubghzReadRAWStatusLoadKeyTX:
+ case SubGhzReadRAWStatusLoadKeyTX:
// Start Load Key TXRepeat
- model->satus = SubghzReadRAWStatusLoadKeyTXRepeat;
+ model->satus = SubGhzReadRAWStatusLoadKeyTXRepeat;
break;
default:
@@ -314,91 +312,91 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
});
} else if(event->key == InputKeyOk && event->type == InputTypeRelease) {
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
- if(model->satus == SubghzReadRAWStatusTXRepeat) {
+ instance->view, (SubGhzReadRAWModel * model) {
+ if(model->satus == SubGhzReadRAWStatusTXRepeat) {
// Stop repeat TX
- model->satus = SubghzReadRAWStatusTX;
- } else if(model->satus == SubghzReadRAWStatusLoadKeyTXRepeat) {
+ model->satus = SubGhzReadRAWStatusTX;
+ } else if(model->satus == SubGhzReadRAWStatusLoadKeyTXRepeat) {
// Stop repeat TX
- model->satus = SubghzReadRAWStatusLoadKeyTX;
+ model->satus = SubGhzReadRAWStatusLoadKeyTX;
}
return false;
});
} else if(event->key == InputKeyBack && event->type == InputTypeShort) {
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
+ instance->view, (SubGhzReadRAWModel * model) {
switch(model->satus) {
- case SubghzReadRAWStatusREC:
+ case SubGhzReadRAWStatusREC:
//Stop REC
- instance->callback(SubghzCustomEventViewReadRAWIDLE, instance->context);
- model->satus = SubghzReadRAWStatusIDLE;
+ instance->callback(SubGhzCustomEventViewReadRAWIDLE, instance->context);
+ model->satus = SubGhzReadRAWStatusIDLE;
break;
- case SubghzReadRAWStatusLoadKeyTX:
+ case SubGhzReadRAWStatusLoadKeyTX:
//Stop TxRx
- instance->callback(SubghzCustomEventViewReadRAWTXRXStop, instance->context);
- model->satus = SubghzReadRAWStatusLoadKeyIDLE;
+ instance->callback(SubGhzCustomEventViewReadRAWTXRXStop, instance->context);
+ model->satus = SubGhzReadRAWStatusLoadKeyIDLE;
break;
- case SubghzReadRAWStatusTX:
+ case SubGhzReadRAWStatusTX:
//Stop TxRx
- instance->callback(SubghzCustomEventViewReadRAWTXRXStop, instance->context);
- model->satus = SubghzReadRAWStatusIDLE;
+ instance->callback(SubGhzCustomEventViewReadRAWTXRXStop, instance->context);
+ model->satus = SubGhzReadRAWStatusIDLE;
break;
- case SubghzReadRAWStatusLoadKeyIDLE:
+ case SubGhzReadRAWStatusLoadKeyIDLE:
//Exit
- instance->callback(SubghzCustomEventViewReadRAWBack, instance->context);
+ instance->callback(SubGhzCustomEventViewReadRAWBack, instance->context);
break;
default:
//Exit
- instance->callback(SubghzCustomEventViewReadRAWBack, instance->context);
+ instance->callback(SubGhzCustomEventViewReadRAWBack, instance->context);
break;
}
return true;
});
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
- if(model->satus == SubghzReadRAWStatusStart) {
+ instance->view, (SubGhzReadRAWModel * model) {
+ if(model->satus == SubGhzReadRAWStatusStart) {
//Config
- instance->callback(SubghzCustomEventViewReadRAWConfig, instance->context);
+ instance->callback(SubGhzCustomEventViewReadRAWConfig, instance->context);
} else if(
- (model->satus == SubghzReadRAWStatusIDLE) ||
- (model->satus == SubghzReadRAWStatusLoadKeyIDLE)) {
+ (model->satus == SubGhzReadRAWStatusIDLE) ||
+ (model->satus == SubGhzReadRAWStatusLoadKeyIDLE)) {
//Erase
- model->satus = SubghzReadRAWStatusStart;
+ model->satus = SubGhzReadRAWStatusStart;
model->rssi_history_end = false;
model->ind_write = 0;
string_set(model->sample_write, "0 spl.");
string_reset(model->file_name);
- instance->callback(SubghzCustomEventViewReadRAWErase, instance->context);
+ instance->callback(SubGhzCustomEventViewReadRAWErase, instance->context);
}
return true;
});
} else if(event->key == InputKeyRight && event->type == InputTypeShort) {
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
- if(model->satus == SubghzReadRAWStatusIDLE) {
+ instance->view, (SubGhzReadRAWModel * model) {
+ if(model->satus == SubGhzReadRAWStatusIDLE) {
//Save
- instance->callback(SubghzCustomEventViewReadRAWSave, instance->context);
- } else if(model->satus == SubghzReadRAWStatusLoadKeyIDLE) {
+ instance->callback(SubGhzCustomEventViewReadRAWSave, instance->context);
+ } else if(model->satus == SubGhzReadRAWStatusLoadKeyIDLE) {
//More
- instance->callback(SubghzCustomEventViewReadRAWMore, instance->context);
+ instance->callback(SubGhzCustomEventViewReadRAWMore, instance->context);
}
return true;
});
} else if(event->key == InputKeyOk && event->type == InputTypeShort) {
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
- if(model->satus == SubghzReadRAWStatusStart) {
+ instance->view, (SubGhzReadRAWModel * model) {
+ if(model->satus == SubGhzReadRAWStatusStart) {
//Record
- instance->callback(SubghzCustomEventViewReadRAWREC, instance->context);
- model->satus = SubghzReadRAWStatusREC;
+ instance->callback(SubGhzCustomEventViewReadRAWREC, instance->context);
+ model->satus = SubGhzReadRAWStatusREC;
model->ind_write = 0;
model->rssi_history_end = false;
- } else if(model->satus == SubghzReadRAWStatusREC) {
+ } else if(model->satus == SubGhzReadRAWStatusREC) {
//Stop
- instance->callback(SubghzCustomEventViewReadRAWIDLE, instance->context);
- model->satus = SubghzReadRAWStatusIDLE;
+ instance->callback(SubGhzCustomEventViewReadRAWIDLE, instance->context);
+ model->satus = SubGhzReadRAWStatusIDLE;
}
return true;
});
@@ -407,16 +405,16 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
}
void subghz_read_raw_set_status(
- SubghzReadRAW* instance,
- SubghzReadRAWStatus satus,
+ SubGhzReadRAW* instance,
+ SubGhzReadRAWStatus satus,
const char* file_name) {
furi_assert(instance);
switch(satus) {
- case SubghzReadRAWStatusStart:
+ case SubGhzReadRAWStatusStart:
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
- model->satus = SubghzReadRAWStatusStart;
+ instance->view, (SubGhzReadRAWModel * model) {
+ model->satus = SubGhzReadRAWStatusStart;
model->rssi_history_end = false;
model->ind_write = 0;
string_reset(model->file_name);
@@ -424,17 +422,17 @@ void subghz_read_raw_set_status(
return true;
});
break;
- case SubghzReadRAWStatusIDLE:
+ case SubGhzReadRAWStatusIDLE:
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
- model->satus = SubghzReadRAWStatusIDLE;
+ instance->view, (SubGhzReadRAWModel * model) {
+ model->satus = SubGhzReadRAWStatusIDLE;
return true;
});
break;
- case SubghzReadRAWStatusLoadKeyTX:
+ case SubGhzReadRAWStatusLoadKeyTX:
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
- model->satus = SubghzReadRAWStatusLoadKeyIDLE;
+ instance->view, (SubGhzReadRAWModel * model) {
+ model->satus = SubGhzReadRAWStatusLoadKeyIDLE;
model->rssi_history_end = false;
model->ind_write = 0;
string_set(model->file_name, file_name);
@@ -442,10 +440,10 @@ void subghz_read_raw_set_status(
return true;
});
break;
- case SubghzReadRAWStatusSaveKey:
+ case SubGhzReadRAWStatusSaveKey:
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
- model->satus = SubghzReadRAWStatusLoadKeyIDLE;
+ instance->view, (SubGhzReadRAWModel * model) {
+ model->satus = SubGhzReadRAWStatusLoadKeyIDLE;
if(!model->ind_write) {
string_set(model->file_name, file_name);
string_set(model->sample_write, "RAW");
@@ -464,31 +462,31 @@ void subghz_read_raw_set_status(
void subghz_read_raw_enter(void* context) {
furi_assert(context);
- //SubghzReadRAW* instance = context;
+ //SubGhzReadRAW* instance = context;
}
void subghz_read_raw_exit(void* context) {
furi_assert(context);
- SubghzReadRAW* instance = context;
+ SubGhzReadRAW* instance = context;
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
- if(model->satus != SubghzReadRAWStatusIDLE &&
- model->satus != SubghzReadRAWStatusStart &&
- model->satus != SubghzReadRAWStatusLoadKeyIDLE) {
- instance->callback(SubghzCustomEventViewReadRAWIDLE, instance->context);
- model->satus = SubghzReadRAWStatusStart;
+ instance->view, (SubGhzReadRAWModel * model) {
+ if(model->satus != SubGhzReadRAWStatusIDLE &&
+ model->satus != SubGhzReadRAWStatusStart &&
+ model->satus != SubGhzReadRAWStatusLoadKeyIDLE) {
+ instance->callback(SubGhzCustomEventViewReadRAWIDLE, instance->context);
+ model->satus = SubGhzReadRAWStatusStart;
}
return true;
});
}
-SubghzReadRAW* subghz_read_raw_alloc() {
- SubghzReadRAW* instance = malloc(sizeof(SubghzReadRAW));
+SubGhzReadRAW* subghz_read_raw_alloc() {
+ SubGhzReadRAW* instance = malloc(sizeof(SubGhzReadRAW));
// View allocation and configuration
instance->view = view_alloc();
- view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(SubghzReadRAWModel));
+ view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(SubGhzReadRAWModel));
view_set_context(instance->view, instance);
view_set_draw_callback(instance->view, (ViewDrawCallback)subghz_read_raw_draw);
view_set_input_callback(instance->view, subghz_read_raw_input);
@@ -496,7 +494,7 @@ SubghzReadRAW* subghz_read_raw_alloc() {
view_set_exit_callback(instance->view, subghz_read_raw_exit);
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
+ instance->view, (SubGhzReadRAWModel * model) {
string_init(model->frequency_str);
string_init(model->preset_str);
string_init(model->sample_write);
@@ -508,11 +506,11 @@ SubghzReadRAW* subghz_read_raw_alloc() {
return instance;
}
-void subghz_read_raw_free(SubghzReadRAW* instance) {
+void subghz_read_raw_free(SubGhzReadRAW* instance) {
furi_assert(instance);
with_view_model(
- instance->view, (SubghzReadRAWModel * model) {
+ instance->view, (SubGhzReadRAWModel * model) {
string_clear(model->frequency_str);
string_clear(model->preset_str);
string_clear(model->sample_write);
@@ -524,7 +522,7 @@ void subghz_read_raw_free(SubghzReadRAW* instance) {
free(instance);
}
-View* subghz_read_raw_get_view(SubghzReadRAW* instance) {
+View* subghz_read_raw_get_view(SubGhzReadRAW* instance) {
furi_assert(instance);
return instance->view;
}
diff --git a/applications/subghz/views/subghz_read_raw.h b/applications/subghz/views/subghz_read_raw.h
index 443d0185..db75f1b4 100644
--- a/applications/subghz/views/subghz_read_raw.h
+++ b/applications/subghz/views/subghz_read_raw.h
@@ -3,48 +3,48 @@
#include <gui/view.h>
#include "../helpers/subghz_custom_event.h"
-typedef struct SubghzReadRAW SubghzReadRAW;
+typedef struct SubGhzReadRAW SubGhzReadRAW;
-typedef void (*SubghzReadRAWCallback)(SubghzCustomEvent event, void* context);
+typedef void (*SubGhzReadRAWCallback)(SubGhzCustomEvent event, void* context);
typedef enum {
- SubghzReadRAWStatusStart,
- SubghzReadRAWStatusIDLE,
- SubghzReadRAWStatusREC,
- SubghzReadRAWStatusTX,
- SubghzReadRAWStatusTXRepeat,
-
- SubghzReadRAWStatusLoadKeyIDLE,
- SubghzReadRAWStatusLoadKeyTX,
- SubghzReadRAWStatusLoadKeyTXRepeat,
- SubghzReadRAWStatusSaveKey,
-} SubghzReadRAWStatus;
+ SubGhzReadRAWStatusStart,
+ SubGhzReadRAWStatusIDLE,
+ SubGhzReadRAWStatusREC,
+ SubGhzReadRAWStatusTX,
+ SubGhzReadRAWStatusTXRepeat,
+
+ SubGhzReadRAWStatusLoadKeyIDLE,
+ SubGhzReadRAWStatusLoadKeyTX,
+ SubGhzReadRAWStatusLoadKeyTXRepeat,
+ SubGhzReadRAWStatusSaveKey,
+} SubGhzReadRAWStatus;
void subghz_read_raw_set_callback(
- SubghzReadRAW* subghz_read_raw,
- SubghzReadRAWCallback callback,
+ SubGhzReadRAW* subghz_read_raw,
+ SubGhzReadRAWCallback callback,
void* context);
-SubghzReadRAW* subghz_read_raw_alloc();
+SubGhzReadRAW* subghz_read_raw_alloc();
-void subghz_read_raw_free(SubghzReadRAW* subghz_static);
+void subghz_read_raw_free(SubGhzReadRAW* subghz_static);
void subghz_read_raw_add_data_statusbar(
- SubghzReadRAW* instance,
+ SubGhzReadRAW* instance,
const char* frequency_str,
const char* preset_str);
-void subghz_read_raw_update_sample_write(SubghzReadRAW* instance, size_t sample);
+void subghz_read_raw_update_sample_write(SubGhzReadRAW* instance, size_t sample);
-void subghz_read_raw_stop_send(SubghzReadRAW* instance);
+void subghz_read_raw_stop_send(SubGhzReadRAW* instance);
-void subghz_read_raw_update_sin(SubghzReadRAW* instance);
+void subghz_read_raw_update_sin(SubGhzReadRAW* instance);
-void subghz_read_raw_add_data_rssi(SubghzReadRAW* instance, float rssi);
+void subghz_read_raw_add_data_rssi(SubGhzReadRAW* instance, float rssi);
void subghz_read_raw_set_status(
- SubghzReadRAW* instance,
- SubghzReadRAWStatus satus,
+ SubGhzReadRAW* instance,
+ SubGhzReadRAWStatus satus,
const char* file_name);
-View* subghz_read_raw_get_view(SubghzReadRAW* subghz_static);
+View* subghz_read_raw_get_view(SubGhzReadRAW* subghz_static);
diff --git a/applications/subghz/views/subghz_receiver.h b/applications/subghz/views/subghz_receiver.h
deleted file mode 100644
index e26ee2c2..00000000
--- a/applications/subghz/views/subghz_receiver.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#pragma once
-
-#include <gui/view.h>
-#include "../helpers/subghz_custom_event.h"
-
-typedef struct SubghzReceiver SubghzReceiver;
-
-typedef void (*SubghzReceiverCallback)(SubghzCustomEvent event, void* context);
-
-void subghz_receiver_set_callback(
- SubghzReceiver* subghz_receiver,
- SubghzReceiverCallback callback,
- void* context);
-
-SubghzReceiver* subghz_receiver_alloc();
-
-void subghz_receiver_free(SubghzReceiver* subghz_receiver);
-
-View* subghz_receiver_get_view(SubghzReceiver* subghz_receiver);
-
-void subghz_receiver_add_data_statusbar(
- SubghzReceiver* subghz_receiver,
- const char* frequency_str,
- const char* preset_str,
- const char* history_stat_str);
-
-void subghz_receiver_add_item_to_menu(
- SubghzReceiver* subghz_receiver,
- const char* name,
- uint8_t type);
-
-uint16_t subghz_receiver_get_idx_menu(SubghzReceiver* subghz_receiver);
-
-void subghz_receiver_set_idx_menu(SubghzReceiver* subghz_receiver, uint16_t idx);
-
-void subghz_receiver_exit(void* context); \ No newline at end of file
diff --git a/applications/subghz/views/subghz_test_carrier.c b/applications/subghz/views/subghz_test_carrier.c
index 82d95bff..6c0a8d16 100644
--- a/applications/subghz/views/subghz_test_carrier.c
+++ b/applications/subghz/views/subghz_test_carrier.c
@@ -7,29 +7,29 @@
#include <furi_hal.h>
#include <input/input.h>
-struct SubghzTestCarrier {
+struct SubGhzTestCarrier {
View* view;
osTimerId_t timer;
- SubghzTestCarrierCallback callback;
+ SubGhzTestCarrierCallback callback;
void* context;
};
typedef enum {
- SubghzTestCarrierModelStatusRx,
- SubghzTestCarrierModelStatusTx,
-} SubghzTestCarrierModelStatus;
+ SubGhzTestCarrierModelStatusRx,
+ SubGhzTestCarrierModelStatusTx,
+} SubGhzTestCarrierModelStatus;
typedef struct {
uint8_t frequency;
uint32_t real_frequency;
FuriHalSubGhzPath path;
float rssi;
- SubghzTestCarrierModelStatus status;
-} SubghzTestCarrierModel;
+ SubGhzTestCarrierModelStatus status;
+} SubGhzTestCarrierModel;
void subghz_test_carrier_set_callback(
- SubghzTestCarrier* subghz_test_carrier,
- SubghzTestCarrierCallback callback,
+ SubGhzTestCarrier* subghz_test_carrier,
+ SubGhzTestCarrierCallback callback,
void* context) {
furi_assert(subghz_test_carrier);
furi_assert(callback);
@@ -37,7 +37,7 @@ void subghz_test_carrier_set_callback(
subghz_test_carrier->context = context;
}
-void subghz_test_carrier_draw(Canvas* canvas, SubghzTestCarrierModel* model) {
+void subghz_test_carrier_draw(Canvas* canvas, SubGhzTestCarrierModel* model) {
char buffer[64];
canvas_set_color(canvas, ColorBlack);
@@ -67,7 +67,7 @@ void subghz_test_carrier_draw(Canvas* canvas, SubghzTestCarrierModel* model) {
}
snprintf(buffer, sizeof(buffer), "Path: %d - %s", model->path, path_name);
canvas_draw_str(canvas, 0, 31, buffer);
- if(model->status == SubghzTestCarrierModelStatusRx) {
+ if(model->status == SubGhzTestCarrierModelStatusRx) {
snprintf(
buffer,
sizeof(buffer),
@@ -82,14 +82,14 @@ void subghz_test_carrier_draw(Canvas* canvas, SubghzTestCarrierModel* model) {
bool subghz_test_carrier_input(InputEvent* event, void* context) {
furi_assert(context);
- SubghzTestCarrier* subghz_test_carrier = context;
+ SubGhzTestCarrier* subghz_test_carrier = context;
if(event->key == InputKeyBack || event->type != InputTypeShort) {
return false;
}
with_view_model(
- subghz_test_carrier->view, (SubghzTestCarrierModel * model) {
+ subghz_test_carrier->view, (SubGhzTestCarrierModel * model) {
furi_hal_subghz_idle();
if(event->key == InputKeyLeft) {
@@ -101,10 +101,10 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
} else if(event->key == InputKeyUp) {
if(model->path < FuriHalSubGhzPath868) model->path++;
} else if(event->key == InputKeyOk) {
- if(model->status == SubghzTestCarrierModelStatusTx) {
- model->status = SubghzTestCarrierModelStatusRx;
+ if(model->status == SubGhzTestCarrierModelStatusTx) {
+ model->status = SubGhzTestCarrierModelStatusRx;
} else {
- model->status = SubghzTestCarrierModelStatusTx;
+ model->status = SubGhzTestCarrierModelStatusTx;
}
}
@@ -112,7 +112,7 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
furi_hal_subghz_set_frequency(subghz_frequencies_testing[model->frequency]);
furi_hal_subghz_set_path(model->path);
- if(model->status == SubghzTestCarrierModelStatusRx) {
+ if(model->status == SubGhzTestCarrierModelStatusRx) {
hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
furi_hal_subghz_rx();
} else {
@@ -121,7 +121,7 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
if(!furi_hal_subghz_tx()) {
hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
subghz_test_carrier->callback(
- SubghzTestCarrierEventOnlyRx, subghz_test_carrier->context);
+ SubGhzTestCarrierEventOnlyRx, subghz_test_carrier->context);
}
}
@@ -133,7 +133,7 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
void subghz_test_carrier_enter(void* context) {
furi_assert(context);
- SubghzTestCarrier* subghz_test_carrier = context;
+ SubGhzTestCarrier* subghz_test_carrier = context;
furi_hal_subghz_reset();
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
@@ -141,13 +141,13 @@ void subghz_test_carrier_enter(void* context) {
hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
with_view_model(
- subghz_test_carrier->view, (SubghzTestCarrierModel * model) {
+ subghz_test_carrier->view, (SubGhzTestCarrierModel * model) {
model->frequency = subghz_frequencies_433_92_testing; // 433
model->real_frequency =
furi_hal_subghz_set_frequency(subghz_frequencies_testing[model->frequency]);
model->path = FuriHalSubGhzPathIsolate; // isolate
model->rssi = 0.0f;
- model->status = SubghzTestCarrierModelStatusRx;
+ model->status = SubGhzTestCarrierModelStatusRx;
return true;
});
@@ -158,7 +158,7 @@ void subghz_test_carrier_enter(void* context) {
void subghz_test_carrier_exit(void* context) {
furi_assert(context);
- SubghzTestCarrier* subghz_test_carrier = context;
+ SubGhzTestCarrier* subghz_test_carrier = context;
osTimerStop(subghz_test_carrier->timer);
@@ -168,11 +168,11 @@ void subghz_test_carrier_exit(void* context) {
void subghz_test_carrier_rssi_timer_callback(void* context) {
furi_assert(context);
- SubghzTestCarrier* subghz_test_carrier = context;
+ SubGhzTestCarrier* subghz_test_carrier = context;
with_view_model(
- subghz_test_carrier->view, (SubghzTestCarrierModel * model) {
- if(model->status == SubghzTestCarrierModelStatusRx) {
+ subghz_test_carrier->view, (SubGhzTestCarrierModel * model) {
+ if(model->status == SubGhzTestCarrierModelStatusRx) {
model->rssi = furi_hal_subghz_get_rssi();
return true;
}
@@ -180,13 +180,13 @@ void subghz_test_carrier_rssi_timer_callback(void* context) {
});
}
-SubghzTestCarrier* subghz_test_carrier_alloc() {
- SubghzTestCarrier* subghz_test_carrier = malloc(sizeof(SubghzTestCarrier));
+SubGhzTestCarrier* subghz_test_carrier_alloc() {
+ SubGhzTestCarrier* subghz_test_carrier = malloc(sizeof(SubGhzTestCarrier));
// View allocation and configuration
subghz_test_carrier->view = view_alloc();
view_allocate_model(
- subghz_test_carrier->view, ViewModelTypeLocking, sizeof(SubghzTestCarrierModel));
+ subghz_test_carrier->view, ViewModelTypeLocking, sizeof(SubGhzTestCarrierModel));
view_set_context(subghz_test_carrier->view, subghz_test_carrier);
view_set_draw_callback(subghz_test_carrier->view, (ViewDrawCallback)subghz_test_carrier_draw);
view_set_input_callback(subghz_test_carrier->view, subghz_test_carrier_input);
@@ -199,14 +199,14 @@ SubghzTestCarrier* subghz_test_carrier_alloc() {
return subghz_test_carrier;
}
-void subghz_test_carrier_free(SubghzTestCarrier* subghz_test_carrier) {
+void subghz_test_carrier_free(SubGhzTestCarrier* subghz_test_carrier) {
furi_assert(subghz_test_carrier);
osTimerDelete(subghz_test_carrier->timer);
view_free(subghz_test_carrier->view);
free(subghz_test_carrier);
}
-View* subghz_test_carrier_get_view(SubghzTestCarrier* subghz_test_carrier) {
+View* subghz_test_carrier_get_view(SubGhzTestCarrier* subghz_test_carrier) {
furi_assert(subghz_test_carrier);
return subghz_test_carrier->view;
}
diff --git a/applications/subghz/views/subghz_test_carrier.h b/applications/subghz/views/subghz_test_carrier.h
index b4522345..7db3343e 100644
--- a/applications/subghz/views/subghz_test_carrier.h
+++ b/applications/subghz/views/subghz_test_carrier.h
@@ -3,20 +3,20 @@
#include <gui/view.h>
typedef enum {
- SubghzTestCarrierEventOnlyRx,
-} SubghzTestCarrierEvent;
+ SubGhzTestCarrierEventOnlyRx,
+} SubGhzTestCarrierEvent;
-typedef struct SubghzTestCarrier SubghzTestCarrier;
+typedef struct SubGhzTestCarrier SubGhzTestCarrier;
-typedef void (*SubghzTestCarrierCallback)(SubghzTestCarrierEvent event, void* context);
+typedef void (*SubGhzTestCarrierCallback)(SubGhzTestCarrierEvent event, void* context);
void subghz_test_carrier_set_callback(
- SubghzTestCarrier* subghz_test_carrier,
- SubghzTestCarrierCallback callback,
+ SubGhzTestCarrier* subghz_test_carrier,
+ SubGhzTestCarrierCallback callback,
void* context);
-SubghzTestCarrier* subghz_test_carrier_alloc();
+SubGhzTestCarrier* subghz_test_carrier_alloc();
-void subghz_test_carrier_free(SubghzTestCarrier* subghz_test_carrier);
+void subghz_test_carrier_free(SubGhzTestCarrier* subghz_test_carrier);
-View* subghz_test_carrier_get_view(SubghzTestCarrier* subghz_test_carrier);
+View* subghz_test_carrier_get_view(SubGhzTestCarrier* subghz_test_carrier);
diff --git a/applications/subghz/views/subghz_test_packet.c b/applications/subghz/views/subghz_test_packet.c
index c856dc74..509d5c0a 100644
--- a/applications/subghz/views/subghz_test_packet.c
+++ b/applications/subghz/views/subghz_test_packet.c
@@ -7,26 +7,26 @@
#include <furi_hal.h>
#include <input/input.h>
#include <toolbox/level_duration.h>
-#include <lib/subghz/protocols/subghz_protocol_princeton.h>
+#include <lib/subghz/protocols/princeton_for_testing.h>
#define SUBGHZ_TEST_PACKET_COUNT 500
-struct SubghzTestPacket {
+struct SubGhzTestPacket {
View* view;
osTimerId_t timer;
SubGhzDecoderPrinceton* decoder;
SubGhzEncoderPrinceton* encoder;
volatile size_t packet_rx;
- SubghzTestPacketCallback callback;
+ SubGhzTestPacketCallback callback;
void* context;
};
typedef enum {
- SubghzTestPacketModelStatusRx,
- SubghzTestPacketModelStatusOnlyRx,
- SubghzTestPacketModelStatusTx,
-} SubghzTestPacketModelStatus;
+ SubGhzTestPacketModelStatusRx,
+ SubGhzTestPacketModelStatusOnlyRx,
+ SubGhzTestPacketModelStatusTx,
+} SubGhzTestPacketModelStatus;
typedef struct {
uint8_t frequency;
@@ -34,14 +34,14 @@ typedef struct {
FuriHalSubGhzPath path;
float rssi;
size_t packets;
- SubghzTestPacketModelStatus status;
-} SubghzTestPacketModel;
+ SubGhzTestPacketModelStatus status;
+} SubGhzTestPacketModel;
volatile bool subghz_test_packet_overrun = false;
void subghz_test_packet_set_callback(
- SubghzTestPacket* subghz_test_packet,
- SubghzTestPacketCallback callback,
+ SubGhzTestPacket* subghz_test_packet,
+ SubGhzTestPacketCallback callback,
void* context) {
furi_assert(subghz_test_packet);
furi_assert(callback);
@@ -51,34 +51,36 @@ void subghz_test_packet_set_callback(
static void subghz_test_packet_rx_callback(bool level, uint32_t duration, void* context) {
furi_assert(context);
- SubghzTestPacket* instance = context;
- subghz_decoder_princeton_parse(instance->decoder, level, duration);
+ SubGhzTestPacket* instance = context;
+ subghz_decoder_princeton_for_testing_parse(instance->decoder, level, duration);
}
-static void subghz_test_packet_rx_pt_callback(SubGhzProtocolCommon* parser, void* context) {
+//todo
+static void subghz_test_packet_rx_pt_callback(SubGhzDecoderPrinceton* parser, void* context) {
furi_assert(context);
- SubghzTestPacket* instance = context;
+ SubGhzTestPacket* instance = context;
instance->packet_rx++;
}
static void subghz_test_packet_rssi_timer_callback(void* context) {
furi_assert(context);
- SubghzTestPacket* instance = context;
+ SubGhzTestPacket* instance = context;
with_view_model(
- instance->view, (SubghzTestPacketModel * model) {
- if(model->status == SubghzTestPacketModelStatusRx) {
+ instance->view, (SubGhzTestPacketModel * model) {
+ if(model->status == SubGhzTestPacketModelStatusRx) {
model->rssi = furi_hal_subghz_get_rssi();
model->packets = instance->packet_rx;
- } else if(model->status == SubghzTestPacketModelStatusTx) {
- model->packets = SUBGHZ_TEST_PACKET_COUNT -
- subghz_encoder_princeton_get_repeat_left(instance->encoder);
+ } else if(model->status == SubGhzTestPacketModelStatusTx) {
+ model->packets =
+ SUBGHZ_TEST_PACKET_COUNT -
+ subghz_encoder_princeton_for_testing_get_repeat_left(instance->encoder);
}
return true;
});
}
-static void subghz_test_packet_draw(Canvas* canvas, SubghzTestPacketModel* model) {
+static void subghz_test_packet_draw(Canvas* canvas, SubGhzTestPacketModel* model) {
char buffer[64];
canvas_set_color(canvas, ColorBlack);
@@ -112,7 +114,7 @@ static void subghz_test_packet_draw(Canvas* canvas, SubghzTestPacketModel* model
snprintf(buffer, sizeof(buffer), "Packets: %d", model->packets);
canvas_draw_str(canvas, 0, 42, buffer);
- if(model->status == SubghzTestPacketModelStatusRx) {
+ if(model->status == SubGhzTestPacketModelStatusRx) {
snprintf(
buffer,
sizeof(buffer),
@@ -127,18 +129,18 @@ static void subghz_test_packet_draw(Canvas* canvas, SubghzTestPacketModel* model
static bool subghz_test_packet_input(InputEvent* event, void* context) {
furi_assert(context);
- SubghzTestPacket* instance = context;
+ SubGhzTestPacket* instance = context;
if(event->key == InputKeyBack || event->type != InputTypeShort) {
return false;
}
with_view_model(
- instance->view, (SubghzTestPacketModel * model) {
- if(model->status == SubghzTestPacketModelStatusRx) {
+ instance->view, (SubGhzTestPacketModel * model) {
+ if(model->status == SubGhzTestPacketModelStatusRx) {
furi_hal_subghz_stop_async_rx();
- } else if(model->status == SubghzTestPacketModelStatusTx) {
- subghz_encoder_princeton_stop(instance->encoder, millis());
+ } else if(model->status == SubGhzTestPacketModelStatusTx) {
+ subghz_encoder_princeton_for_testing_stop(instance->encoder, millis());
furi_hal_subghz_stop_async_tx();
}
@@ -151,10 +153,10 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) {
} else if(event->key == InputKeyUp) {
if(model->path < FuriHalSubGhzPath868) model->path++;
} else if(event->key == InputKeyOk) {
- if(model->status == SubghzTestPacketModelStatusRx) {
- model->status = SubghzTestPacketModelStatusTx;
+ if(model->status == SubGhzTestPacketModelStatusRx) {
+ model->status = SubGhzTestPacketModelStatusTx;
} else {
- model->status = SubghzTestPacketModelStatusRx;
+ model->status = SubGhzTestPacketModelStatusRx;
}
}
@@ -162,18 +164,18 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) {
furi_hal_subghz_set_frequency(subghz_frequencies_testing[model->frequency]);
furi_hal_subghz_set_path(model->path);
- if(model->status == SubghzTestPacketModelStatusRx) {
+ if(model->status == SubGhzTestPacketModelStatusRx) {
furi_hal_subghz_start_async_rx(subghz_test_packet_rx_callback, instance);
} else {
- subghz_encoder_princeton_set(
+ subghz_encoder_princeton_for_testing_set(
instance->encoder,
0x00AABBCC,
SUBGHZ_TEST_PACKET_COUNT,
subghz_frequencies_testing[model->frequency]);
if(!furi_hal_subghz_start_async_tx(
- subghz_encoder_princeton_yield, instance->encoder)) {
- model->status = SubghzTestPacketModelStatusOnlyRx;
- instance->callback(SubghzTestPacketEventOnlyRx, instance->context);
+ subghz_encoder_princeton_for_testing_yield, instance->encoder)) {
+ model->status = SubGhzTestPacketModelStatusOnlyRx;
+ instance->callback(SubGhzTestPacketEventOnlyRx, instance->context);
}
}
@@ -185,19 +187,19 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) {
void subghz_test_packet_enter(void* context) {
furi_assert(context);
- SubghzTestPacket* instance = context;
+ SubGhzTestPacket* instance = context;
furi_hal_subghz_reset();
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
with_view_model(
- instance->view, (SubghzTestPacketModel * model) {
+ instance->view, (SubGhzTestPacketModel * model) {
model->frequency = subghz_frequencies_433_92_testing;
model->real_frequency =
furi_hal_subghz_set_frequency(subghz_frequencies_testing[model->frequency]);
model->path = FuriHalSubGhzPathIsolate; // isolate
model->rssi = 0.0f;
- model->status = SubghzTestPacketModelStatusRx;
+ model->status = SubGhzTestPacketModelStatusRx;
return true;
});
@@ -208,17 +210,17 @@ void subghz_test_packet_enter(void* context) {
void subghz_test_packet_exit(void* context) {
furi_assert(context);
- SubghzTestPacket* instance = context;
+ SubGhzTestPacket* instance = context;
osTimerStop(instance->timer);
// Reinitialize IC to default state
with_view_model(
- instance->view, (SubghzTestPacketModel * model) {
- if(model->status == SubghzTestPacketModelStatusRx) {
+ instance->view, (SubGhzTestPacketModel * model) {
+ if(model->status == SubGhzTestPacketModelStatusRx) {
furi_hal_subghz_stop_async_rx();
- } else if(model->status == SubghzTestPacketModelStatusTx) {
- subghz_encoder_princeton_stop(instance->encoder, millis());
+ } else if(model->status == SubGhzTestPacketModelStatusTx) {
+ subghz_encoder_princeton_for_testing_stop(instance->encoder, millis());
furi_hal_subghz_stop_async_tx();
}
return true;
@@ -226,12 +228,12 @@ void subghz_test_packet_exit(void* context) {
furi_hal_subghz_sleep();
}
-SubghzTestPacket* subghz_test_packet_alloc() {
- SubghzTestPacket* instance = malloc(sizeof(SubghzTestPacket));
+SubGhzTestPacket* subghz_test_packet_alloc() {
+ SubGhzTestPacket* instance = malloc(sizeof(SubGhzTestPacket));
// View allocation and configuration
instance->view = view_alloc();
- view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(SubghzTestPacketModel));
+ view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(SubGhzTestPacketModel));
view_set_context(instance->view, instance);
view_set_draw_callback(instance->view, (ViewDrawCallback)subghz_test_packet_draw);
view_set_input_callback(instance->view, subghz_test_packet_input);
@@ -241,26 +243,26 @@ SubghzTestPacket* subghz_test_packet_alloc() {
instance->timer =
osTimerNew(subghz_test_packet_rssi_timer_callback, osTimerPeriodic, instance, NULL);
- instance->decoder = subghz_decoder_princeton_alloc();
- subghz_protocol_common_set_callback(
- (SubGhzProtocolCommon*)instance->decoder, subghz_test_packet_rx_pt_callback, instance);
- instance->encoder = subghz_encoder_princeton_alloc();
+ instance->decoder = subghz_decoder_princeton_for_testing_alloc();
+ subghz_decoder_princeton_for_testing_set_callback(
+ instance->decoder, subghz_test_packet_rx_pt_callback, instance);
+ instance->encoder = subghz_encoder_princeton_for_testing_alloc();
return instance;
}
-void subghz_test_packet_free(SubghzTestPacket* instance) {
+void subghz_test_packet_free(SubGhzTestPacket* instance) {
furi_assert(instance);
- subghz_decoder_princeton_free(instance->decoder);
- subghz_encoder_princeton_free(instance->encoder);
+ subghz_decoder_princeton_for_testing_free(instance->decoder);
+ subghz_encoder_princeton_for_testing_free(instance->encoder);
osTimerDelete(instance->timer);
view_free(instance->view);
free(instance);
}
-View* subghz_test_packet_get_view(SubghzTestPacket* instance) {
+View* subghz_test_packet_get_view(SubGhzTestPacket* instance) {
furi_assert(instance);
return instance->view;
}
diff --git a/applications/subghz/views/subghz_test_packet.h b/applications/subghz/views/subghz_test_packet.h
index bd861ee9..f384cf4f 100644
--- a/applications/subghz/views/subghz_test_packet.h
+++ b/applications/subghz/views/subghz_test_packet.h
@@ -3,20 +3,20 @@
#include <gui/view.h>
typedef enum {
- SubghzTestPacketEventOnlyRx,
-} SubghzTestPacketEvent;
+ SubGhzTestPacketEventOnlyRx,
+} SubGhzTestPacketEvent;
-typedef struct SubghzTestPacket SubghzTestPacket;
+typedef struct SubGhzTestPacket SubGhzTestPacket;
-typedef void (*SubghzTestPacketCallback)(SubghzTestPacketEvent event, void* context);
+typedef void (*SubGhzTestPacketCallback)(SubGhzTestPacketEvent event, void* context);
void subghz_test_packet_set_callback(
- SubghzTestPacket* subghz_test_packet,
- SubghzTestPacketCallback callback,
+ SubGhzTestPacket* subghz_test_packet,
+ SubGhzTestPacketCallback callback,
void* context);
-SubghzTestPacket* subghz_test_packet_alloc();
+SubGhzTestPacket* subghz_test_packet_alloc();
-void subghz_test_packet_free(SubghzTestPacket* subghz_test_packet);
+void subghz_test_packet_free(SubGhzTestPacket* subghz_test_packet);
-View* subghz_test_packet_get_view(SubghzTestPacket* subghz_test_packet);
+View* subghz_test_packet_get_view(SubGhzTestPacket* subghz_test_packet);
diff --git a/applications/subghz/views/subghz_test_static.c b/applications/subghz/views/subghz_test_static.c
index 35001bdc..aa564fd9 100644
--- a/applications/subghz/views/subghz_test_static.c
+++ b/applications/subghz/views/subghz_test_static.c
@@ -7,14 +7,14 @@
#include <furi_hal.h>
#include <input/input.h>
#include <notification/notification_messages.h>
-#include <lib/subghz/protocols/subghz_protocol_princeton.h>
+#include <lib/subghz/protocols/princeton_for_testing.h>
#define TAG "SubGhzTestStatic"
typedef enum {
- SubghzTestStaticStatusIDLE,
- SubghzTestStaticStatusTX,
-} SubghzTestStaticStatus;
+ SubGhzTestStaticStatusIDLE,
+ SubGhzTestStaticStatusTX,
+} SubGhzTestStaticStatus;
static const uint32_t subghz_test_static_keys[] = {
0x0074BADE,
@@ -23,11 +23,11 @@ static const uint32_t subghz_test_static_keys[] = {
0x00E34A4E,
};
-struct SubghzTestStatic {
+struct SubGhzTestStatic {
View* view;
- SubghzTestStaticStatus satus_tx;
+ SubGhzTestStaticStatus satus_tx;
SubGhzEncoderPrinceton* encoder;
- SubghzTestStaticCallback callback;
+ SubGhzTestStaticCallback callback;
void* context;
};
@@ -35,11 +35,11 @@ typedef struct {
uint8_t frequency;
uint32_t real_frequency;
uint8_t button;
-} SubghzTestStaticModel;
+} SubGhzTestStaticModel;
void subghz_test_static_set_callback(
- SubghzTestStatic* subghz_test_static,
- SubghzTestStaticCallback callback,
+ SubGhzTestStatic* subghz_test_static,
+ SubGhzTestStaticCallback callback,
void* context) {
furi_assert(subghz_test_static);
furi_assert(callback);
@@ -47,7 +47,7 @@ void subghz_test_static_set_callback(
subghz_test_static->context = context;
}
-void subghz_test_static_draw(Canvas* canvas, SubghzTestStaticModel* model) {
+void subghz_test_static_draw(Canvas* canvas, SubGhzTestStaticModel* model) {
char buffer[64];
canvas_set_color(canvas, ColorBlack);
@@ -70,14 +70,14 @@ void subghz_test_static_draw(Canvas* canvas, SubghzTestStaticModel* model) {
bool subghz_test_static_input(InputEvent* event, void* context) {
furi_assert(context);
- SubghzTestStatic* instance = context;
+ SubGhzTestStatic* instance = context;
if(event->key == InputKeyBack) {
return false;
}
with_view_model(
- instance->view, (SubghzTestStaticModel * model) {
+ instance->view, (SubGhzTestStaticModel * model) {
if(event->type == InputTypeShort) {
if(event->key == InputKeyLeft) {
if(model->frequency > 0) model->frequency--;
@@ -99,31 +99,31 @@ bool subghz_test_static_input(InputEvent* event, void* context) {
furi_hal_subghz_set_frequency_and_path(
subghz_frequencies_testing[model->frequency]);
if(!furi_hal_subghz_tx()) {
- instance->callback(SubghzTestStaticEventOnlyRx, instance->context);
+ instance->callback(SubGhzTestStaticEventOnlyRx, instance->context);
} else {
notification_message_block(notification, &sequence_set_red_255);
FURI_LOG_I(TAG, "TX Start");
- subghz_encoder_princeton_set(
+ subghz_encoder_princeton_for_testing_set(
instance->encoder,
subghz_test_static_keys[model->button],
10000,
subghz_frequencies_testing[model->frequency]);
furi_hal_subghz_start_async_tx(
- subghz_encoder_princeton_yield, instance->encoder);
- instance->satus_tx = SubghzTestStaticStatusTX;
+ subghz_encoder_princeton_for_testing_yield, instance->encoder);
+ instance->satus_tx = SubGhzTestStaticStatusTX;
}
} else if(event->type == InputTypeRelease) {
- if(instance->satus_tx == SubghzTestStaticStatusTX) {
+ if(instance->satus_tx == SubGhzTestStaticStatusTX) {
FURI_LOG_I(TAG, "TX Stop");
- subghz_encoder_princeton_stop(instance->encoder, millis());
- subghz_encoder_princeton_print_log(instance->encoder);
+ subghz_encoder_princeton_for_testing_stop(instance->encoder, millis());
+ subghz_encoder_princeton_for_testing_print_log(instance->encoder);
furi_hal_subghz_stop_async_tx();
notification_message(notification, &sequence_reset_red);
}
- instance->satus_tx = SubghzTestStaticStatusIDLE;
+ instance->satus_tx = SubGhzTestStaticStatusIDLE;
}
furi_record_close("notification");
}
@@ -136,17 +136,17 @@ bool subghz_test_static_input(InputEvent* event, void* context) {
void subghz_test_static_enter(void* context) {
furi_assert(context);
- SubghzTestStatic* instance = context;
+ SubGhzTestStatic* instance = context;
furi_hal_subghz_reset();
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
hal_gpio_write(&gpio_cc1101_g0, false);
- instance->satus_tx = SubghzTestStaticStatusIDLE;
+ instance->satus_tx = SubGhzTestStaticStatusIDLE;
with_view_model(
- instance->view, (SubghzTestStaticModel * model) {
+ instance->view, (SubGhzTestStaticModel * model) {
model->frequency = subghz_frequencies_433_92_testing;
model->real_frequency = subghz_frequencies_testing[model->frequency];
model->button = 0;
@@ -160,31 +160,31 @@ void subghz_test_static_exit(void* context) {
furi_hal_subghz_sleep();
}
-SubghzTestStatic* subghz_test_static_alloc() {
- SubghzTestStatic* instance = malloc(sizeof(SubghzTestStatic));
+SubGhzTestStatic* subghz_test_static_alloc() {
+ SubGhzTestStatic* instance = malloc(sizeof(SubGhzTestStatic));
// View allocation and configuration
instance->view = view_alloc();
- view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(SubghzTestStaticModel));
+ view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(SubGhzTestStaticModel));
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);
- instance->encoder = subghz_encoder_princeton_alloc();
+ instance->encoder = subghz_encoder_princeton_for_testing_alloc();
return instance;
}
-void subghz_test_static_free(SubghzTestStatic* instance) {
+void subghz_test_static_free(SubGhzTestStatic* instance) {
furi_assert(instance);
- subghz_encoder_princeton_free(instance->encoder);
+ subghz_encoder_princeton_for_testing_free(instance->encoder);
view_free(instance->view);
free(instance);
}
-View* subghz_test_static_get_view(SubghzTestStatic* instance) {
+View* subghz_test_static_get_view(SubGhzTestStatic* instance) {
furi_assert(instance);
return instance->view;
}
diff --git a/applications/subghz/views/subghz_test_static.h b/applications/subghz/views/subghz_test_static.h
index 48346d8a..90203643 100644
--- a/applications/subghz/views/subghz_test_static.h
+++ b/applications/subghz/views/subghz_test_static.h
@@ -3,20 +3,20 @@
#include <gui/view.h>
typedef enum {
- SubghzTestStaticEventOnlyRx,
-} SubghzTestStaticEvent;
+ SubGhzTestStaticEventOnlyRx,
+} SubGhzTestStaticEvent;
-typedef struct SubghzTestStatic SubghzTestStatic;
+typedef struct SubGhzTestStatic SubGhzTestStatic;
-typedef void (*SubghzTestStaticCallback)(SubghzTestStaticEvent event, void* context);
+typedef void (*SubGhzTestStaticCallback)(SubGhzTestStaticEvent event, void* context);
void subghz_test_static_set_callback(
- SubghzTestStatic* subghz_test_static,
- SubghzTestStaticCallback callback,
+ SubGhzTestStatic* subghz_test_static,
+ SubGhzTestStaticCallback callback,
void* context);
-SubghzTestStatic* subghz_test_static_alloc();
+SubGhzTestStatic* subghz_test_static_alloc();
-void subghz_test_static_free(SubghzTestStatic* subghz_static);
+void subghz_test_static_free(SubGhzTestStatic* subghz_static);
-View* subghz_test_static_get_view(SubghzTestStatic* subghz_static);
+View* subghz_test_static_get_view(SubGhzTestStatic* subghz_static);
diff --git a/applications/subghz/views/subghz_transmitter.h b/applications/subghz/views/subghz_transmitter.h
deleted file mode 100644
index 995e08f6..00000000
--- a/applications/subghz/views/subghz_transmitter.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include <gui/view.h>
-#include "../helpers/subghz_custom_event.h"
-
-typedef struct SubghzTransmitter SubghzTransmitter;
-
-typedef void (*SubghzTransmitterCallback)(SubghzCustomEvent event, void* context);
-
-void subghz_transmitter_set_callback(
- SubghzTransmitter* subghz_transmitter,
- SubghzTransmitterCallback callback,
- void* context);
-
-SubghzTransmitter* subghz_transmitter_alloc();
-
-void subghz_transmitter_free(SubghzTransmitter* subghz_transmitter);
-
-View* subghz_transmitter_get_view(SubghzTransmitter* subghz_transmitter);
-
-void subghz_transmitter_add_data_to_show(
- SubghzTransmitter* subghz_transmitter,
- const char* key_str,
- const char* frequency_str,
- const char* preset_str,
- uint8_t show_button);
diff --git a/applications/subghz/views/subghz_transmitter.c b/applications/subghz/views/transmitter.c
index f1afccfa..3113e31f 100644
--- a/applications/subghz/views/subghz_transmitter.c
+++ b/applications/subghz/views/transmitter.c
@@ -1,12 +1,12 @@
-#include "subghz_transmitter.h"
+#include "transmitter.h"
#include "../subghz_i.h"
#include <input/input.h>
#include <gui/elements.h>
-struct SubghzTransmitter {
+struct SubGhzViewTransmitter {
View* view;
- SubghzTransmitterCallback callback;
+ SubGhzViewTransmitterCallback callback;
void* context;
};
@@ -15,11 +15,11 @@ typedef struct {
string_t preset_str;
string_t key_str;
uint8_t show_button;
-} SubghzTransmitterModel;
+} SubGhzViewTransmitterModel;
-void subghz_transmitter_set_callback(
- SubghzTransmitter* subghz_transmitter,
- SubghzTransmitterCallback callback,
+void subghz_view_transmitter_set_callback(
+ SubGhzViewTransmitter* subghz_transmitter,
+ SubGhzViewTransmitterCallback callback,
void* context) {
furi_assert(subghz_transmitter);
@@ -27,15 +27,15 @@ void subghz_transmitter_set_callback(
subghz_transmitter->context = context;
}
-void subghz_transmitter_add_data_to_show(
- SubghzTransmitter* subghz_transmitter,
+void subghz_view_transmitter_add_data_to_show(
+ SubGhzViewTransmitter* subghz_transmitter,
const char* key_str,
const char* frequency_str,
const char* preset_str,
uint8_t show_button) {
furi_assert(subghz_transmitter);
with_view_model(
- subghz_transmitter->view, (SubghzTransmitterModel * model) {
+ subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
string_set(model->key_str, key_str);
string_set(model->frequency_str, frequency_str);
string_set(model->preset_str, preset_str);
@@ -44,7 +44,7 @@ void subghz_transmitter_add_data_to_show(
});
}
-static void subghz_transmitter_button_right(Canvas* canvas, const char* str) {
+static void subghz_view_transmitter_button_right(Canvas* canvas, const char* str) {
const uint8_t button_height = 13;
const uint8_t vertical_offset = 3;
const uint8_t horizontal_offset = 1;
@@ -75,24 +75,24 @@ static void subghz_transmitter_button_right(Canvas* canvas, const char* str) {
canvas_invert_color(canvas);
}
-void subghz_transmitter_draw(Canvas* canvas, SubghzTransmitterModel* model) {
+void subghz_view_transmitter_draw(Canvas* canvas, SubGhzViewTransmitterModel* model) {
canvas_clear(canvas);
canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontSecondary);
elements_multiline_text(canvas, 0, 8, string_get_cstr(model->key_str));
canvas_draw_str(canvas, 78, 8, string_get_cstr(model->frequency_str));
canvas_draw_str(canvas, 113, 8, string_get_cstr(model->preset_str));
- if(model->show_button) subghz_transmitter_button_right(canvas, "Send");
+ if(model->show_button) subghz_view_transmitter_button_right(canvas, "Send");
}
-bool subghz_transmitter_input(InputEvent* event, void* context) {
+bool subghz_view_transmitter_input(InputEvent* event, void* context) {
furi_assert(context);
- SubghzTransmitter* subghz_transmitter = context;
+ SubGhzViewTransmitter* subghz_transmitter = context;
bool can_be_sent = false;
if(event->key == InputKeyBack && event->type == InputTypeShort) {
with_view_model(
- subghz_transmitter->view, (SubghzTransmitterModel * model) {
+ subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
string_reset(model->frequency_str);
string_reset(model->preset_str);
string_reset(model->key_str);
@@ -103,7 +103,7 @@ bool subghz_transmitter_input(InputEvent* event, void* context) {
}
with_view_model(
- subghz_transmitter->view, (SubghzTransmitterModel * model) {
+ subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
if(model->show_button) {
can_be_sent = true;
}
@@ -112,42 +112,41 @@ bool subghz_transmitter_input(InputEvent* event, void* context) {
if(can_be_sent && event->key == InputKeyOk && event->type == InputTypePress) {
subghz_transmitter->callback(
- SubghzCustomEventViewTransmitterSendStart, subghz_transmitter->context);
+ SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context);
return true;
} else if(can_be_sent && event->key == InputKeyOk && event->type == InputTypeRelease) {
subghz_transmitter->callback(
- SubghzCustomEventViewTransmitterSendStop, subghz_transmitter->context);
+ SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context);
return true;
}
return true;
}
-void subghz_transmitter_enter(void* context) {
+void subghz_view_transmitter_enter(void* context) {
furi_assert(context);
- // SubghzTransmitter* subghz_transmitter = context;
}
-void subghz_transmitter_exit(void* context) {
+void subghz_view_transmitter_exit(void* context) {
furi_assert(context);
- // SubghzTransmitter* subghz_transmitter = context;
}
-SubghzTransmitter* subghz_transmitter_alloc() {
- SubghzTransmitter* subghz_transmitter = malloc(sizeof(SubghzTransmitter));
+SubGhzViewTransmitter* subghz_view_transmitter_alloc() {
+ SubGhzViewTransmitter* subghz_transmitter = malloc(sizeof(SubGhzViewTransmitter));
// View allocation and configuration
subghz_transmitter->view = view_alloc();
view_allocate_model(
- subghz_transmitter->view, ViewModelTypeLocking, sizeof(SubghzTransmitterModel));
+ subghz_transmitter->view, ViewModelTypeLocking, sizeof(SubGhzViewTransmitterModel));
view_set_context(subghz_transmitter->view, subghz_transmitter);
- view_set_draw_callback(subghz_transmitter->view, (ViewDrawCallback)subghz_transmitter_draw);
- view_set_input_callback(subghz_transmitter->view, subghz_transmitter_input);
- view_set_enter_callback(subghz_transmitter->view, subghz_transmitter_enter);
- view_set_exit_callback(subghz_transmitter->view, subghz_transmitter_exit);
+ view_set_draw_callback(
+ subghz_transmitter->view, (ViewDrawCallback)subghz_view_transmitter_draw);
+ view_set_input_callback(subghz_transmitter->view, subghz_view_transmitter_input);
+ view_set_enter_callback(subghz_transmitter->view, subghz_view_transmitter_enter);
+ view_set_exit_callback(subghz_transmitter->view, subghz_view_transmitter_exit);
with_view_model(
- subghz_transmitter->view, (SubghzTransmitterModel * model) {
+ subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
string_init(model->frequency_str);
string_init(model->preset_str);
string_init(model->key_str);
@@ -156,11 +155,11 @@ SubghzTransmitter* subghz_transmitter_alloc() {
return subghz_transmitter;
}
-void subghz_transmitter_free(SubghzTransmitter* subghz_transmitter) {
+void subghz_view_transmitter_free(SubGhzViewTransmitter* subghz_transmitter) {
furi_assert(subghz_transmitter);
with_view_model(
- subghz_transmitter->view, (SubghzTransmitterModel * model) {
+ subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
string_clear(model->frequency_str);
string_clear(model->preset_str);
string_clear(model->key_str);
@@ -170,7 +169,7 @@ void subghz_transmitter_free(SubghzTransmitter* subghz_transmitter) {
free(subghz_transmitter);
}
-View* subghz_transmitter_get_view(SubghzTransmitter* subghz_transmitter) {
+View* subghz_view_transmitter_get_view(SubGhzViewTransmitter* subghz_transmitter) {
furi_assert(subghz_transmitter);
return subghz_transmitter->view;
}
diff --git a/applications/subghz/views/transmitter.h b/applications/subghz/views/transmitter.h
new file mode 100644
index 00000000..64bcbd1a
--- /dev/null
+++ b/applications/subghz/views/transmitter.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <gui/view.h>
+#include "../helpers/subghz_custom_event.h"
+
+typedef struct SubGhzViewTransmitter SubGhzViewTransmitter;
+
+typedef void (*SubGhzViewTransmitterCallback)(SubGhzCustomEvent event, void* context);
+
+void subghz_view_transmitter_set_callback(
+ SubGhzViewTransmitter* subghz_transmitter,
+ SubGhzViewTransmitterCallback callback,
+ void* context);
+
+SubGhzViewTransmitter* subghz_view_transmitter_alloc();
+
+void subghz_view_transmitter_free(SubGhzViewTransmitter* subghz_transmitter);
+
+View* subghz_view_transmitter_get_view(SubGhzViewTransmitter* subghz_transmitter);
+
+void subghz_view_transmitter_add_data_to_show(
+ SubGhzViewTransmitter* subghz_transmitter,
+ const char* key_str,
+ const char* frequency_str,
+ const char* preset_str,
+ uint8_t show_button);