settings.h 1.7 KB

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