diff --git a/Firmware/Display_Objects_Datatypes.h b/Firmware/Display_Objects_Datatypes.h index 0098565..603cf36 100644 --- a/Firmware/Display_Objects_Datatypes.h +++ b/Firmware/Display_Objects_Datatypes.h @@ -54,9 +54,9 @@ /******************************************************************* Forwward Declarations *******************************************************************/ -typedef struct Menu_Item_S Menu_Item; -typedef struct Menu_List_S Menu_List; -typedef struct Hierarchical_Menu_S Hierarchical_Menu; +typedef struct Menu_Item_s Menu_Item; +typedef struct Menu_List_s Menu_List; +typedef struct Hierarchical_Menu_s Hierarchical_Menu; /******************************************************************* diff --git a/Firmware/Hierarchical_Menu.c b/Firmware/Hierarchical_Menu.c index cb1f58b..46bdeb6 100644 --- a/Firmware/Hierarchical_Menu.c +++ b/Firmware/Hierarchical_Menu.c @@ -27,12 +27,22 @@ static const Menu_List _Menu_List_MIDI; const Hierarchical_Menu _Hierarchical_Menu_MIDI; // ============================================================================================ -// Variables +// Variables Configuration +static const Menu_Configuration_Select_Value _Select_Value_Fade_Speed = { + .Min = 1, + .Max = UINT8_MAX, + .Format = "%u" +}; + + + +// ============================================================================================ +// Variables Hierarchical Menu static const Menu_Item _Menu_Items_MIDI_Config[] = { - { "MIDI Channel" , NULL, false, &_Menu_List_MIDI_Config, NONE, "", NULL }, - { "Select Octave" , NULL, false, &_Menu_List_MIDI_Config, NONE, "", NULL }, - { "Skip Note Off" , NULL, false, &_Menu_List_MIDI_Config, BOOL, "Skip Note Off", (void*)(&_EEPROM_Content.Channel_MIDI_Configuration[0].Skip_Note_Off_Event) }, - { "Back" , NULL, true , &_Menu_List_MIDI_Config, NONE, "", NULL } + { "MIDI Channel" , NULL, false, &_Menu_List_MIDI_Config, NONE, "", NULL, NULL }, + { "Select Octave" , NULL, false, &_Menu_List_MIDI_Config, NONE, "", NULL, NULL }, + { "Skip Note Off" , NULL, false, &_Menu_List_MIDI_Config, BOOL, "Skip Note Off", (void*)(&_EEPROM_Content.Channel_MIDI_Configuration[0].Skip_Note_Off_Event), NULL }, + { "Back" , NULL, true , &_Menu_List_MIDI_Config, NONE, "", NULL, NULL } }; static const Menu_List _Menu_List_MIDI_Config = { @@ -45,11 +55,11 @@ static const Menu_List _Menu_List_MIDI_Config = { static const Menu_Item _Menu_Items_MIDI_Notes[] = { - { "Red" , NULL, false, &_Menu_List_MIDI_Notes, NONE, "", NULL }, - { "Green" , NULL, false, &_Menu_List_MIDI_Notes, NONE, "", NULL }, - { "Blue" , NULL, false, &_Menu_List_MIDI_Notes, NONE, "", NULL }, - { "Default Notes" , NULL, false, &_Menu_List_MIDI_Notes, NONE, "", NULL }, - { "Back" , NULL, true , &_Menu_List_MIDI_Notes, NONE, "", NULL } + { "Red" , NULL, false, &_Menu_List_MIDI_Notes, NONE, "", NULL, NULL }, + { "Green" , NULL, false, &_Menu_List_MIDI_Notes, NONE, "", NULL, NULL }, + { "Blue" , NULL, false, &_Menu_List_MIDI_Notes, NONE, "", NULL, NULL }, + { "Default Notes" , NULL, false, &_Menu_List_MIDI_Notes, NONE, "", NULL, NULL }, + { "Back" , NULL, true , &_Menu_List_MIDI_Notes, NONE, "", NULL, NULL } }; static const Menu_List _Menu_List_MIDI_Notes = { @@ -62,18 +72,12 @@ static const Menu_List _Menu_List_MIDI_Notes = { static const Menu_Item _Menu_Items_MIDI_Pause[] = { - { "Enable" , NULL, false, &_Menu_List_MIDI_Pause, BOOL, "Enable Pause Light", (void*)(&_EEPROM_Content.Pause_Light_Configuration[0].Enabled) }, - { "Color" , NULL, false, &_Menu_List_MIDI_Pause, RGB , "Pause Light Color", (void*)(&_EEPROM_Content.Pause_Light_Configuration[0].Color) }, - { "Fade Speed" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL }, - { "Timeout" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL }, - { "Reset" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL }, - { "Item 1" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL }, - { "Item 2" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL }, - { "Item 3" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL }, - { "Item 4" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL }, - { "Item 5" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL }, - { "Item 6" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL }, - { "Back" , NULL, true , &_Menu_List_MIDI_Pause, NONE, "", NULL } + { "Enable" , NULL, false, &_Menu_List_MIDI_Pause, BOOL, "Enable Pause Light", (void*)(&_EEPROM_Content.Pause_Light_Configuration[0].Enabled), NULL }, + { "Color" , NULL, false, &_Menu_List_MIDI_Pause, RGB , "Pause Light Color", (void*)(&_EEPROM_Content.Pause_Light_Configuration[0].Color), NULL }, + { "Fade Speed" , NULL, false, &_Menu_List_MIDI_Pause, VALUE, "Pause Light Fade Speed", (void*)(&_EEPROM_Content.Pause_Light_Configuration[0].Fade_Speed), (void*)(&_Select_Value_Fade_Speed)}, + { "Timeout" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL, NULL }, + { "Reset" , NULL, false, &_Menu_List_MIDI_Pause, NONE, "", NULL, NULL }, + { "Back" , NULL, true , &_Menu_List_MIDI_Pause, NONE, "", NULL, NULL } }; static const Menu_List _Menu_List_MIDI_Pause = { diff --git a/Firmware/Hierarchical_Menu.h b/Firmware/Hierarchical_Menu.h index 27bd9c8..7878f1b 100644 --- a/Firmware/Hierarchical_Menu.h +++ b/Firmware/Hierarchical_Menu.h @@ -23,9 +23,9 @@ // ============================================================================================ // Forward declarations -typedef struct Menu_Item_S Menu_Item; -typedef struct Menu_List_S Menu_List; -typedef struct Hierarchical_Menu_S Hierarchical_Menu; +typedef struct Menu_Item_s Menu_Item; +typedef struct Menu_List_s Menu_List; +typedef struct Hierarchical_Menu_s Hierarchical_Menu; // ============================================================================================ @@ -33,10 +33,18 @@ typedef struct Hierarchical_Menu_S Hierarchical_Menu; typedef enum { NONE, BOOL, - RGB + RGB, + VALUE } Variable_Type; -typedef struct Menu_Item_S { +typedef struct { + int32_t Min; + int32_t Max; + char* Format; +} Menu_Configuration_Select_Value; + + +typedef struct Menu_Item_s { const char* Text; const Menu_List* List; const bool Is_Back; @@ -45,9 +53,10 @@ typedef struct Menu_Item_S { const Variable_Type Type; const char* Variable_Title; const void* Variable; + const void* Configuration; } Menu_Item; -typedef struct Menu_List_S { +typedef struct Menu_List_s { const char* Title; const Menu_Item* Items; const uint32_t Item_Count; @@ -55,7 +64,7 @@ typedef struct Menu_List_S { const Hierarchical_Menu* Root; } Menu_List; -typedef struct Hierarchical_Menu_S { +typedef struct Hierarchical_Menu_s { const Menu_List* List; const void (*Parent_Function)(Screen_Transition_Direction, Screen_Transition_Direction, Easing, uint32_t, int32_t); const int32_t Parent_Selected_Setting; diff --git a/Firmware/Screens.h b/Firmware/Screens.h index 814a049..64b6efc 100644 --- a/Firmware/Screens.h +++ b/Firmware/Screens.h @@ -54,6 +54,6 @@ extern void Screen_Setup_Settings_About(Screen_Transition_Direction direction_ou extern void Screen_Setup_Select_Bool(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration, char* title, uint32_t title_length, uint8_t *value, const Hierarchical_Menu* return_menu, const Menu_List* return_list, int32_t return_selected_item); extern void Screen_Setup_Select_RGB(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration, char* title, uint32_t title_length, LED_Data_t* rgb_color, const Hierarchical_Menu* return_menu, const Menu_List* return_list, int32_t return_selected_item); - +extern void Screen_Setup_Select_Value(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration, char* title, uint32_t title_length, int32_t* value, const Menu_Configuration_Select_Value* config, const Hierarchical_Menu* return_menu, const Menu_List* return_list, int32_t return_selected_item); #endif /* SCREENS_H_ */ \ No newline at end of file diff --git a/Firmware/Screens_Display/Screen_Select_Value.c b/Firmware/Screens_Display/Screen_Select_Value.c new file mode 100644 index 0000000..3bba44c --- /dev/null +++ b/Firmware/Screens_Display/Screen_Select_Value.c @@ -0,0 +1,165 @@ +/* + * File: Screen_Select_Value.c + * + * Created: Created: Friday August 2025 13:35:25 + * Author: Chris + */ + +// ============================================================================================ +// Includes +#include "../Screens.h" +#include "../UI_Control.h" +#include "../Command_Definition.h" + +#include "../Display.h" +#include "../Display_Objects.h" +#include "../Display_Default_Configurations.h" + + +// ============================================================================================ +// Variables +static Object_ID _Object_Message_Box; + +static const Hierarchical_Menu* _Return_Menu = NULL; +static const Menu_List* _Return_List = NULL; +static int32_t _Return_Selected_Item; + +static char* _Title; +static uint32_t _Title_Length; +static int32_t* _Value; +static const Menu_Configuration_Select_Value* _Config; + +static bool _Decision_Made; +static uint32_t _Counter; + + +// ============================================================================================ +// Function Declarations +void Screen_Setup_Select_Value(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration, char* title, uint32_t title_length, int32_t* value, const Menu_Configuration_Select_Value* config, const Hierarchical_Menu* return_menu, const Menu_List* return_list, int32_t return_selected_item); + +static void Screen_Init (Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration); +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_Select_Value(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration, char* title, uint32_t title_length, int32_t* value, const Menu_Configuration_Select_Value* config, const Hierarchical_Menu* return_menu, const Menu_List* return_list, int32_t return_selected_item) +{ + _Value = value; + _Config = config; + + Screen_Init(direction_out, direction_in, type, frame_duration); + + _Return_Menu = return_menu; + _Return_List = return_list; + _Return_Selected_Item = return_selected_item; + + _Decision_Made = false; + _Counter = 0; +} + +void Screen_Init(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration) +{ + _Screen_Tick = Screen_Tick; + _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 // + ////////////////////////////// + Display_Objects_Add_Select_Value(_Title, _Title_Length, _Value, _Config->Max, _Config->Min, _Config->Format, &_Configuration_Default_Select_Value); + _Object_Message_Box = Display_Objects_Add_Message_Box(CENTER_MIDDLE, BOTH_IN_PERCENT, 50, 50, "Saved", MESSAGE_BOX_ICON_CIRCLE_CHECKMARK, &_Message_Box_Style_Regular); + + Display_Select_Object(); + + UI_Control_Acceleration_Reset(); + UI_Control_Acceleration_Set_Enabled(true); +} + +void Screen_Tick(void) +{ + if(_Decision_Made) { + _Counter++; + } + + if(_Counter == MESSAGE_BOX_DEFAULT_TICKS) { + Screen_Setup_Settings_Hierarchical_Menu(TRANSITION_DOWN, TRANSITION_RIGHT, SCREEN_TRANSITION_DEFAULT_EASING, SCREEN_TRANSITION_DEFAULT_FRAMES, _Return_Menu, _Return_List, _Return_Selected_Item); + } +} + +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) +{ + if(_Decision_Made) { + return; + } + + UI_Control_Selector_Inc(_Value, _Config->Min, _Config->Max, true); +} + +void Screen_Action_CCW(Object_ID object_id) +{ + if(_Decision_Made) { + return; + } + + UI_Control_Selector_Dec(_Value, _Config->Min, _Config->Max, 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) +{ + if(!_Decision_Made) { + Display_Objects_Show_Message_Box(_Object_Message_Box, MESSAGE_BOX_DEFAULT_TICKS); + _Decision_Made = true; + } +} + + +/******************************************************************* + Internal Functions +*******************************************************************/ + diff --git a/Firmware/Screens_Display/Screen_Settings_Hierarchical_Menu.c b/Firmware/Screens_Display/Screen_Settings_Hierarchical_Menu.c index bbe6282..00ad8bc 100644 --- a/Firmware/Screens_Display/Screen_Settings_Hierarchical_Menu.c +++ b/Firmware/Screens_Display/Screen_Settings_Hierarchical_Menu.c @@ -251,6 +251,9 @@ void Handle_Item_Selection(void) Screen_Setup_Select_RGB(TRANSITION_LEFT, TRANSITION_UP, SCREEN_TRANSITION_DEFAULT_EASING, SCREEN_TRANSITION_DEFAULT_FRAMES, (char*)Selected_Item->Variable_Title, strlen(Selected_Item->Variable_Title), (LED_Data_t*)Selected_Item->Variable, _Menu, Selected_Item->Containing_List, _Selected_Item); break; + case VALUE: + break; + case NONE: default: break; diff --git a/Firmware/build/build_number.txt b/Firmware/build/build_number.txt index 2e5658d..0d635ca 100644 --- a/Firmware/build/build_number.txt +++ b/Firmware/build/build_number.txt @@ -1 +1 @@ -422 +426 diff --git a/Housing/RP2350_MIDI_Lighter_Housing.scad b/Housing/RP2350_MIDI_Lighter_Housing.scad index 13f0b43..11b8d48 100644 --- a/Housing/RP2350_MIDI_Lighter_Housing.scad +++ b/Housing/RP2350_MIDI_Lighter_Housing.scad @@ -8,10 +8,10 @@ include Show_FAD_Logo = false; -Show_PCB = false; -Audio_Jack_Present = false; +Show_PCB = true; +Audio_Jack_Present = true; Debug_Present = true; -$preview = true; +$preview = false; @@ -32,12 +32,37 @@ if(Show_PCB) // Bottom_Wall(); // rotate([0, 180, 0]) // translate([0, 0, eps]) Display_GC9A01A_Cover(); -MIDI_Plug_Solder_Guide(); +Power_Plug_Solder_Guide(); +// MIDI_Plug_Solder_Guide(Audio_Jack_Present); -module MIDI_Plug_Solder_Guide() +module Power_Plug_Solder_Guide() +{ + Main_Block_Z = 13; + + difference() + { + translate(Power_Plug) translate([2.5, 0, Main_Block_Z/2 + PCB_T/2 +eps]) cube([12, 18, Main_Block_Z], center=true); + + translate(Power_Plug) translate([-2, 6+eps, 0]) cube([8, 6, 100], center=true); + translate(Power_Plug) translate([0, -8, 2 + PCB_T/2 - eps]) cube([20, 6, 4], center=true); + Screw_Holes_M3(); + + translate(Power_Plug) + translate([10.625, -2.4, 0]) + translate([-3.5, 0, 0]) + scale(1.05) + { + translate([3.5/2-eps, 0, 11/2]) cube([ 3.5, 9, 11.0], center=true); + translate([-10.9/2, 0, 6.4/2]) cube([10.9, 9, 6.4], center=true); + translate([-10.9/2, 0, 6.4]) rotate([0, 90, 0]) cylinder(h=10.9, d=9, center=true, $fn=60); + } + } +} + +module MIDI_Plug_Solder_Guide(Audio_Jack_Present = false) { Main_Block_X = PCB_W + 2*Cover_O; - Main_Block_Y = 13.335 + 2; + Main_Block_Y = 13.335 + 4; difference() { @@ -51,9 +76,14 @@ module MIDI_Plug_Solder_Guide() for (i = MIDI_Plugs) { translate(i) { translate([0, -5, 10.2/2]) cube([18.2, 10.0, 10.20], center=true); - translate([0, -0.5-10-0.5+eps, 20.35/2]) cube([20.5, 2.0, 20.35], center=true); + translate([0, -0.5-10-0.25+eps, 20.35/2]) cube([21.5, 2.5, 20.35], center=true); } } + + if(Audio_Jack_Present) { + translate(Audio_Jack) translate([0, -3, 5 + PCB_T/2]) cube([8, 20, 10], center=true); + translate(Audio_Jack) translate([0, 0, 0.5 + PCB_T/2-eps]) cube([12, 20, 1], center=true); + } } } @@ -144,7 +174,7 @@ module Top_Wall() translate([0, 0, -Wall_T_H/2 - Overlao_H/2 - eps]) cube([PCB_W + 1*Cover_O, PCB_H + 1*Cover_O, Overlao_H], center=true); } - cube( [PCB_W + 0*Cover_O + 0.5, PCB_H + 0*Cover_O + 0.5 , 2*Wall_T_H], center=true); + cube([PCB_W + 0*Cover_O + 0.5, PCB_H + 0*Cover_O + 0.5 , 2*Wall_T_H], center=true); translate([0, 0, +Wall_T_H/2 - Cover_T_T/2]) cube([PCB_W + 1*Cover_O, PCB_H + 1*Cover_O, Cover_T_T + eps], center=true); } @@ -163,8 +193,6 @@ module Top_Wall() } } - - translate([PCB_W/2, PCB_H/2, +Wall_T_H/2]) { // For the MOLEX Connector @@ -174,9 +202,9 @@ module Top_Wall() if(Audio_Jack_Present) { Top_Wall_Remove_Part("bottom", 3.5, 10, Audio_Jack[0]); } - Top_Wall_Remove_Part("right", 6.5, 3.5, Button[1]); - translate([-Cover_O, 0, 0]) Top_Wall_Remove_Part("right", PCB_T/2 + 8.0, 8.0, Button[1]); - Top_Wall_Remove_Part("right", PCB_T/2+2.5, 16, USB_C[1]); + Top_Wall_Remove_Part("right", 7.0, 3.5, Button[1]); + translate([-Cover_O + eps, 0, 0]) Top_Wall_Remove_Part("right", PCB_T/2 + 8.0, 8.0, Button[1]); + Top_Wall_Remove_Part("right", PCB_T/2+2.2, 16, USB_C[1]); // Cutout for Debug Connector if(Debug_Present) { @@ -194,6 +222,7 @@ module Top_Wall() } translate([0, 0, Cover_T_T]) Top_Wall_Add_Inner_Wall("right", Wall_T_H, Cover_O/2, 1, Power_Plug[1]+2.5); + translate([0, 0, Cover_T_T]) Top_Wall_Add_Inner_Wall("right", Wall_T_H - 3.0, Cover_O/2, 1, Power_Plug[1]-7.8); } } diff --git a/Housing/RP2350_MIDI_Lighter_PCB.scad b/Housing/RP2350_MIDI_Lighter_PCB.scad index 29f7386..141797b 100644 --- a/Housing/RP2350_MIDI_Lighter_PCB.scad +++ b/Housing/RP2350_MIDI_Lighter_PCB.scad @@ -353,6 +353,7 @@ module MIDI_Plug_MABPM_5S(cutout = false) if(cutout == true) { + translate([0, 0, 1]) union() { translate([0, -10-2, 20.35/2]) rotate([90, 0, 0]) cylinder(h=50, d=18, center=true, $fn = $preview ? 32 : 100);