|
@@ -1,3 +1,4 @@
|
|
|
|
|
+#include <gui/canvas.h>
|
|
|
#include <gui/modules/menu.h>
|
|
#include <gui/modules/menu.h>
|
|
|
|
|
|
|
|
/* generated by fbt from .png files in images folder */
|
|
/* generated by fbt from .png files in images folder */
|
|
@@ -7,23 +8,27 @@
|
|
|
#include "tone_gen.h"
|
|
#include "tone_gen.h"
|
|
|
|
|
|
|
|
#include "scenes/starting_scene.h"
|
|
#include "scenes/starting_scene.h"
|
|
|
|
|
+#include "scenes/playback_scene.h"
|
|
|
#include "scenes/settings_scene.h"
|
|
#include "scenes/settings_scene.h"
|
|
|
|
|
|
|
|
/** collection of all scene on_enter handlers - in the same order as their enum */
|
|
/** collection of all scene on_enter handlers - in the same order as their enum */
|
|
|
void (*const scene_on_enter_handlers[])(void*) = {
|
|
void (*const scene_on_enter_handlers[])(void*) = {
|
|
|
scene_on_enter_starting_scene,
|
|
scene_on_enter_starting_scene,
|
|
|
|
|
+ scene_on_enter_playback_scene,
|
|
|
scene_on_enter_settings_scene,
|
|
scene_on_enter_settings_scene,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/** collection of all scene on event handlers - in the same order as their enum */
|
|
/** collection of all scene on event handlers - in the same order as their enum */
|
|
|
bool (*const scene_on_event_handlers[])(void*, SceneManagerEvent) = {
|
|
bool (*const scene_on_event_handlers[])(void*, SceneManagerEvent) = {
|
|
|
scene_on_event_starting_scene,
|
|
scene_on_event_starting_scene,
|
|
|
|
|
+ scene_on_event_playback_scene,
|
|
|
scene_on_event_settings_scene,
|
|
scene_on_event_settings_scene,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/** collection of all scene on exit handlers - in the same order as their enum */
|
|
/** collection of all scene on exit handlers - in the same order as their enum */
|
|
|
void (*const scene_on_exit_handlers[])(void*) = {
|
|
void (*const scene_on_exit_handlers[])(void*) = {
|
|
|
scene_on_exit_starting_scene,
|
|
scene_on_exit_starting_scene,
|
|
|
|
|
+ scene_on_exit_playback_scene,
|
|
|
scene_on_exit_settings_scene,
|
|
scene_on_exit_settings_scene,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -35,23 +40,46 @@ const SceneManagerHandlers scene_event_handlers = {
|
|
|
|
|
|
|
|
int setupViews(struct AppContext_t** appContext) {
|
|
int setupViews(struct AppContext_t** appContext) {
|
|
|
// Create views
|
|
// Create views
|
|
|
|
|
+ FURI_LOG_I(TAG, "Creating views");
|
|
|
struct View_t* sharedMenuView = malloc(sizeof(struct View_t));
|
|
struct View_t* sharedMenuView = malloc(sizeof(struct View_t));
|
|
|
sharedMenuView->viewData = menu_alloc();
|
|
sharedMenuView->viewData = menu_alloc();
|
|
|
sharedMenuView->viewId = ToneGenAppView_SharedMenu;
|
|
sharedMenuView->viewId = ToneGenAppView_SharedMenu;
|
|
|
sharedMenuView->type = MENU;
|
|
sharedMenuView->type = MENU;
|
|
|
|
|
|
|
|
|
|
+ struct View_t* playbackView = malloc(sizeof(struct View_t));
|
|
|
|
|
+ playbackView->viewData = view_alloc();
|
|
|
|
|
+ playbackView->viewId = ToneGenAppView_PlaybackView;
|
|
|
|
|
+ playbackView->type = VIEW;
|
|
|
|
|
+
|
|
|
// Add views to the app context for management later
|
|
// Add views to the app context for management later
|
|
|
|
|
+ FURI_LOG_I(TAG, "Adding views to app context");
|
|
|
AppContextStatus result = addViewToAppContext(appContext, sharedMenuView);
|
|
AppContextStatus result = addViewToAppContext(appContext, sharedMenuView);
|
|
|
if(result != APP_CONTEXT_OK) {
|
|
if(result != APP_CONTEXT_OK) {
|
|
|
FURI_LOG_E(TAG, "There was a problem adding the view %d!", sharedMenuView->viewId);
|
|
FURI_LOG_E(TAG, "There was a problem adding the view %d!", sharedMenuView->viewId);
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ result = addViewToAppContext(appContext, playbackView);
|
|
|
|
|
+ if(result != APP_CONTEXT_OK) {
|
|
|
|
|
+ FURI_LOG_E(TAG, "There was a problem adding the view %d!", playbackView->viewId);
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Add views to the view dispatcher for usage later
|
|
// Add views to the view dispatcher for usage later
|
|
|
|
|
+ FURI_LOG_I(TAG, "Adding views to view dispatcher");
|
|
|
view_dispatcher_add_view(
|
|
view_dispatcher_add_view(
|
|
|
(*appContext)->view_dispatcher,
|
|
(*appContext)->view_dispatcher,
|
|
|
sharedMenuView->viewId,
|
|
sharedMenuView->viewId,
|
|
|
menu_get_view(sharedMenuView->viewData));
|
|
menu_get_view(sharedMenuView->viewData));
|
|
|
|
|
+ FURI_LOG_I(TAG, "Adding next view to app context");
|
|
|
|
|
+ view_dispatcher_add_view(
|
|
|
|
|
+ (*appContext)->view_dispatcher, playbackView->viewId, playbackView->viewData);
|
|
|
|
|
+ FURI_LOG_I(TAG, "Done making views");
|
|
|
|
|
+
|
|
|
|
|
+ // On the playback view, ensure we only allocate for the model once
|
|
|
|
|
+ FURI_LOG_I(TAG, "allocating view model for playback");
|
|
|
|
|
+ view_allocate_model(playbackView->viewData, ViewModelTypeLockFree, sizeof(struct ToneData_t));
|
|
|
|
|
+
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -65,6 +93,12 @@ int32_t tone_gen_app(void* p) {
|
|
|
initializeAppContext(&appContext, ToneGenAppView_count, &scene_event_handlers);
|
|
initializeAppContext(&appContext, ToneGenAppView_count, &scene_event_handlers);
|
|
|
|
|
|
|
|
if(result == APP_CONTEXT_OK) {
|
|
if(result == APP_CONTEXT_OK) {
|
|
|
|
|
+ appContext->additionalData = malloc(sizeof(struct ToneData_t));
|
|
|
|
|
+ ((struct ToneData_t*)appContext->additionalData)->animationOffset = 0;
|
|
|
|
|
+ ((struct ToneData_t*)appContext->additionalData)->amplitude = 1;
|
|
|
|
|
+ ((struct ToneData_t*)appContext->additionalData)->period = 1;
|
|
|
|
|
+ ((struct ToneData_t*)appContext->additionalData)->waveType = SINE;
|
|
|
|
|
+
|
|
|
result = setupViews(&appContext);
|
|
result = setupViews(&appContext);
|
|
|
if(result == 0) {
|
|
if(result == 0) {
|
|
|
// set the scene and launch the main loop
|
|
// set the scene and launch the main loop
|