settings.h 1.7 KB

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