BME680.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. Unitemp - Universal temperature reader
  3. Copyright (C) 2022 Victor Nikitchuk (https://github.com/quen0n)
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef UNITEMP_BME680
  16. #define UNITEMP_BME680
  17. #include "../unitemp.h"
  18. #include "../Sensors.h"
  19. #include "../interfaces/I2CSensor.h"
  20. typedef struct {
  21. uint16_t dig_T1;
  22. int16_t dig_T2;
  23. int16_t dig_T3;
  24. } BME680_temp_cal;
  25. typedef struct {
  26. uint16_t dig_GH1;
  27. int16_t dig_GH2;
  28. int16_t dig_GH3;
  29. } BME680_gas_cal;
  30. typedef struct {
  31. uint16_t dig_P1;
  32. int16_t dig_P2;
  33. int16_t dig_P3;
  34. int16_t dig_P4;
  35. int16_t dig_P5;
  36. int16_t dig_P6;
  37. int16_t dig_P7;
  38. int16_t dig_P8;
  39. int16_t dig_P9;
  40. int16_t dig_P10;
  41. } BME680_press_cal;
  42. typedef struct {
  43. uint8_t dig_H1;
  44. int16_t dig_H2;
  45. uint8_t dig_H3;
  46. int16_t dig_H4;
  47. int16_t dig_H5;
  48. int8_t dig_H6;
  49. int8_t dig_H7;
  50. } BME680_hum_cal;
  51. typedef struct {
  52. //Калибровочные значения температуры
  53. BME680_temp_cal temp_cal;
  54. //Калибровочные значения давления
  55. BME680_press_cal press_cal;
  56. //Калибровочные значения влажности воздуха
  57. BME680_hum_cal hum_cal;
  58. BME680_gas_cal gas_cal;
  59. //Время последнего обновления калибровочных значений
  60. uint32_t last_cal_update_time;
  61. //Индификатор датчика
  62. uint8_t chip_id;
  63. //Корректировочное значение температуры
  64. int32_t t_fine;
  65. } BME680_instance;
  66. extern const SensorType BMP280;
  67. extern const SensorType BME680;
  68. /**
  69. * @brief Выделение памяти и установка начальных значений датчика BMP280
  70. * @param sensor Указатель на создаваемый датчик
  71. * @return Истина при успехе
  72. */
  73. bool unitemp_BME680_alloc(Sensor* sensor, char* args);
  74. /**
  75. * @brief Инициализации датчика BMP280
  76. * @param sensor Указатель на датчик
  77. * @return Истина если инициализация упспешная
  78. */
  79. bool unitemp_BME680_init(Sensor* sensor);
  80. /**
  81. * @brief Деинициализация датчика
  82. * @param sensor Указатель на датчик
  83. */
  84. bool unitemp_BME680_deinit(Sensor* sensor);
  85. /**
  86. * @brief Обновление значений из датчика
  87. * @param sensor Указатель на датчик
  88. * @return Статус опроса датчика
  89. */
  90. UnitempStatus unitemp_BME680_update(Sensor* sensor);
  91. /**
  92. * @brief Высвободить память датчика
  93. * @param sensor Указатель на датчик
  94. */
  95. bool unitemp_BME680_free(Sensor* sensor);
  96. #endif