{"id":15877949,"url":"https://github.com/hubmartin/menu_library_v2","last_synced_at":"2025-07-04T15:37:46.809Z","repository":{"id":69027541,"uuid":"242383208","full_name":"hubmartin/menu_library_v2","owner":"hubmartin","description":null,"archived":false,"fork":false,"pushed_at":"2020-02-22T17:37:26.000Z","size":691,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-04T15:37:46.248Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hubmartin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-22T17:33:48.000Z","updated_at":"2022-11-14T05:19:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"f965c51b-a262-4c9a-80e6-81663c8849ca","html_url":"https://github.com/hubmartin/menu_library_v2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hubmartin/menu_library_v2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hubmartin%2Fmenu_library_v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hubmartin%2Fmenu_library_v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hubmartin%2Fmenu_library_v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hubmartin%2Fmenu_library_v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hubmartin","download_url":"https://codeload.github.com/hubmartin/menu_library_v2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hubmartin%2Fmenu_library_v2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263568107,"owners_count":23481615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T02:05:04.902Z","updated_at":"2025-07-04T15:37:46.785Z","avatar_url":"https://github.com/hubmartin.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Menu library\n\n\nImproved and more advanced menu for small embedded systems.\n\n### Features\n\n* Simple implementation on character or graphic displays\n* Multilanguage support\n* Checkbox items\n* Items with displayed parameters: integer, string\n* Automatic transparent update of menu and parameters on the screen in time\n* Callbacks for every item\n* Scrolling with cursor and selected item in the middle on the screen, so you won't accidentaly skip item that you're looking for\n\n### Demo\n\nhttps://www.youtube.com/watch?v=H0bVR4JFMfw\n\n### Simple example\n\n![](img/simple_menu_320.png)\n\n```\n#include \"m2lib/m2.h\"\n\n// Simple menu\nMenuItem menuItem0 = {{\"First\"}};\nMenuItem menuItem1 = {{\"Second\"}};\nMenu simpleMenu = {{\"Simple Menu\"}, .items = {\u0026menuItem0, \u0026menuItem1, 0}};\n\nvoid m2Test()\n{\n    unsigned char ret;\n\n    // Simple menu\n    // return value is index of the selected item\n    ret = menu2(\u0026simpleMenu);\n}\n```\n\n\n### Advanced menu example\n\n![](img/advanced_menu_320.png)\n\n```\n//\n// Advanced menu definitions\n//\n\n// Items\nMenuItem item0 = {{\"Tick\"}, callback, MENU_PARAMETER_IS_NUMBER | MENU_CALLBACK_IS_FUNCTION, (int)\u0026msTick};\nMenuItem item1 = {{\"Lang SubMnu\"}, (void*)\u0026subMenu,  MENU_CALLBACK_IS_SUBMENU, 0};\nMenuItem itemTime = {{\"Time\"}, callback, MENU_PARAMETER_IS_STRING | MENU_CALLBACK_IS_FUNCTION, (int)\"12:05\"};\nMenuItem item2 = {{\"Count\"}, callback, MENU_ITEM_IS_CHECKBOX | MENU_ITEM_IS_CHECKED | MENU_CALLBACK_IS_FUNCTION};\nMenuItem item3 = {{\"Lights\"}, callback, MENU_ITEM_IS_CHECKBOX  };\nMenuItem item4 = {{\"Sound\"}, callback, MENU_ITEM_IS_CHECKBOX | MENU_ITEM_IS_CHECKED };\nMenuItem item5 = {{\"Fan\"}, callback, MENU_ITEM_IS_CHECKBOX };\nMenuItem item6 = {{\"Buzzer\"}, callback, MENU_ITEM_IS_CHECKBOX | MENU_ITEM_IS_CHECKED };\nMenuItem item7 = {{\"Last check\"}, callback, MENU_ITEM_IS_CHECKBOX };\n\n// Menu\n// Notice that some items are duplicated, the same menuItem can be used in multiple menus or in thee same menu\nMenu menu = {\n    {\"Menu ver2\"},\n    .items = {\u0026item0, \u0026item1, \u0026itemTime, \u0026item2, \u0026item3, \u0026item2, \u0026item5, \u0026item6, \u0026item7, \u0026item3, \u0026item4, 0},\n    .refresh = 200\n};\n\nvoid m2Test()\n{\n    // Advanced menu\n    menu2(\u0026menu);\n}\n\n// Callback\nvoid callback(void *m)\n{\n    Menu* menu = ((Menu*)m);\n    MenuItem *selectedItem = menu-\u003eitems[menu-\u003eselectedIndex];\n\n    // Increment value in second menu item\n    if(selectedItem == \u0026item2)\n    {\n        selectedItem-\u003eflags |= MENU_PARAMETER_IS_NUMBER;\n        selectedItem-\u003eparameter = (int)\u0026testVal;\n        testVal++;\n        return;\n    }\n\n    displayClear();\n    displayString(\"Item callback\", 0, ROW(0));\n    displayString(\"Index:\", 0, ROW(1));\n    displayNumber(menu-\u003eselectedIndex, COL(8), ROW(1));\n    displayString(\"Item name:\", 0, ROW(2));\n    displayString(selectedItem-\u003etext[menuLanguage], 0, ROW(3));\n    displayDraw();\n\n    while(evtGet() == 0);\n}\n```\n\n### Multilanguage menu example\n\n![](img/english_menu_320.png)\n\n```\n//\n// Submenu definitions, multilanguage menu\n//\n\n// Items\nMenuItem aa = {{\"Prvni\", \"First\"}, 0, MENU_PARAMETER_IS_NUMBER, (int)\u0026msTick};\nMenuItem bb = {{\"Druha\", \"Second\"}, 0, MENU_PARAMETER_IS_NUMBER, (int)\u0026testVal};\nMenuItem cc = {{\"Zmen jazyk\", \"Change lang\"}, switchLanguage, MENU_CALLBACK_IS_FUNCTION};\n// Menu\nMenu subMenu = {{\"Czech Menu\", \"English Menu\"}, .items = {\u0026aa, \u0026bb, \u0026cc, 0}, .refresh = 1000};\n\n// Simple switching between two languages\nvoid switchLanguage(void *m)\n{\n    menuLanguage = menuLanguage == LANGUAGE_CZECH ? LANGUAGE_ENGLISH : LANGUAGE_CZECH;\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubmartin%2Fmenu_library_v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhubmartin%2Fmenu_library_v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubmartin%2Fmenu_library_v2/lists"}