settings.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include <avr/eeprom.h>
  3. #include "working_modes.h"
  4. /* u8 list - max 15 */
  5. #define CONF_U8_GNSS_MODE 0
  6. #define CONF_U8_LAST 0
  7. /* flags list - max 31 */
  8. #define CONFFLAG_DISABLE_FILTERS 0
  9. #define CONFFLAG_ENABLE_SBAS 1
  10. #define CONFFLAG_LAST 1
  11. /* GNSS modes */
  12. #define GNSS_MODE_GPS_GLONASS_GALILEO 0
  13. #define GNSS_MODE_GPS 1
  14. #define GNSS_MODE_GPS_GALILEO 2
  15. #define GNSS_MODE_GALILEO 3
  16. #define GNSS_MODE_GPS_BEIDOU 4
  17. #define GNSS_MODE_BEIDOU 5
  18. #define SETTINGS_TYPE_BACK 0
  19. #define SETTINGS_TYPE_BOOL 1
  20. #define SETTINGS_TYPE_U8 2
  21. #define HAVE_NEXT_SETTING_POSITION (mp.settings_menu_pos < SETTINGS_MENU_MAXPOS)
  22. #define HAVE_PREV_SETTING_POSITION (mp.settings_menu_pos > 0)
  23. #define SETTINGS_MENU_MAXPOS 3
  24. struct config_s {
  25. union {
  26. unsigned char conf_u8[16];
  27. struct {
  28. unsigned char gnss_mode; // 0
  29. };
  30. };
  31. unsigned char flags[4];
  32. };
  33. struct settings_menu_pos_s {
  34. unsigned char type;
  35. __flash const char *name;
  36. unsigned char index;
  37. void (* changed)(void);
  38. void (* display)(unsigned char);
  39. };
  40. extern const __flash unsigned char limits_max_u8[];
  41. extern __flash const struct settings_menu_pos_s settings_menu[SETTINGS_MENU_MAXPOS+1];
  42. extern __flash const char *gnss_names[];
  43. unsigned char settings_load(void); /* 0 - ok, 1 - error */
  44. void settings_store(void);
  45. unsigned char check_config_data(void); /* 0 - ok, 1 - error */
  46. void settings_display_and_modify_bool(unsigned char mindex, unsigned char k);
  47. void settings_display_and_modify_u8(unsigned char mindex, unsigned char k);
  48. unsigned char get_flag(unsigned char index);
  49. void set_flag(unsigned char index, unsigned char val);
  50. void settings_bool_disp_default(unsigned char val);