/* * Screen_Menu_Main.c * * Created: Fri Apr 02 2021 14:34:01 * Author Chris */ // ============================================================================================ // Includes #include "../Screens.h" #include "../UI_Control.h" #include "../Display_Default_Configurations.h" #include "../Display.h" #include "../Display_Objects.h" // ============================================================================================ // Defines #define ENTRY_COUNT 4 // ============================================================================================ // Variables extern const unsigned char _Font_DejaVu_Sans_Mono_10x17[]; extern const uint16_t _Image_Computer_64x64[]; extern const uint16_t _Image_Energy_64x64[]; extern const uint16_t _Image_Music_64x64[]; extern const uint16_t _Image_Setting_64x64[]; static Object_ID _Object_Ring_Menu; static int32_t _Ring_Menu_Selected = 0; // 0 = Mode, 1 = MIDI, 2 = Power, 3 = Settings // Define your 4 menu items static Menu_Ring_Item_Config _Ring_Menu_Items[ENTRY_COUNT] = { { .Label = "MIDI", .Icon = _Image_Music_64x64 }, { .Label = "SETUP", .Icon = _Image_Setting_64x64 }, { .Label = "POWER", .Icon = _Image_Energy_64x64 }, { .Label = "MODE", .Icon = _Image_Computer_64x64 } }; // Ring menu configuration static Configuration_Menu_Ring _Ring_Menu_Config = { .Center_Text_Color = DISPLAY_COLOR_FROM_RGB888(100, 181, 246), .Center_BG_Color = DISPLAY_COLOR_FROM_RGB888(26, 26, 46), .Center_Border_Color = DISPLAY_COLOR_FROM_RGB888(51, 51, 51), .Selection_Ring_Color = DISPLAY_COLOR_FROM_RGB888(255, 215, 0), .Center_Text_Font = _Font_DejaVu_Sans_Mono_10x17, .Item_Radius = 85, .Center_Size = 90, .Image_Size = 64, .Selection_Ring_Diameter = 0, .Selection_Ring_Thickness = 3, .Selection_Ring_Padding = 0, .Selection_Scale = 1.15f, .Animation_Duration = 15, .Idle_Rotation_Speed = 2.0f, .Start_Angle_Degrees = 0.0f, .Distribute_Evenly = true, .Fixed_Angle_Step = 90.0f, .Enable_Appear_Animation = false }; // ============================================================================================ // Function Declarations void Screen_Setup_Menu_Main(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration, bool do_menu_animation, uint32_t selected_entry); static void Screen_Tick (void); static void Screen_Click (uint button_return_value); static void Screen_Touch_Event (int16_t x, int16_t y); static void Screen_Action_CW (Object_ID object_id); static void Screen_Action_CCW (Object_ID object_id); static void Screen_On_Object_Focused (Object_ID object_id); static void Screen_On_Object_Defocused (Object_ID object_id); static void Screen_On_Object_Select (Object_ID object_id); static void Screen_On_Object_Deselect (Object_ID object_id); /******************************************************************* Functions *******************************************************************/ void Screen_Setup_Menu_Main(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration, bool do_menu_animation, uint32_t selected_entry) { _Screen_Tick = Screen_Tick; _Screen_Click = Screen_Click; _Screen_Touch_Event = Screen_Touch_Event; _Screen_Action_CW = Screen_Action_CW; _Screen_Action_CCW = Screen_Action_CCW; _Screen_On_Objects_Focused = Screen_On_Object_Focused; _Screen_On_Objects_Defocused = Screen_On_Object_Defocused; _Screen_On_Object_Select = Screen_On_Object_Select; _Screen_On_Object_Deselect = Screen_On_Object_Deselect; Display_Objects_Clear(); Display_Screen_Transition_Start(direction_out, direction_in, type, frame_duration); ////////////////////////////// // Add Display Objects here // ////////////////////////////// _Object_Ring_Menu = Display_Objects_Add_Menu_Ring(_Ring_Menu_Items, ENTRY_COUNT, &_Ring_Menu_Selected, &_Ring_Menu_Config); if(do_menu_animation) { Display_Objects_Menu_Ring_Start_Appear_Animation(_Object_Ring_Menu); } Display_Select_First_Object(); Display_Select_Object(); // Initialize values _Ring_Menu_Selected = 0; if(selected_entry < ENTRY_COUNT) { _Ring_Menu_Selected = selected_entry; } } void Screen_Tick(void) { } void Screen_Click(uint button_return_value) { } void Screen_Touch_Event(int16_t x, int16_t y) { } void Screen_Action_CW(Object_ID object_id) { UI_Control_Selector_Inc(&_Ring_Menu_Selected, 0, ENTRY_COUNT-1, true); } void Screen_Action_CCW(Object_ID object_id) { UI_Control_Selector_Dec(&_Ring_Menu_Selected, 0, ENTRY_COUNT-1, true); } void Screen_On_Object_Focused(Object_ID object_id) { } void Screen_On_Object_Defocused(Object_ID object_id) { } void Screen_On_Object_Select(Object_ID object_id) { } void Screen_On_Object_Deselect(Object_ID object_id) { switch (_Ring_Menu_Selected) { case 0: break; case 1: Screen_Setup_Settings(TRANSITION_UP, TRANSITION_UP, INOUT_SINE, 15); break; case 2: break; case 3: break; } Display_Select_Object(); } /******************************************************************* Internal Functions *******************************************************************/