diff --git a/grid_common/grid_ui_system.c b/grid_common/grid_ui_system.c index 2340b2e1..bfed4818 100644 --- a/grid_common/grid_ui_system.c +++ b/grid_common/grid_ui_system.c @@ -29,9 +29,19 @@ void grid_ui_element_system_init(struct grid_ui_element* ele) { grid_ui_event_init(ele, 2, GRID_PARAMETER_EVENT_MIDIRX, GRID_LUA_FNC_A_MIDIRX_short, grid_ui_system_midirx_actionstring); // Midi Receive grid_ui_event_init(ele, 3, GRID_PARAMETER_EVENT_TIMER, GRID_LUA_FNC_A_TIMER_short, grid_ui_system_timer_actionstring); - ele->template_initializer = NULL; - ele->template_parameter_list_length = 0; + ele->template_initializer = &grid_ui_element_system_template_parameter_init; + ele->template_parameter_list_length = GRID_LUA_FNC_S_LIST_length; ele->event_clear_cb = NULL; ele->page_change_cb = NULL; } + +void grid_ui_element_system_template_parameter_init(struct grid_ui_template_buffer* buf) { + + // printf("template parameter init\r\n"); + + uint8_t element_index = buf->parent->index; + int32_t* template_parameter_list = buf->template_parameter_list; + + template_parameter_list[GRID_LUA_FNC_S_ELEMENT_INDEX_index] = element_index; +} diff --git a/grid_common/grid_ui_system.h b/grid_common/grid_ui_system.h index fe62ee0f..df4b6d30 100644 --- a/grid_common/grid_ui_system.h +++ b/grid_common/grid_ui_system.h @@ -8,10 +8,22 @@ void grid_ui_element_system_init(struct grid_ui_element* ele); +void grid_ui_element_system_template_parameter_init(struct grid_ui_template_buffer* buf); + +#define GRID_LUA_FNC_S_ELEMENT_INDEX_index 0 +#define GRID_LUA_FNC_S_ELEMENT_INDEX_helper "0" +#define GRID_LUA_FNC_S_ELEMENT_INDEX_short "ind" +#define GRID_LUA_FNC_S_ELEMENT_INDEX_human "element_index" + +#define GRID_LUA_FNC_S_LIST_length 1 + // System init function #define GRID_LUA_SYS_META_init \ "system_meta = { __index = { \ \ + " GRID_LUA_FNC_S_ELEMENT_INDEX_short "=function (self,a) return " \ + "gtv(self.index, " GRID_LUA_FNC_S_ELEMENT_INDEX_helper ", a) end, \ + \ " GRID_LUA_FNC_A_INIT_short " = function (self) print('undefined action') end, \ " GRID_LUA_FNC_A_MAPMODE_short " = function (self) print('undefined action') end,\ " GRID_LUA_FNC_A_MIDIRX_short " = function (self) print('undefined action') end,\