menu.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * menu.c
  3. *
  4. * Created on: Jan 26, 2022
  5. * Author: radioman
  6. */
  7. /*
  8. Menu Structure:
  9. Dose rate measure
  10. Total dose measure
  11. Reset total dose
  12. Time
  13. Reset timer
  14. Settings:
  15. Measurement settings:
  16. Reset total dose
  17. Sound settings:
  18. Sound volume
  19. Sound type
  20. Buttons volume
  21. Back
  22. Alarm settings:
  23. Alarm at dose rate
  24. Alarm at dose
  25. Alarm sound type
  26. Alarm volume
  27. Back
  28. Energy-saving settings
  29. Display auto-shutdown
  30. Device auto-shutdown
  31. Back
  32. About
  33. */
  34. #include "menu.h"
  35. #include "ssd1306.h"
  36. static menu_entry_td menu[] = { \
  37. { .title = "Dose rate measure", .id = 1, .parent_id = 0 },
  38. { .title = "Total dose measure", .id = 2, .parent_id = 0 },
  39. { .title = "Up Time", .id = 3, .parent_id = 0 },
  40. { .title = "Settings", .id = 4, .parent_id = 0 },
  41. { .title = "Sound", .id = 5, .parent_id = 3 },
  42. { .title = "Sound volume", .id = 6, .parent_id = 4 },
  43. { .title = "Sound type", .id = 7, .parent_id = 4 },
  44. { .title = "Button sound", .id = 8, .parent_id = 4 },
  45. { .title = "Back", .id = 9, .parent_id = 4 },
  46. { .title = "Alarm", .id = 10, .parent_id = 3 },
  47. { .title = "Alarm at dose rate", .id = 11, .parent_id = 9 },
  48. { .title = "Alarm at dose", .id = 12, .parent_id = 9 },
  49. { .title = "Alarm sound type", .id = 13, .parent_id = 9 },
  50. { .title = "Alarm volume", .id = 14, .parent_id = 9 },
  51. { .title = "Back", .id = 15, .parent_id = 9 },
  52. { .title = "Energy-saving", .id = 16, .parent_id = 3 },
  53. { .title = "Display auto-shutdown", .id = 17, .parent_id = 15 },
  54. { .title = "Device auto-shutdown", .id = 18, .parent_id = 15 },
  55. { .title = "Back", .id = 19, .parent_id = 15 },
  56. { .title = "Information", .id = 20, .parent_id = 0 }
  57. };
  58. menu_entry_td* GetMenuEntry(uint8_t id)
  59. {
  60. return &menu[id];
  61. }
  62. void MenuShow(uint8_t id)
  63. {
  64. int x = 0, y = 0;
  65. SSD1306_COLOR color = White;
  66. menu[1].selected = 1;
  67. for(int i = 0; i < (sizeof(menu) / sizeof(menu_entry_td)); i++)
  68. {
  69. if(menu[i].parent_id == 0)
  70. {
  71. ssd1306_SetCursor(x, y);
  72. (menu[i].selected) ? (color = Black) : (color = White);
  73. ssd1306_WriteString(menu[i].title, Font_7x10, color);
  74. y += 11;
  75. }
  76. }
  77. }