-
Notifications
You must be signed in to change notification settings - Fork 52
Code Reference
Nils Feldkämper edited this page Jul 13, 2020
·
13 revisions
##Defines
// display characteristics
#define _LCDML_DISP_cols 20
#define _LCDML_DISP_rows 4
// this value have to be the same as the last menu element
#define _LCDML_DISP_cnt 17 ##Objects
LCDML // object of the LCDMenuLib2 class
LCDML_0 // object of the first menu element##Makros
All Makros start "LCDML_"
// create some global used variables, have to be called under the
// creation of the menu and outside of any other functions
LCDML_createMenu(_LCDML_DISP_cnt);
// have to be placed in the main setup function
LCDML_setup(_LCDML_DISP_cnt);
// add menu elements to the menu
// id = starts with 0 and have to increment with '1'
// parent = at level 0 the parent is "LCDML_0"
// at every other level the parent is the name of the level before +
// the child number _1, _2, ...
// child = 1,2,3 is the number of a child (starts with 1)
// content = is the displayed name of a menu element, can be set to "" when it is dynamic
// callback = is the menu function which is called when the element is activ
// can be set to NULL if no menu function exists
LCDML_add(id, parent, child, content, callback);
// add a advanced menu element
// id, parent, child, content have the same functionality to LCDML_add
// callback = depending on settings:
// settings = _LCDML_TYPE_default => it is a normal menu function
// settings = _LCDML_TYPE_dynParam => it is a dynContent function
// param = is a number (0-255) which is a parameter of every menu function
// condetion= is a function with a "boolean" return value
//
LCDML_addAdvanced(id, parent, child, condetion, content, callback, param, settings);
// get the menu element name and copy the name in the "var" variable
// var = is a string with _LCDML_DISP_cols characters
// id = is the id of menu element
LCDML_getContent(var, id);##LCDMenuLib methods
All methods can be called with "LCDML."
// constructor
LCDMenuLib2(LCDMenuLib2_menu &p_r ,const uint8_t p_rows, const uint8_t p_cols, LCDML_FuncPtr contentUpdate, LCDML_FuncPtr contentClear, LCDML_FuncPtr menuControl);
// init method
void LCDML.init(uint8_t); // initialisation of the menu / reset the complete menu// loop methods
void LCDML.loop(void); // call the loop_menu and the loop_control function
void LCDML.loop_control(void); // call callback function to control the menu
void LCDML.loop_menu(void); // checks if a button or a menu function are needed and call them// menu methods
void LCDML.MENU_display(uint8_t update=0); // update the current menu structure but do not display it
void LCDML.MENU_goRoot(void); // set the cursor to the root element
void LCDML.MENU_enRollover(void); // enable menu rollover (first to last or last to first element on a layer)
void LCDML.MENU_disRollover(void); // disable the menu rollover function
void LCDML.MENU_enScroll(void); // enable the scroll function (this function can be disabled on dyn content elements and when a encoder is used)
void LCDML.MENU_disScroll(void); // disable the scroll function to catch the cursor to an dyn content element when a encoder is used
void LCDML.MENU_setDynContent(void); // set this value when dyn content is shown on the current windows of the display
uint8_t LCDML.MENU_checkDynContent(void); // check if dyn content is displayed
bool LCDML.MENU_getScrollDisableStatus(void); // check if the scroll function is disabled
uint8_t LCDML.MENU_getLayer(void); // get the current layer of the menu
uint8_t LCDML.MENU_getCursorPos(void); // get the current cursor position (row 0, row 1, row 2, ...)
uint8_t LCDML.MENU_getCursorPosAbs(void); // get the current cursor postion absolute (..., row 10, row 11, ..) based on the menu structure
uint8_t LCDML.MENU_getChilds(void); // get the current number of childs on this layer
uint8_t LCDML.MENU_getParentID(uint8_t p_layer=0); // get the parent id of a selected higher layer
uint8_t LCDML.MENU_getScroll(void); // get the current scroll value
uint8_t LCDML.MENU_getLastActiveFunctionID(void); // returns the id of the last active function
uint8_t LCDML.MENU_getLastCursorPositionID(void); // returns the last cursor position function id
uint8_t LCDML.MENU_getElementIDFromCursorPos(void); // returns the menu element id from current cursor position
void LCDML.MENU_setDynFunctionContentUpdate(void); // this is a special function for dynamic content to update the dynamic content again
void LCDML.MENU_clearDynFunctionContentUpdate(void);// this is a special function to clear the dynamic content update. this function is called internally LCDMenuLib2_menu * LCDML.MENU_getDisplayedObj(void); // get the objection with the current content to display
LCDMenuLib2_menu * LCDML.MENU_getCurrentObj(void); // get the current menu child object
LCDMenuLib2_menu * LCDML.MENU_getRootObj(void); // get the root menu object// BT = button methods
bool LCDML.BT_setup(void); // check if the button initialisation was done
void LCDML.BT_enter(void); // set button enter
void LCDML.BT_up(void); // set button up
void LCDML.BT_down(void); // set button down
void LCDML.BT_left(void); // set button left
void LCDML.BT_right(void); // set button right
void LCDML.BT_quit(void); // set button quit
//
void LCDML.BT_resetAll(void); // reset all button states
void LCDML.BT_resetEnter(void); // reset enter button state
void LCDML.BT_resetUp(void); // reset up button state
void LCDML.BT_resetDown(void); // reset down button state
void LCDML.BT_resetLeft(void); // reset left button state
void LCDML.BT_resetRight(void); // reset right button state
void LCDML.BT_resetQuit(void); // reset quit button state
//
bool LCDML.BT_checkAny(void); // check if any button was pressed
bool LCDML.BT_checkEnter(void); // check enter button
bool LCDML.BT_checkUp(void); // check up button
bool LCDML.BT_checkDown(void); // check down button
bool LCDML.BT_checkLeft(void); // check left button
bool LCDML.BT_checkRight(void); // check right button
bool LCDML.BT_checkQuit(void); // check quit button // CE = custom event
bool LCDML.CE_setup(void); // check if the button initialisation was done
void LCDML.CE_set(uint8_t p_event); // set button enter
//
void LCDML.CE_resetAll(void); // reset all button states
void LCDML.CE_reset(uint8_t p_event); // reset enter button state
//
bool LCDML.CE_checkAny(void); // check if any button was pressed
bool LCDML.CE_check(uint8_t p_event); // check enter button
//
void LCDML.CE_setOnChangeCbFunction(uint8_t p_event, LCDML_FuncPtr_pu8 p_function); // add callback function
void LCDML.CE_clearOnChangeCbFunction(uint8_t p_event); // remove callback function// display methods
void LCDML.DISP_update(void); // display the content and update the menu structure
void LCDML.DISP_menuUpdate(void); // display the content but do not update the menu structure
void LCDML.DISP_clear(void); // calls the callback function to clear the display
bool LCDML.DISP_checkMenuUpdate(void); // check if there is new content to display
bool LCDML.DISP_checkMenuCursorUpdate(void); // check if the cursor was moved
uint8_t LCDML.DISP_getMenuContentId(uint8_t n); // get the id`s from a contentelement for a special line // menu function methods
bool LCDML.FUNC_setup(void); // check if a menu function is called the first time to init some things
bool LCDML.FUNC_loop(void); // check if a menu function is running in a loop
bool LCDML.FUNC_close(void); // check if a menu function is closed to reach a stable state
void LCDML.FUNC_goBackToMenu(uint8_t p_goBackCnt=0); // close the current menu function (the FUNC_close check is true when this is set)
uint8_t LCDML.FUNC_getID(void); // get the ID of the current menu function
void LCDML.FUNC_setLoopInterval(unsigned long p_t); // set a loop intervall for the current menu function the default loop intervall is 100000000 ms
void LCDML.FUNC_disableScreensaver(void); // disable the screensaver for the current menu function
void LCDML.FUNC_setGBAToLastCursorPos(void); // set a special "go back handling" - only to last cursor position
void LCDML.FUNC_setGBAToLastFunc(void); // set a special "go back handling" - only to last function
void LCDML.FUNC_setGBA(void); // set a special "go back handling" which decide between the two function above
void LCDML.FUNC_setCEMask(unsigned long p_mask); // set a mask to enable only special events for a menu function// timer methods
bool LCDML.TIMER_ms(unsigned long &p_var, unsigned long p_t); // a small timer based on the millis() function
void LCDML.TIMER_msReset(unsigned long &p_var); // reset the millis timer
bool LCDML.TIMER_us(unsigned long &p_var, unsigned long p_t); // a small timer based on the micros() function
void LCDML.TIMER_usReset(unsigned long &p_var); // reset the micros timer// other methods
void LCDML.OTHER_jumpToFunc(LCDML_FuncPtr_pu8 p_search, uint8_t p_para = 0); // jumpTo a defined function based on the function name
void LCDML.OTHER_jumpToID(uint8_t p_search, uint8_t p_para = 0); // jumpTo a defined function based on the function id
void LCDML.OTHER_setCursorToID(uint8_t p_search); // set the cursor to a defined function based on the id
void LCDML.OTHER_setCursorToFunc(LCDML_FuncPtr_pu8 p_search); // set the cursor to a defined function based on the function name
uint8_t LCDML.OTHER_getIDFromFunction(LCDML_FuncPtr_pu8 p_search); // get the menu element id from a menu element function name
void LCDML.OTHER_updateFunc(void); // update a menu function directly when it runs // screensaver methods
void LCDML.SCREEN_enable(LCDML_FuncPtr_pu8 p_function, unsigned long p_t); // enable the screensaver feature
void LCDML.SCREEN_disable(void); // disable the screensaver feature
void LCDML.SCREEN_resetTimer(void); // reset the screensaver timer
void LCDML.SCREEN_start(void); // start the screensaver directly