You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

2 years ago
  1. #ifndef WMM_H
  2. #define WMM_H
  3. #include <stdint.h>
  4. #define WMM_EPOCH 2020.0f
  5. typedef struct
  6. {
  7. float gnm;
  8. float hnm;
  9. float dgnm;
  10. float dhnm;
  11. } wmm_cof_record_t;
  12. /**
  13. * Initialize the WMM. Needs calling only once.
  14. */
  15. void wmm_init(void);
  16. /**
  17. * Get the date in WMM format
  18. *
  19. * @param year Year in 2 digit format of 21st centuary, i.e. 20 represents 2020
  20. * @param month Month, 1 to 12
  21. * @param date Date of month, 1 to 31
  22. * @return Date in WMM format
  23. * @note No checking of illegal dates is done
  24. */
  25. float wmm_get_date(uint8_t year, uint8_t month, uint8_t date);
  26. /**
  27. * Get the magnetic variation at a point on the earth's surface
  28. *
  29. * @param glat Latitude in degrees and fractional degrees, negative west
  30. * @param glon Longitude in degrees and fractional degrees, negative west
  31. * @param time_years The date as returned from wmm_get_date
  32. * @param dec Pointer to float holding calculated magnetic variation (also known as declination). Negative is west.
  33. * @note The altitude used is the ellipsoid at the supplied latitude/longitude, not the earth's surface. This will
  34. * give very small errors in some parts of the world comapred to sea level.
  35. */
  36. void E0000(float glat, float glon, float time_years, float *dec);
  37. #endif