Move plugins to external folder

This commit is contained in:
MX
2023-03-14 20:00:53 +03:00
parent dd99c22792
commit 8b8b78d001
671 changed files with 1 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
#include "dtmf_dolphin_scene.h"
// Generate scene on_enter handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
void (*const dtmf_dolphin_scene_on_enter_handlers[])(void*) = {
#include "dtmf_dolphin_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 dtmf_dolphin_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
#include "dtmf_dolphin_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 dtmf_dolphin_scene_on_exit_handlers[])(void* context) = {
#include "dtmf_dolphin_scene_config.h"
};
#undef ADD_SCENE
// Initialize scene handlers configuration structure
const SceneManagerHandlers dtmf_dolphin_scene_handlers = {
.on_enter_handlers = dtmf_dolphin_scene_on_enter_handlers,
.on_event_handlers = dtmf_dolphin_scene_on_event_handlers,
.on_exit_handlers = dtmf_dolphin_scene_on_exit_handlers,
.scene_num = DTMFDolphinSceneNum,
};

View File

@@ -0,0 +1,29 @@
#pragma once
#include <gui/scene_manager.h>
// Generate scene id and total number
#define ADD_SCENE(prefix, name, id) DTMFDolphinScene##id,
typedef enum {
#include "dtmf_dolphin_scene_config.h"
DTMFDolphinSceneNum,
} DTMFDolphinScene;
#undef ADD_SCENE
extern const SceneManagerHandlers dtmf_dolphin_scene_handlers;
// Generate scene on_enter handlers declaration
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
#include "dtmf_dolphin_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 "dtmf_dolphin_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 "dtmf_dolphin_scene_config.h"
#undef ADD_SCENE

View File

@@ -0,0 +1,2 @@
ADD_SCENE(dtmf_dolphin, start, Start)
ADD_SCENE(dtmf_dolphin, dialer, Dialer)

View File

@@ -0,0 +1,49 @@
#include "../dtmf_dolphin_i.h"
// #include "../dtmf_dolphin_data.h"
// #include "../dtmf_dolphin_audio.h"
void dtmf_dolphin_scene_dialer_on_enter(void* context) {
DTMFDolphinApp* app = context;
DTMFDolphinScene scene_id = DTMFDolphinSceneDialer;
enum DTMFDolphinSceneState state = scene_manager_get_scene_state(app->scene_manager, scene_id);
switch(state) {
case DTMFDolphinSceneStateBluebox:
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX);
break;
case DTMFDolphinSceneStateRedboxUS:
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_REDBOX_US);
break;
case DTMFDolphinSceneStateRedboxUK:
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_REDBOX_UK);
break;
case DTMFDolphinSceneStateRedboxCA:
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_REDBOX_CA);
break;
case DTMFDolphinSceneStateMisc:
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_MISC);
break;
default:
dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_DIALER);
break;
}
view_dispatcher_switch_to_view(app->view_dispatcher, DTMFDolphinViewDialer);
}
bool dtmf_dolphin_scene_dialer_on_event(void* context, SceneManagerEvent event) {
DTMFDolphinApp* app = context;
UNUSED(app);
UNUSED(event);
bool consumed = false;
// if(event.type == SceneManagerEventTypeTick) {
// consumed = true;
// }
return consumed;
}
void dtmf_dolphin_scene_dialer_on_exit(void* context) {
UNUSED(context);
}

View File

@@ -0,0 +1,94 @@
#include "../dtmf_dolphin_i.h"
static void dtmf_dolphin_scene_start_main_menu_enter_callback(void* context, uint32_t index) {
DTMFDolphinApp* app = context;
uint8_t cust_event = 255;
switch(index) {
case 0:
cust_event = DTMFDolphinEventStartDialer;
break;
case 1:
cust_event = DTMFDolphinEventStartBluebox;
break;
case 2:
cust_event = DTMFDolphinEventStartRedboxUS;
break;
case 3:
cust_event = DTMFDolphinEventStartRedboxUK;
break;
case 4:
cust_event = DTMFDolphinEventStartRedboxCA;
break;
case 5:
cust_event = DTMFDolphinEventStartMisc;
break;
default:
return;
}
view_dispatcher_send_custom_event(app->view_dispatcher, cust_event);
}
void dtmf_dolphin_scene_start_on_enter(void* context) {
DTMFDolphinApp* app = context;
VariableItemList* var_item_list = app->main_menu_list;
// VariableItem* item;
variable_item_list_set_enter_callback(
var_item_list, dtmf_dolphin_scene_start_main_menu_enter_callback, app);
variable_item_list_add(var_item_list, "Dialer", 0, NULL, context);
variable_item_list_add(var_item_list, "Bluebox", 0, NULL, context);
variable_item_list_add(var_item_list, "Redbox (US)", 0, NULL, context);
variable_item_list_add(var_item_list, "Redbox (UK)", 0, NULL, context);
variable_item_list_add(var_item_list, "Redbox (CA)", 0, NULL, context);
variable_item_list_add(var_item_list, "Misc", 0, NULL, context);
variable_item_list_set_selected_item(
var_item_list, scene_manager_get_scene_state(app->scene_manager, DTMFDolphinSceneStart));
view_dispatcher_switch_to_view(app->view_dispatcher, DTMFDolphinViewMainMenu);
}
bool dtmf_dolphin_scene_start_on_event(void* context, SceneManagerEvent event) {
DTMFDolphinApp* app = context;
UNUSED(app);
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
uint8_t sc_state;
switch(event.event) {
case DTMFDolphinEventStartDialer:
sc_state = DTMFDolphinSceneStateDialer;
break;
case DTMFDolphinEventStartBluebox:
sc_state = DTMFDolphinSceneStateBluebox;
break;
case DTMFDolphinEventStartRedboxUS:
sc_state = DTMFDolphinSceneStateRedboxUS;
break;
case DTMFDolphinEventStartRedboxUK:
sc_state = DTMFDolphinSceneStateRedboxUK;
break;
case DTMFDolphinEventStartRedboxCA:
sc_state = DTMFDolphinSceneStateRedboxCA;
break;
case DTMFDolphinEventStartMisc:
sc_state = DTMFDolphinSceneStateMisc;
break;
default:
return consumed;
}
scene_manager_set_scene_state(app->scene_manager, DTMFDolphinSceneDialer, sc_state);
scene_manager_next_scene(app->scene_manager, DTMFDolphinSceneDialer);
consumed = true;
}
return consumed;
}
void dtmf_dolphin_scene_start_on_exit(void* context) {
DTMFDolphinApp* app = context;
variable_item_list_reset(app->main_menu_list);
}