BME680.h 3.3 KB

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