{"action":"created","issue":{"url":"https://api.github.com/repos/jonblack/arduino-menusystem/issues/32","repository_url":"https://api.github.com/repos/jonblack/arduino-menusystem","labels_url":"https://api.github.com/repos/jonblack/arduino-menusystem/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/jonblack/arduino-menusystem/issues/32/comments","events_url":"https://api.github.com/repos/jonblack/arduino-menusystem/issues/32/events","html_url":"https://github.com/jonblack/arduino-menusystem/issues/32","id":155050831,"number":32,"title":"Moving Menu Names and Items into PROGMEM","user":{"login":"jecottrell","id":19391382,"avatar_url":"https://avatars.githubusercontent.com/u/19391382?v=3","gravatar_id":"","url":"https://api.github.com/users/jecottrell","html_url":"https://github.com/jecottrell","followers_url":"https://api.github.com/users/jecottrell/followers","following_url":"https://api.github.com/users/jecottrell/following{/other_user}","gists_url":"https://api.github.com/users/jecottrell/gists{/gist_id}","starred_url":"https://api.github.com/users/jecottrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jecottrell/subscriptions","organizations_url":"https://api.github.com/users/jecottrell/orgs","repos_url":"https://api.github.com/users/jecottrell/repos","events_url":"https://api.github.com/users/jecottrell/events{/privacy}","received_events_url":"https://api.github.com/users/jecottrell/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jonblack/arduino-menusystem/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-16T15:13:15Z","updated_at":"2016-05-17T03:25:33Z","closed_at":null,"body":"I'm running up against a dynamic memory limit with an involved menu tree. I've tried all of the PROGMEM ideas presented by Dean Camera (fourwalledcubicle) and I haven't been successful. Is there any way to achieve that?\r\n\r\nHere is the beginning of my menu system:\r\n\r\n```\r\nMenuSystem ms;\r\nMenu mm(\"HOME\");\r\n  MenuItem mm_mi1(\"Status\");\r\n  Menu mu2(\"MODES\");\r\n    Menu mu21(\"AUTO\");\r\n      MenuItem mu21_mi1(\"Select\");\r\n    Menu mu22(\"MANUAL\");\r\n      MenuItem mu22_mi1(\"Select\");\r\n      MenuItem mu22_mi2(\"Move Doors\");\r\n      MenuItem mu22_mi3(\"Move Nest Gates\");\r\n      MenuItem mu22_mi4(\"Switch Lights\");\r\n  Menu mu3(\"SETTINGS\");\r\n    MenuItem mu3_mi1(\"Set Time\");\r\n    MenuItem mu3_mi2(\"Set Date\");\r\n    Menu mu31(\"DOOR SCHEDULE\");\r\n      MenuItem mu31_mi1(\"Door Open Time\");\r\n      MenuItem mu31_mi2(\"Door Close Time\");\r\n    Menu mu32(\"NEST SCHEDULE\");\r\n      MenuItem mu32_mi1(\"Nest Open Time\");\r\n      MenuItem mu32_mi2(\"Nest Close Time\");\r\n    Menu mu33(\"LIGHT SCHEDULE\");\r\n      Menu mu331(\"LIGHT AM SCHED\");\r\n        MenuItem mu331_mi1(\"Lights AM On\");\r\n        MenuItem mu331_mi2(\"Lights AM Off\");\r\n      Menu mu332(\"LIGHT PM SCHED\");\r\n        MenuItem mu332_mi1(\"Lights PM On\");\r\n        MenuItem mu332_mi2(\"Lights PM Off\");\r\n```\r\n\r\n\r\nThanks for developing and sharing your code. It's been an INCREDIBLE help with my latest project.\r\n\r\nJohn"},"comment":{"url":"https://api.github.com/repos/jonblack/arduino-menusystem/issues/comments/219610224","html_url":"https://github.com/jonblack/arduino-menusystem/issues/32#issuecomment-219610224","issue_url":"https://api.github.com/repos/jonblack/arduino-menusystem/issues/32","id":219610224,"user":{"login":"jecottrell","id":19391382,"avatar_url":"https://avatars.githubusercontent.com/u/19391382?v=3","gravatar_id":"","url":"https://api.github.com/users/jecottrell","html_url":"https://github.com/jecottrell","followers_url":"https://api.github.com/users/jecottrell/followers","following_url":"https://api.github.com/users/jecottrell/following{/other_user}","gists_url":"https://api.github.com/users/jecottrell/gists{/gist_id}","starred_url":"https://api.github.com/users/jecottrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jecottrell/subscriptions","organizations_url":"https://api.github.com/users/jecottrell/orgs","repos_url":"https://api.github.com/users/jecottrell/repos","events_url":"https://api.github.com/users/jecottrell/events{/privacy}","received_events_url":"https://api.github.com/users/jecottrell/received_events","type":"User","site_admin":false},"created_at":"2016-05-17T03:25:32Z","updated_at":"2016-05-17T03:25:32Z","body":"So, I think I've found the solution but I'm not sure how to implement it. I was having a similar problem after declaring a constant array of constant character arrays with PROGMEM. Like this:\r\n\r\n```\r\nconst char time_str[]  PROGMEM = \"  Time: \";\r\nconst char date_str[]  PROGMEM = \"  Date: \";\r\nconst char batt_str[]  PROGMEM = \"  Batt: \";\r\nconst char wind_str[]  PROGMEM = \"  Wind: \";\r\nconst char water_str[] PROGMEM = \" Water: \";\r\nconst char light_str[] PROGMEM = \"Lights: \";\r\nconst char door_str[]  PROGMEM = \" Doors: \";\r\nconst char nest_str[]  PROGMEM = \" Nests: \";\r\n\r\n// define a string table array of strings in PROGMEM\r\nconst char* const status_string_table[] PROGMEM = {\r\n  time_str,\r\n  date_str,\r\n  batt_str,\r\n  wind_str,\r\n  water_str,\r\n  light_str,\r\n  door_str,\r\n  nest_str\r\n}; \r\n```\r\n\r\nIf I tried to print by directly referencing the table of arrays, it wouldn't work, like this:\r\n\r\n```\r\nvoid displayStatuses()\r\n{\r\n  lcd.clear();\r\n  lcd.setCursor(0,0);\r\n  lcd.print(status_string_table[status_display_index]);\r\n}\r\n```\r\n\r\nBut, after finding and using [this](https://www.arduino.cc/en/Reference/PROGMEM) approach, everything worked fine:\r\n\r\n```\r\nvoid displayStatuses()\r\n{\r\n  // Buffer for printing our arrays\r\n  char status_buffer[16];\r\n  \r\n  strcpy_P(status_buffer, (char*)pgm_read_word(&(status_string_table[status_display_index])));\r\n  \r\n  lcd.clear();\r\n  lcd.setCursor(0,0);\r\n  lcd.print(status_buffer);\r\n}\r\n```\r\n\r\n\r\nSo the question would be, how to do that in this function:\r\n\r\n```\r\nvoid displayMenu()\r\n{\r\n  // Buffer for printing our arrays\r\n  char status_buffer[16];\r\n  \r\n  lcd.clear();\r\n  lcd.setCursor(0,0);\r\n  // Display the menu\r\n  Menu const* cp_menu = ms.get_current_menu();\r\n  \r\n\r\n????\r\n  strcpy_P(status_buffer, (char*)pgm_read_word(&(cp_menu->get_name())));\r\n????\r\n\r\n  //lcd.print(\"Current menu name: \");\r\n  lcd.print(cp_menu->get_name());\r\n  \r\n  lcd.setCursor(0,1);\r\n  lcd.print('*');\r\n  \r\n  lcd.print(cp_menu->get_selected()->get_name());\r\n}\r\n```"}}