mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-21 02:03:18 +00:00
7afdd14a4c
* Gui: ported submenu and view_dispatcher_remove_view from iButton branch * App gui-test: use backported submenu api * App subghz: initial commit * App subghz: syntax fix * App gui-test: fix submenu callback * App subghz: add subfolders to build * Gui view: c++ verison of with_view_model * Subghz app: simple spectrum settings view * Subghz app: add spectrum settings view to view manager * Subghz app: spectrum settings scene Co-authored-by: coreglitch <mail@s3f.ru>
67 lines
No EOL
2.2 KiB
C++
67 lines
No EOL
2.2 KiB
C++
#include "subghz-scene-start.h"
|
|
#include "../subghz-app.h"
|
|
#include "../subghz-view-manager.h"
|
|
#include "../subghz-event.h"
|
|
#include <callback-connector.h>
|
|
|
|
typedef enum {
|
|
SubmenuIndexSpectrumAnalyzer,
|
|
SubmenuIndexFrequencyScanner,
|
|
SubmenuIndexSignalAnalyzer,
|
|
SubmenuIndexSignalTransmitter,
|
|
SubmenuIndexApplications,
|
|
} SubmenuIndex;
|
|
|
|
void SubghzSceneStart::on_enter(SubghzApp* app) {
|
|
SubghzAppViewManager* view_manager = app->get_view_manager();
|
|
Submenu* submenu = view_manager->get_submenu();
|
|
auto callback = cbc::obtain_connector(this, &SubghzSceneStart::submenu_callback);
|
|
|
|
submenu_add_item(submenu, "Spectrum Analyzer", SubmenuIndexSpectrumAnalyzer, callback, app);
|
|
submenu_add_item(submenu, "Frequency Scanner", SubmenuIndexFrequencyScanner, callback, app);
|
|
submenu_add_item(submenu, "Signal Analyzer", SubmenuIndexSignalAnalyzer, callback, app);
|
|
submenu_add_item(submenu, "Signal Transmitter", SubmenuIndexSignalTransmitter, callback, app);
|
|
submenu_add_item(submenu, "Applications", SubmenuIndexApplications, callback, app);
|
|
|
|
view_manager->switch_to(SubghzAppViewManager::ViewType::Submenu);
|
|
}
|
|
|
|
bool SubghzSceneStart::on_event(SubghzApp* app, SubghzEvent* event) {
|
|
bool consumed = false;
|
|
|
|
if(event->type == SubghzEvent::Type::MenuSelected) {
|
|
switch(event->payload.menu_index) {
|
|
case SubmenuIndexSpectrumAnalyzer:
|
|
app->switch_to_next_scene(SubghzApp::Scene::SceneSpectrumSettings);
|
|
break;
|
|
case SubmenuIndexFrequencyScanner:
|
|
break;
|
|
case SubmenuIndexSignalAnalyzer:
|
|
break;
|
|
case SubmenuIndexSignalTransmitter:
|
|
break;
|
|
case SubmenuIndexApplications:
|
|
break;
|
|
}
|
|
consumed = true;
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void SubghzSceneStart::on_exit(SubghzApp* app) {
|
|
SubghzAppViewManager* view_manager = app->get_view_manager();
|
|
Submenu* submenu = view_manager->get_submenu();
|
|
|
|
submenu_clean(submenu);
|
|
}
|
|
|
|
void SubghzSceneStart::submenu_callback(void* context, uint32_t index) {
|
|
SubghzApp* app = static_cast<SubghzApp*>(context);
|
|
SubghzEvent event;
|
|
|
|
event.type = SubghzEvent::Type::MenuSelected;
|
|
event.payload.menu_index = index;
|
|
|
|
app->get_view_manager()->send_event(&event);
|
|
} |