mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 22:38:36 -07:00
Move plugins to external folder
This commit is contained in:
211
applications/external/pocsag_pager/scenes/pocsag_pager_receiver.c
vendored
Normal file
211
applications/external/pocsag_pager/scenes/pocsag_pager_receiver.c
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
#include "../pocsag_pager_app_i.h"
|
||||
#include "../views/pocsag_pager_receiver.h"
|
||||
|
||||
static const NotificationSequence subghs_sequence_rx = {
|
||||
&message_green_255,
|
||||
|
||||
&message_vibro_on,
|
||||
&message_note_c6,
|
||||
&message_delay_50,
|
||||
&message_sound_off,
|
||||
&message_vibro_off,
|
||||
|
||||
&message_delay_50,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const NotificationSequence subghs_sequence_rx_locked = {
|
||||
&message_green_255,
|
||||
|
||||
&message_display_backlight_on,
|
||||
|
||||
&message_vibro_on,
|
||||
&message_note_c6,
|
||||
&message_delay_50,
|
||||
&message_sound_off,
|
||||
&message_vibro_off,
|
||||
|
||||
&message_delay_500,
|
||||
|
||||
&message_display_backlight_off,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void pocsag_pager_scene_receiver_update_statusbar(void* context) {
|
||||
POCSAGPagerApp* app = context;
|
||||
FuriString* history_stat_str;
|
||||
history_stat_str = furi_string_alloc();
|
||||
if(!pcsg_history_get_text_space_left(app->txrx->history, history_stat_str)) {
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
|
||||
pcsg_get_frequency_modulation(app, frequency_str, modulation_str);
|
||||
|
||||
pcsg_view_receiver_add_data_statusbar(
|
||||
app->pcsg_receiver,
|
||||
furi_string_get_cstr(frequency_str),
|
||||
furi_string_get_cstr(modulation_str),
|
||||
furi_string_get_cstr(history_stat_str));
|
||||
|
||||
furi_string_free(frequency_str);
|
||||
furi_string_free(modulation_str);
|
||||
} else {
|
||||
pcsg_view_receiver_add_data_statusbar(
|
||||
app->pcsg_receiver, furi_string_get_cstr(history_stat_str), "", "");
|
||||
}
|
||||
furi_string_free(history_stat_str);
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_receiver_callback(PCSGCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
POCSAGPagerApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
static void pocsag_pager_scene_receiver_add_to_history_callback(
|
||||
SubGhzReceiver* receiver,
|
||||
SubGhzProtocolDecoderBase* decoder_base,
|
||||
void* context) {
|
||||
furi_assert(context);
|
||||
POCSAGPagerApp* app = context;
|
||||
FuriString* str_buff;
|
||||
str_buff = furi_string_alloc();
|
||||
|
||||
if(pcsg_history_add_to_history(app->txrx->history, decoder_base, app->txrx->preset) ==
|
||||
PCSGHistoryStateAddKeyNewDada) {
|
||||
furi_string_reset(str_buff);
|
||||
|
||||
pcsg_history_get_text_item_menu(
|
||||
app->txrx->history, str_buff, pcsg_history_get_item(app->txrx->history) - 1);
|
||||
pcsg_view_receiver_add_item_to_menu(
|
||||
app->pcsg_receiver,
|
||||
furi_string_get_cstr(str_buff),
|
||||
pcsg_history_get_type_protocol(
|
||||
app->txrx->history, pcsg_history_get_item(app->txrx->history) - 1));
|
||||
|
||||
pocsag_pager_scene_receiver_update_statusbar(app);
|
||||
notification_message(app->notifications, &sequence_blink_green_10);
|
||||
if(app->lock != PCSGLockOn) {
|
||||
notification_message(app->notifications, &subghs_sequence_rx);
|
||||
} else {
|
||||
notification_message(app->notifications, &subghs_sequence_rx_locked);
|
||||
}
|
||||
}
|
||||
subghz_receiver_reset(receiver);
|
||||
furi_string_free(str_buff);
|
||||
app->txrx->rx_key_state = PCSGRxKeyStateAddKey;
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_receiver_on_enter(void* context) {
|
||||
POCSAGPagerApp* app = context;
|
||||
|
||||
FuriString* str_buff;
|
||||
str_buff = furi_string_alloc();
|
||||
|
||||
if(app->txrx->rx_key_state == PCSGRxKeyStateIDLE) {
|
||||
pcsg_preset_init(app, "FM95", 439987500, NULL, 0);
|
||||
pcsg_history_reset(app->txrx->history);
|
||||
app->txrx->rx_key_state = PCSGRxKeyStateStart;
|
||||
}
|
||||
|
||||
pcsg_view_receiver_set_lock(app->pcsg_receiver, app->lock);
|
||||
|
||||
//Load history to receiver
|
||||
pcsg_view_receiver_exit(app->pcsg_receiver);
|
||||
for(uint8_t i = 0; i < pcsg_history_get_item(app->txrx->history); i++) {
|
||||
furi_string_reset(str_buff);
|
||||
pcsg_history_get_text_item_menu(app->txrx->history, str_buff, i);
|
||||
pcsg_view_receiver_add_item_to_menu(
|
||||
app->pcsg_receiver,
|
||||
furi_string_get_cstr(str_buff),
|
||||
pcsg_history_get_type_protocol(app->txrx->history, i));
|
||||
app->txrx->rx_key_state = PCSGRxKeyStateAddKey;
|
||||
}
|
||||
furi_string_free(str_buff);
|
||||
pocsag_pager_scene_receiver_update_statusbar(app);
|
||||
|
||||
pcsg_view_receiver_set_callback(app->pcsg_receiver, pocsag_pager_scene_receiver_callback, app);
|
||||
subghz_receiver_set_rx_callback(
|
||||
app->txrx->receiver, pocsag_pager_scene_receiver_add_to_history_callback, app);
|
||||
|
||||
if(app->txrx->txrx_state == PCSGTxRxStateRx) {
|
||||
pcsg_rx_end(app);
|
||||
};
|
||||
if((app->txrx->txrx_state == PCSGTxRxStateIDLE) ||
|
||||
(app->txrx->txrx_state == PCSGTxRxStateSleep)) {
|
||||
pcsg_begin(
|
||||
app,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
app->setting, furi_string_get_cstr(app->txrx->preset->name)));
|
||||
|
||||
pcsg_rx(app, app->txrx->preset->frequency);
|
||||
}
|
||||
|
||||
pcsg_view_receiver_set_idx_menu(app->pcsg_receiver, app->txrx->idx_menu_chosen);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, POCSAGPagerViewReceiver);
|
||||
}
|
||||
|
||||
bool pocsag_pager_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
POCSAGPagerApp* app = context;
|
||||
bool consumed = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case PCSGCustomEventViewReceiverBack:
|
||||
// Stop CC1101 Rx
|
||||
if(app->txrx->txrx_state == PCSGTxRxStateRx) {
|
||||
pcsg_rx_end(app);
|
||||
pcsg_sleep(app);
|
||||
};
|
||||
app->txrx->hopper_state = PCSGHopperStateOFF;
|
||||
app->txrx->idx_menu_chosen = 0;
|
||||
subghz_receiver_set_rx_callback(app->txrx->receiver, NULL, app);
|
||||
|
||||
app->txrx->rx_key_state = PCSGRxKeyStateIDLE;
|
||||
pcsg_preset_init(app, "FM95", 439987500, NULL, 0);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, POCSAGPagerSceneStart);
|
||||
consumed = true;
|
||||
break;
|
||||
case PCSGCustomEventViewReceiverOK:
|
||||
app->txrx->idx_menu_chosen = pcsg_view_receiver_get_idx_menu(app->pcsg_receiver);
|
||||
scene_manager_next_scene(app->scene_manager, POCSAGPagerSceneReceiverInfo);
|
||||
consumed = true;
|
||||
break;
|
||||
case PCSGCustomEventViewReceiverConfig:
|
||||
app->txrx->idx_menu_chosen = pcsg_view_receiver_get_idx_menu(app->pcsg_receiver);
|
||||
scene_manager_next_scene(app->scene_manager, POCSAGPagerSceneReceiverConfig);
|
||||
consumed = true;
|
||||
break;
|
||||
case PCSGCustomEventViewReceiverOffDisplay:
|
||||
notification_message(app->notifications, &sequence_display_backlight_off);
|
||||
consumed = true;
|
||||
break;
|
||||
case PCSGCustomEventViewReceiverUnlock:
|
||||
app->lock = PCSGLockOff;
|
||||
consumed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
if(app->txrx->hopper_state != PCSGHopperStateOFF) {
|
||||
pcsg_hopper_update(app);
|
||||
pocsag_pager_scene_receiver_update_statusbar(app);
|
||||
}
|
||||
// Get current RSSI
|
||||
float rssi = furi_hal_subghz_get_rssi();
|
||||
pcsg_receiver_rssi(app->pcsg_receiver, rssi);
|
||||
|
||||
if(app->txrx->txrx_state == PCSGTxRxStateRx) {
|
||||
notification_message(app->notifications, &sequence_blink_cyan_10);
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_receiver_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
||||
30
applications/external/pocsag_pager/scenes/pocsag_pager_scene.c
vendored
Normal file
30
applications/external/pocsag_pager/scenes/pocsag_pager_scene.c
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "../pocsag_pager_app_i.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const pocsag_pager_scene_on_enter_handlers[])(void*) = {
|
||||
#include "pocsag_pager_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
|
||||
bool (*const pocsag_pager_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "pocsag_pager_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
|
||||
void (*const pocsag_pager_scene_on_exit_handlers[])(void* context) = {
|
||||
#include "pocsag_pager_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers pocsag_pager_scene_handlers = {
|
||||
.on_enter_handlers = pocsag_pager_scene_on_enter_handlers,
|
||||
.on_event_handlers = pocsag_pager_scene_on_event_handlers,
|
||||
.on_exit_handlers = pocsag_pager_scene_on_exit_handlers,
|
||||
.scene_num = POCSAGPagerSceneNum,
|
||||
};
|
||||
29
applications/external/pocsag_pager/scenes/pocsag_pager_scene.h
vendored
Normal file
29
applications/external/pocsag_pager/scenes/pocsag_pager_scene.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) POCSAGPagerScene##id,
|
||||
typedef enum {
|
||||
#include "pocsag_pager_scene_config.h"
|
||||
POCSAGPagerSceneNum,
|
||||
} POCSAGPagerScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers pocsag_pager_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "pocsag_pager_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) \
|
||||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
|
||||
#include "pocsag_pager_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
|
||||
#include "pocsag_pager_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
74
applications/external/pocsag_pager/scenes/pocsag_pager_scene_about.c
vendored
Normal file
74
applications/external/pocsag_pager/scenes/pocsag_pager_scene_about.c
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "../pocsag_pager_app_i.h"
|
||||
#include "../helpers/pocsag_pager_types.h"
|
||||
|
||||
void pocsag_pager_scene_about_widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
POCSAGPagerApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_about_on_enter(void* context) {
|
||||
POCSAGPagerApp* app = context;
|
||||
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
furi_string_printf(temp_str, "\e#%s\n", "Information");
|
||||
|
||||
furi_string_cat_printf(temp_str, "Version: %s\n", PCSG_VERSION_APP);
|
||||
furi_string_cat_printf(temp_str, "Developed by:\n%s\n\n", PCSG_DEVELOPED);
|
||||
furi_string_cat_printf(temp_str, "Github: %s\n\n", PCSG_GITHUB);
|
||||
|
||||
furi_string_cat_printf(temp_str, "\e#%s\n", "Description");
|
||||
furi_string_cat_printf(temp_str, "Receiving POCSAG Pager \nmessages\n\n");
|
||||
|
||||
furi_string_cat_printf(temp_str, "Supported protocols:\n");
|
||||
size_t i = 0;
|
||||
const char* protocol_name =
|
||||
subghz_environment_get_protocol_name_registry(app->txrx->environment, i++);
|
||||
do {
|
||||
furi_string_cat_printf(temp_str, "%s\n", protocol_name);
|
||||
protocol_name = subghz_environment_get_protocol_name_registry(app->txrx->environment, i++);
|
||||
} while(protocol_name != NULL);
|
||||
|
||||
widget_add_text_box_element(
|
||||
app->widget,
|
||||
0,
|
||||
0,
|
||||
128,
|
||||
14,
|
||||
AlignCenter,
|
||||
AlignBottom,
|
||||
"\e#\e! \e!\n",
|
||||
false);
|
||||
widget_add_text_box_element(
|
||||
app->widget,
|
||||
0,
|
||||
2,
|
||||
128,
|
||||
14,
|
||||
AlignCenter,
|
||||
AlignBottom,
|
||||
"\e#\e! POCSAG Pager \e!\n",
|
||||
false);
|
||||
widget_add_text_scroll_element(app->widget, 0, 16, 128, 50, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, POCSAGPagerViewWidget);
|
||||
}
|
||||
|
||||
bool pocsag_pager_scene_about_on_event(void* context, SceneManagerEvent event) {
|
||||
POCSAGPagerApp* app = context;
|
||||
bool consumed = false;
|
||||
UNUSED(app);
|
||||
UNUSED(event);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_about_on_exit(void* context) {
|
||||
POCSAGPagerApp* app = context;
|
||||
|
||||
// Clear views
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
5
applications/external/pocsag_pager/scenes/pocsag_pager_scene_config.h
vendored
Normal file
5
applications/external/pocsag_pager/scenes/pocsag_pager_scene_config.h
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
ADD_SCENE(pocsag_pager, start, Start)
|
||||
ADD_SCENE(pocsag_pager, about, About)
|
||||
ADD_SCENE(pocsag_pager, receiver, Receiver)
|
||||
ADD_SCENE(pocsag_pager, receiver_config, ReceiverConfig)
|
||||
ADD_SCENE(pocsag_pager, receiver_info, ReceiverInfo)
|
||||
221
applications/external/pocsag_pager/scenes/pocsag_pager_scene_receiver_config.c
vendored
Normal file
221
applications/external/pocsag_pager/scenes/pocsag_pager_scene_receiver_config.c
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
#include "../pocsag_pager_app_i.h"
|
||||
|
||||
enum PCSGSettingIndex {
|
||||
PCSGSettingIndexFrequency,
|
||||
PCSGSettingIndexHopping,
|
||||
PCSGSettingIndexModulation,
|
||||
PCSGSettingIndexLock,
|
||||
};
|
||||
|
||||
#define HOPPING_COUNT 2
|
||||
const char* const hopping_text[HOPPING_COUNT] = {
|
||||
"OFF",
|
||||
"ON",
|
||||
};
|
||||
const uint32_t hopping_value[HOPPING_COUNT] = {
|
||||
PCSGHopperStateOFF,
|
||||
PCSGHopperStateRunnig,
|
||||
};
|
||||
|
||||
uint8_t pocsag_pager_scene_receiver_config_next_frequency(const uint32_t value, void* context) {
|
||||
furi_assert(context);
|
||||
POCSAGPagerApp* app = context;
|
||||
uint8_t index = 0;
|
||||
for(uint8_t i = 0; i < subghz_setting_get_frequency_count(app->setting); i++) {
|
||||
if(value == subghz_setting_get_frequency(app->setting, i)) {
|
||||
index = i;
|
||||
break;
|
||||
} else {
|
||||
index = subghz_setting_get_frequency_default_index(app->setting);
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
uint8_t pocsag_pager_scene_receiver_config_next_preset(const char* preset_name, void* context) {
|
||||
furi_assert(context);
|
||||
POCSAGPagerApp* app = context;
|
||||
uint8_t index = 0;
|
||||
for(uint8_t i = 0; i < subghz_setting_get_preset_count(app->setting); i++) {
|
||||
if(!strcmp(subghz_setting_get_preset_name(app->setting, i), preset_name)) {
|
||||
index = i;
|
||||
break;
|
||||
} else {
|
||||
// index = subghz_setting_get_frequency_default_index(app ->setting);
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
uint8_t pocsag_pager_scene_receiver_config_hopper_value_index(
|
||||
const uint32_t value,
|
||||
const uint32_t values[],
|
||||
uint8_t values_count,
|
||||
void* context) {
|
||||
furi_assert(context);
|
||||
UNUSED(values_count);
|
||||
POCSAGPagerApp* app = context;
|
||||
|
||||
if(value == values[0]) {
|
||||
return 0;
|
||||
} else {
|
||||
variable_item_set_current_value_text(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
app->scene_manager, POCSAGPagerSceneReceiverConfig),
|
||||
" -----");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void pocsag_pager_scene_receiver_config_set_frequency(VariableItem* item) {
|
||||
POCSAGPagerApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
if(app->txrx->hopper_state == PCSGHopperStateOFF) {
|
||||
char text_buf[10] = {0};
|
||||
snprintf(
|
||||
text_buf,
|
||||
sizeof(text_buf),
|
||||
"%lu.%02lu",
|
||||
subghz_setting_get_frequency(app->setting, index) / 1000000,
|
||||
(subghz_setting_get_frequency(app->setting, index) % 1000000) / 10000);
|
||||
variable_item_set_current_value_text(item, text_buf);
|
||||
app->txrx->preset->frequency = subghz_setting_get_frequency(app->setting, index);
|
||||
} else {
|
||||
variable_item_set_current_value_index(
|
||||
item, subghz_setting_get_frequency_default_index(app->setting));
|
||||
}
|
||||
}
|
||||
|
||||
static void pocsag_pager_scene_receiver_config_set_preset(VariableItem* item) {
|
||||
POCSAGPagerApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(
|
||||
item, subghz_setting_get_preset_name(app->setting, index));
|
||||
pcsg_preset_init(
|
||||
app,
|
||||
subghz_setting_get_preset_name(app->setting, index),
|
||||
app->txrx->preset->frequency,
|
||||
subghz_setting_get_preset_data(app->setting, index),
|
||||
subghz_setting_get_preset_data_size(app->setting, index));
|
||||
}
|
||||
|
||||
static void pocsag_pager_scene_receiver_config_set_hopping_running(VariableItem* item) {
|
||||
POCSAGPagerApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, hopping_text[index]);
|
||||
if(hopping_value[index] == PCSGHopperStateOFF) {
|
||||
char text_buf[10] = {0};
|
||||
snprintf(
|
||||
text_buf,
|
||||
sizeof(text_buf),
|
||||
"%lu.%02lu",
|
||||
subghz_setting_get_default_frequency(app->setting) / 1000000,
|
||||
(subghz_setting_get_default_frequency(app->setting) % 1000000) / 10000);
|
||||
variable_item_set_current_value_text(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
app->scene_manager, POCSAGPagerSceneReceiverConfig),
|
||||
text_buf);
|
||||
app->txrx->preset->frequency = subghz_setting_get_default_frequency(app->setting);
|
||||
variable_item_set_current_value_index(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
app->scene_manager, POCSAGPagerSceneReceiverConfig),
|
||||
subghz_setting_get_frequency_default_index(app->setting));
|
||||
} else {
|
||||
variable_item_set_current_value_text(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
app->scene_manager, POCSAGPagerSceneReceiverConfig),
|
||||
" -----");
|
||||
variable_item_set_current_value_index(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
app->scene_manager, POCSAGPagerSceneReceiverConfig),
|
||||
subghz_setting_get_frequency_default_index(app->setting));
|
||||
}
|
||||
|
||||
app->txrx->hopper_state = hopping_value[index];
|
||||
}
|
||||
|
||||
static void
|
||||
pocsag_pager_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) {
|
||||
furi_assert(context);
|
||||
POCSAGPagerApp* app = context;
|
||||
if(index == PCSGSettingIndexLock) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, PCSGCustomEventSceneSettingLock);
|
||||
}
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_receiver_config_on_enter(void* context) {
|
||||
POCSAGPagerApp* app = context;
|
||||
VariableItem* item;
|
||||
uint8_t value_index;
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list,
|
||||
"Frequency:",
|
||||
subghz_setting_get_frequency_count(app->setting),
|
||||
pocsag_pager_scene_receiver_config_set_frequency,
|
||||
app);
|
||||
value_index =
|
||||
pocsag_pager_scene_receiver_config_next_frequency(app->txrx->preset->frequency, app);
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, POCSAGPagerSceneReceiverConfig, (uint32_t)item);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
char text_buf[10] = {0};
|
||||
snprintf(
|
||||
text_buf,
|
||||
sizeof(text_buf),
|
||||
"%lu.%02lu",
|
||||
subghz_setting_get_frequency(app->setting, value_index) / 1000000,
|
||||
(subghz_setting_get_frequency(app->setting, value_index) % 1000000) / 10000);
|
||||
variable_item_set_current_value_text(item, text_buf);
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list,
|
||||
"Hopping:",
|
||||
HOPPING_COUNT,
|
||||
pocsag_pager_scene_receiver_config_set_hopping_running,
|
||||
app);
|
||||
value_index = pocsag_pager_scene_receiver_config_hopper_value_index(
|
||||
app->txrx->hopper_state, hopping_value, HOPPING_COUNT, app);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, hopping_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->variable_item_list,
|
||||
"Modulation:",
|
||||
subghz_setting_get_preset_count(app->setting),
|
||||
pocsag_pager_scene_receiver_config_set_preset,
|
||||
app);
|
||||
value_index = pocsag_pager_scene_receiver_config_next_preset(
|
||||
furi_string_get_cstr(app->txrx->preset->name), app);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(
|
||||
item, subghz_setting_get_preset_name(app->setting, value_index));
|
||||
|
||||
variable_item_list_add(app->variable_item_list, "Lock Keyboard", 1, NULL, NULL);
|
||||
variable_item_list_set_enter_callback(
|
||||
app->variable_item_list, pocsag_pager_scene_receiver_config_var_list_enter_callback, app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, POCSAGPagerViewVariableItemList);
|
||||
}
|
||||
|
||||
bool pocsag_pager_scene_receiver_config_on_event(void* context, SceneManagerEvent event) {
|
||||
POCSAGPagerApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == PCSGCustomEventSceneSettingLock) {
|
||||
app->lock = PCSGLockOn;
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_receiver_config_on_exit(void* context) {
|
||||
POCSAGPagerApp* app = context;
|
||||
variable_item_list_set_selected_item(app->variable_item_list, 0);
|
||||
variable_item_list_reset(app->variable_item_list);
|
||||
}
|
||||
50
applications/external/pocsag_pager/scenes/pocsag_pager_scene_receiver_info.c
vendored
Normal file
50
applications/external/pocsag_pager/scenes/pocsag_pager_scene_receiver_info.c
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "../pocsag_pager_app_i.h"
|
||||
#include "../views/pocsag_pager_receiver.h"
|
||||
|
||||
void pocsag_pager_scene_receiver_info_callback(PCSGCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
POCSAGPagerApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
static void pocsag_pager_scene_receiver_info_add_to_history_callback(
|
||||
SubGhzReceiver* receiver,
|
||||
SubGhzProtocolDecoderBase* decoder_base,
|
||||
void* context) {
|
||||
furi_assert(context);
|
||||
POCSAGPagerApp* app = context;
|
||||
|
||||
if(pcsg_history_add_to_history(app->txrx->history, decoder_base, app->txrx->preset) ==
|
||||
PCSGHistoryStateAddKeyUpdateData) {
|
||||
pcsg_view_receiver_info_update(
|
||||
app->pcsg_receiver_info,
|
||||
pcsg_history_get_raw_data(app->txrx->history, app->txrx->idx_menu_chosen));
|
||||
subghz_receiver_reset(receiver);
|
||||
|
||||
notification_message(app->notifications, &sequence_blink_green_10);
|
||||
app->txrx->rx_key_state = PCSGRxKeyStateAddKey;
|
||||
}
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_receiver_info_on_enter(void* context) {
|
||||
POCSAGPagerApp* app = context;
|
||||
|
||||
subghz_receiver_set_rx_callback(
|
||||
app->txrx->receiver, pocsag_pager_scene_receiver_info_add_to_history_callback, app);
|
||||
pcsg_view_receiver_info_update(
|
||||
app->pcsg_receiver_info,
|
||||
pcsg_history_get_raw_data(app->txrx->history, app->txrx->idx_menu_chosen));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, POCSAGPagerViewReceiverInfo);
|
||||
}
|
||||
|
||||
bool pocsag_pager_scene_receiver_info_on_event(void* context, SceneManagerEvent event) {
|
||||
POCSAGPagerApp* app = context;
|
||||
bool consumed = false;
|
||||
UNUSED(app);
|
||||
UNUSED(event);
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_receiver_info_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
||||
58
applications/external/pocsag_pager/scenes/pocsag_pager_scene_start.c
vendored
Normal file
58
applications/external/pocsag_pager/scenes/pocsag_pager_scene_start.c
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "../pocsag_pager_app_i.h"
|
||||
|
||||
typedef enum {
|
||||
SubmenuIndexPOCSAGPagerReceiver,
|
||||
SubmenuIndexPOCSAGPagerAbout,
|
||||
} SubmenuIndex;
|
||||
|
||||
void pocsag_pager_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
POCSAGPagerApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_start_on_enter(void* context) {
|
||||
UNUSED(context);
|
||||
POCSAGPagerApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Receive messages",
|
||||
SubmenuIndexPOCSAGPagerReceiver,
|
||||
pocsag_pager_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"About",
|
||||
SubmenuIndexPOCSAGPagerAbout,
|
||||
pocsag_pager_scene_start_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, POCSAGPagerSceneStart));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, POCSAGPagerViewSubmenu);
|
||||
}
|
||||
|
||||
bool pocsag_pager_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
POCSAGPagerApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexPOCSAGPagerAbout) {
|
||||
scene_manager_next_scene(app->scene_manager, POCSAGPagerSceneAbout);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexPOCSAGPagerReceiver) {
|
||||
scene_manager_next_scene(app->scene_manager, POCSAGPagerSceneReceiver);
|
||||
consumed = true;
|
||||
}
|
||||
scene_manager_set_scene_state(app->scene_manager, POCSAGPagerSceneStart, event.event);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void pocsag_pager_scene_start_on_exit(void* context) {
|
||||
POCSAGPagerApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
Reference in New Issue
Block a user