[FL-2904, FL-2900, FL-2890] WS: add app WeatherStation (#1833)
* WeatherStation: start * SubGhz: rename protocol magellen -> magellan * WeatherStation: err Unresolved symbols: {'subghz_protocol_decoder_base_get_string'} * WeatherStation: fix Unresolved symbols: {'subghz_protocol_decoder_base_get_string'} * Subghz: add set protocol_items * WeatherStation: adding your protocols * WS: add Infactory protocol * WS: add history * WS: add setting * WS: add lock * WS: add hopper frequency * WS: fix history * WS fix string_t -> FuriString* * WS: add images * WS: history record update when receiving data from the sensor again * WS: add receiver info, delete extra code * WS: add protocol ThermoPRO_TX4 * [FL-2900] SubGhz: Move icons in Sub-GHz * WS: add Notification * [FL-2890] SubGhz: Rename *_user files in resources to _user.example * WS: add about scene * WS: removing redundant code * WS: add protocol Nexus-TH * WS: add protocol GT_WT03 * WS: fix notification and rename "Weather Station" -> "Read Weather Station" * SubGhz: partial unit tests fix * SubGhz: fix unit_test * SubGhz: remove dead code * SubGhz: rename SubGhzPresetDefinition into SubGhzRadioPreset, cleanup subghz types. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -0,0 +1,207 @@
|
||||
#include "../weather_station_app_i.h"
|
||||
#include "../views/weather_station_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 weather_station_scene_receiver_update_statusbar(void* context) {
|
||||
WeatherStationApp* app = context;
|
||||
FuriString* history_stat_str;
|
||||
history_stat_str = furi_string_alloc();
|
||||
if(!ws_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();
|
||||
|
||||
ws_get_frequency_modulation(app, frequency_str, modulation_str);
|
||||
|
||||
ws_view_receiver_add_data_statusbar(
|
||||
app->ws_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 {
|
||||
ws_view_receiver_add_data_statusbar(
|
||||
app->ws_receiver, furi_string_get_cstr(history_stat_str), "", "");
|
||||
}
|
||||
furi_string_free(history_stat_str);
|
||||
}
|
||||
|
||||
void weather_station_scene_receiver_callback(WSCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
WeatherStationApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
static void weather_station_scene_receiver_add_to_history_callback(
|
||||
SubGhzReceiver* receiver,
|
||||
SubGhzProtocolDecoderBase* decoder_base,
|
||||
void* context) {
|
||||
furi_assert(context);
|
||||
WeatherStationApp* app = context;
|
||||
FuriString* str_buff;
|
||||
str_buff = furi_string_alloc();
|
||||
|
||||
if(ws_history_add_to_history(app->txrx->history, decoder_base, app->txrx->preset) ==
|
||||
WSHistoryStateAddKeyNewDada) {
|
||||
furi_string_reset(str_buff);
|
||||
|
||||
ws_history_get_text_item_menu(
|
||||
app->txrx->history, str_buff, ws_history_get_item(app->txrx->history) - 1);
|
||||
ws_view_receiver_add_item_to_menu(
|
||||
app->ws_receiver,
|
||||
furi_string_get_cstr(str_buff),
|
||||
ws_history_get_type_protocol(
|
||||
app->txrx->history, ws_history_get_item(app->txrx->history) - 1));
|
||||
|
||||
weather_station_scene_receiver_update_statusbar(app);
|
||||
notification_message(app->notifications, &sequence_blink_green_10);
|
||||
if(app->lock != WSLockOn) {
|
||||
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 = WSRxKeyStateAddKey;
|
||||
}
|
||||
|
||||
void weather_station_scene_receiver_on_enter(void* context) {
|
||||
WeatherStationApp* app = context;
|
||||
|
||||
FuriString* str_buff;
|
||||
str_buff = furi_string_alloc();
|
||||
|
||||
if(app->txrx->rx_key_state == WSRxKeyStateIDLE) {
|
||||
ws_preset_init(app, "AM650", subghz_setting_get_default_frequency(app->setting), NULL, 0);
|
||||
ws_history_reset(app->txrx->history);
|
||||
app->txrx->rx_key_state = WSRxKeyStateStart;
|
||||
}
|
||||
|
||||
ws_view_receiver_set_lock(app->ws_receiver, app->lock);
|
||||
|
||||
//Load history to receiver
|
||||
ws_view_receiver_exit(app->ws_receiver);
|
||||
for(uint8_t i = 0; i < ws_history_get_item(app->txrx->history); i++) {
|
||||
furi_string_reset(str_buff);
|
||||
ws_history_get_text_item_menu(app->txrx->history, str_buff, i);
|
||||
ws_view_receiver_add_item_to_menu(
|
||||
app->ws_receiver,
|
||||
furi_string_get_cstr(str_buff),
|
||||
ws_history_get_type_protocol(app->txrx->history, i));
|
||||
app->txrx->rx_key_state = WSRxKeyStateAddKey;
|
||||
}
|
||||
furi_string_free(str_buff);
|
||||
weather_station_scene_receiver_update_statusbar(app);
|
||||
|
||||
ws_view_receiver_set_callback(app->ws_receiver, weather_station_scene_receiver_callback, app);
|
||||
subghz_receiver_set_rx_callback(
|
||||
app->txrx->receiver, weather_station_scene_receiver_add_to_history_callback, app);
|
||||
|
||||
if(app->txrx->txrx_state == WSTxRxStateRx) {
|
||||
ws_rx_end(app);
|
||||
};
|
||||
if((app->txrx->txrx_state == WSTxRxStateIDLE) || (app->txrx->txrx_state == WSTxRxStateSleep)) {
|
||||
ws_begin(
|
||||
app,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
app->setting, furi_string_get_cstr(app->txrx->preset->name)));
|
||||
|
||||
ws_rx(app, app->txrx->preset->frequency);
|
||||
}
|
||||
|
||||
ws_view_receiver_set_idx_menu(app->ws_receiver, app->txrx->idx_menu_chosen);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WeatherStationViewReceiver);
|
||||
}
|
||||
|
||||
bool weather_station_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
WeatherStationApp* app = context;
|
||||
bool consumed = false;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case WSCustomEventViewReceiverBack:
|
||||
// Stop CC1101 Rx
|
||||
if(app->txrx->txrx_state == WSTxRxStateRx) {
|
||||
ws_rx_end(app);
|
||||
ws_sleep(app);
|
||||
};
|
||||
app->txrx->hopper_state = WSHopperStateOFF;
|
||||
app->txrx->idx_menu_chosen = 0;
|
||||
subghz_receiver_set_rx_callback(app->txrx->receiver, NULL, app);
|
||||
|
||||
app->txrx->rx_key_state = WSRxKeyStateIDLE;
|
||||
ws_preset_init(
|
||||
app, "AM650", subghz_setting_get_default_frequency(app->setting), NULL, 0);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
app->scene_manager, WeatherStationSceneStart);
|
||||
consumed = true;
|
||||
break;
|
||||
case WSCustomEventViewReceiverOK:
|
||||
app->txrx->idx_menu_chosen = ws_view_receiver_get_idx_menu(app->ws_receiver);
|
||||
scene_manager_next_scene(app->scene_manager, WeatherStationSceneReceiverInfo);
|
||||
consumed = true;
|
||||
break;
|
||||
case WSCustomEventViewReceiverConfig:
|
||||
app->txrx->idx_menu_chosen = ws_view_receiver_get_idx_menu(app->ws_receiver);
|
||||
scene_manager_next_scene(app->scene_manager, WeatherStationSceneReceiverConfig);
|
||||
consumed = true;
|
||||
break;
|
||||
case WSCustomEventViewReceiverOffDisplay:
|
||||
notification_message(app->notifications, &sequence_display_backlight_off);
|
||||
consumed = true;
|
||||
break;
|
||||
case WSCustomEventViewReceiverUnlock:
|
||||
app->lock = WSLockOff;
|
||||
consumed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
if(app->txrx->hopper_state != WSHopperStateOFF) {
|
||||
ws_hopper_update(app);
|
||||
weather_station_scene_receiver_update_statusbar(app);
|
||||
}
|
||||
if(app->txrx->txrx_state == WSTxRxStateRx) {
|
||||
notification_message(app->notifications, &sequence_blink_cyan_10);
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void weather_station_scene_receiver_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
#include "../weather_station_app_i.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const weather_station_scene_on_enter_handlers[])(void*) = {
|
||||
#include "weather_station_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 weather_station_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "weather_station_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 weather_station_scene_on_exit_handlers[])(void* context) = {
|
||||
#include "weather_station_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers weather_station_scene_handlers = {
|
||||
.on_enter_handlers = weather_station_scene_on_enter_handlers,
|
||||
.on_event_handlers = weather_station_scene_on_event_handlers,
|
||||
.on_exit_handlers = weather_station_scene_on_exit_handlers,
|
||||
.scene_num = WeatherStationSceneNum,
|
||||
};
|
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) WeatherStationScene##id,
|
||||
typedef enum {
|
||||
#include "weather_station_scene_config.h"
|
||||
WeatherStationSceneNum,
|
||||
} WeatherStationScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers weather_station_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "weather_station_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 "weather_station_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 "weather_station_scene_config.h"
|
||||
#undef ADD_SCENE
|
@@ -0,0 +1,78 @@
|
||||
#include "../weather_station_app_i.h"
|
||||
#include "../helpers/weather_station_types.h"
|
||||
|
||||
void weather_station_scene_about_widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
WeatherStationApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void weather_station_scene_about_on_enter(void* context) {
|
||||
WeatherStationApp* 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", WS_VERSION_APP);
|
||||
furi_string_cat_printf(temp_str, "Developed by: %s\n", WS_DEVELOPED);
|
||||
furi_string_cat_printf(temp_str, "Github: %s\n\n", WS_GITHUB);
|
||||
|
||||
furi_string_cat_printf(temp_str, "\e#%s\n", "Description");
|
||||
furi_string_cat_printf(
|
||||
temp_str, "Reading messages from\nweather station that work\nwith SubGhz sensors\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! Weather station \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, WeatherStationViewWidget);
|
||||
}
|
||||
|
||||
bool weather_station_scene_about_on_event(void* context, SceneManagerEvent event) {
|
||||
WeatherStationApp* app = context;
|
||||
bool consumed = false;
|
||||
UNUSED(app);
|
||||
UNUSED(event);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void weather_station_scene_about_on_exit(void* context) {
|
||||
WeatherStationApp* app = context;
|
||||
|
||||
// Clear views
|
||||
widget_reset(app->widget);
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
ADD_SCENE(weather_station, start, Start)
|
||||
ADD_SCENE(weather_station, about, About)
|
||||
ADD_SCENE(weather_station, receiver, Receiver)
|
||||
ADD_SCENE(weather_station, receiver_config, ReceiverConfig)
|
||||
ADD_SCENE(weather_station, receiver_info, ReceiverInfo)
|
@@ -0,0 +1,223 @@
|
||||
#include "../weather_station_app_i.h"
|
||||
|
||||
enum WSSettingIndex {
|
||||
WSSettingIndexFrequency,
|
||||
WSSettingIndexHopping,
|
||||
WSSettingIndexModulation,
|
||||
WSSettingIndexLock,
|
||||
};
|
||||
|
||||
#define HOPPING_COUNT 2
|
||||
const char* const hopping_text[HOPPING_COUNT] = {
|
||||
"OFF",
|
||||
"ON",
|
||||
};
|
||||
const uint32_t hopping_value[HOPPING_COUNT] = {
|
||||
WSHopperStateOFF,
|
||||
WSHopperStateRunnig,
|
||||
};
|
||||
|
||||
uint8_t weather_station_scene_receiver_config_next_frequency(const uint32_t value, void* context) {
|
||||
furi_assert(context);
|
||||
WeatherStationApp* 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 weather_station_scene_receiver_config_next_preset(const char* preset_name, void* context) {
|
||||
furi_assert(context);
|
||||
WeatherStationApp* 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 weather_station_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);
|
||||
WeatherStationApp* app = context;
|
||||
|
||||
if(value == values[0]) {
|
||||
return 0;
|
||||
} else {
|
||||
variable_item_set_current_value_text(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
app->scene_manager, WeatherStationSceneReceiverConfig),
|
||||
" -----");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void weather_station_scene_receiver_config_set_frequency(VariableItem* item) {
|
||||
WeatherStationApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
if(app->txrx->hopper_state == WSHopperStateOFF) {
|
||||
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 weather_station_scene_receiver_config_set_preset(VariableItem* item) {
|
||||
WeatherStationApp* 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));
|
||||
ws_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 weather_station_scene_receiver_config_set_hopping_running(VariableItem* item) {
|
||||
WeatherStationApp* 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] == WSHopperStateOFF) {
|
||||
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, WeatherStationSceneReceiverConfig),
|
||||
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, WeatherStationSceneReceiverConfig),
|
||||
subghz_setting_get_frequency_default_index(app->setting));
|
||||
} else {
|
||||
variable_item_set_current_value_text(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
app->scene_manager, WeatherStationSceneReceiverConfig),
|
||||
" -----");
|
||||
variable_item_set_current_value_index(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
app->scene_manager, WeatherStationSceneReceiverConfig),
|
||||
subghz_setting_get_frequency_default_index(app->setting));
|
||||
}
|
||||
|
||||
app->txrx->hopper_state = hopping_value[index];
|
||||
}
|
||||
|
||||
static void
|
||||
weather_station_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) {
|
||||
furi_assert(context);
|
||||
WeatherStationApp* app = context;
|
||||
if(index == WSSettingIndexLock) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, WSCustomEventSceneSettingLock);
|
||||
}
|
||||
}
|
||||
|
||||
void weather_station_scene_receiver_config_on_enter(void* context) {
|
||||
WeatherStationApp* 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),
|
||||
weather_station_scene_receiver_config_set_frequency,
|
||||
app);
|
||||
value_index =
|
||||
weather_station_scene_receiver_config_next_frequency(app->txrx->preset->frequency, app);
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, WeatherStationSceneReceiverConfig, (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,
|
||||
weather_station_scene_receiver_config_set_hopping_running,
|
||||
app);
|
||||
value_index = weather_station_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),
|
||||
weather_station_scene_receiver_config_set_preset,
|
||||
app);
|
||||
value_index = weather_station_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,
|
||||
weather_station_scene_receiver_config_var_list_enter_callback,
|
||||
app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WeatherStationViewVariableItemList);
|
||||
}
|
||||
|
||||
bool weather_station_scene_receiver_config_on_event(void* context, SceneManagerEvent event) {
|
||||
WeatherStationApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == WSCustomEventSceneSettingLock) {
|
||||
app->lock = WSLockOn;
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void weather_station_scene_receiver_config_on_exit(void* context) {
|
||||
WeatherStationApp* app = context;
|
||||
variable_item_list_set_selected_item(app->variable_item_list, 0);
|
||||
variable_item_list_reset(app->variable_item_list);
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
#include "../weather_station_app_i.h"
|
||||
#include "../views/weather_station_receiver.h"
|
||||
|
||||
void weather_station_scene_receiver_info_callback(WSCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
WeatherStationApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
||||
}
|
||||
|
||||
static void weather_station_scene_receiver_info_add_to_history_callback(
|
||||
SubGhzReceiver* receiver,
|
||||
SubGhzProtocolDecoderBase* decoder_base,
|
||||
void* context) {
|
||||
furi_assert(context);
|
||||
WeatherStationApp* app = context;
|
||||
|
||||
if(ws_history_add_to_history(app->txrx->history, decoder_base, app->txrx->preset) ==
|
||||
WSHistoryStateAddKeyUpdateData) {
|
||||
ws_view_receiver_info_update(
|
||||
app->ws_receiver_info,
|
||||
ws_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 = WSRxKeyStateAddKey;
|
||||
}
|
||||
}
|
||||
|
||||
void weather_station_scene_receiver_info_on_enter(void* context) {
|
||||
WeatherStationApp* app = context;
|
||||
|
||||
subghz_receiver_set_rx_callback(
|
||||
app->txrx->receiver, weather_station_scene_receiver_info_add_to_history_callback, app);
|
||||
ws_view_receiver_info_update(
|
||||
app->ws_receiver_info,
|
||||
ws_history_get_raw_data(app->txrx->history, app->txrx->idx_menu_chosen));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WeatherStationViewReceiverInfo);
|
||||
}
|
||||
|
||||
bool weather_station_scene_receiver_info_on_event(void* context, SceneManagerEvent event) {
|
||||
WeatherStationApp* app = context;
|
||||
bool consumed = false;
|
||||
UNUSED(app);
|
||||
UNUSED(event);
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void weather_station_scene_receiver_info_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
#include "../weather_station_app_i.h"
|
||||
|
||||
typedef enum {
|
||||
SubmenuIndexWeatherStationReceiver,
|
||||
SubmenuIndexWeatherStationAbout,
|
||||
} SubmenuIndex;
|
||||
|
||||
void weather_station_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||
WeatherStationApp* app = context;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||
}
|
||||
|
||||
void weather_station_scene_start_on_enter(void* context) {
|
||||
UNUSED(context);
|
||||
WeatherStationApp* app = context;
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Read Weather Station",
|
||||
SubmenuIndexWeatherStationReceiver,
|
||||
weather_station_scene_start_submenu_callback,
|
||||
app);
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"About",
|
||||
SubmenuIndexWeatherStationAbout,
|
||||
weather_station_scene_start_submenu_callback,
|
||||
app);
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, WeatherStationSceneStart));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WeatherStationViewSubmenu);
|
||||
}
|
||||
|
||||
bool weather_station_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
WeatherStationApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexWeatherStationAbout) {
|
||||
scene_manager_next_scene(app->scene_manager, WeatherStationSceneAbout);
|
||||
consumed = true;
|
||||
} else if(event.event == SubmenuIndexWeatherStationReceiver) {
|
||||
scene_manager_next_scene(app->scene_manager, WeatherStationSceneReceiver);
|
||||
consumed = true;
|
||||
}
|
||||
scene_manager_set_scene_state(app->scene_manager, WeatherStationSceneStart, event.event);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void weather_station_scene_start_on_exit(void* context) {
|
||||
WeatherStationApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
Reference in New Issue
Block a user