unitemp.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. Unitemp - Universal temperature reader
  3. Copyright (C) 2022-2023 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
  16. #define UNITEMP
  17. /* Подключение стандартных библиотек */
  18. /* Подключение API Flipper Zero */
  19. //Файловый поток
  20. #include <toolbox/stream/file_stream.h>
  21. //Экран
  22. #include <gui/gui.h>
  23. #include <gui/view_dispatcher.h>
  24. #include <gui/modules/widget.h>
  25. #include <gui/modules/popup.h>
  26. //Уведомления
  27. #include <notification/notification.h>
  28. #include <notification/notification_messages.h>
  29. /* Внутренние библиотеки */
  30. //Интерфейсы подключения датчиков
  31. #include "Sensors.h"
  32. /* Объявление макроподстановок */
  33. //Имя приложения
  34. #define APP_NAME "Unitemp"
  35. //Версия приложения
  36. #define UNITEMP_APP_VER "1.6"
  37. //Путь хранения файлов плагина
  38. #define APP_PATH_FOLDER EXT_PATH("apps_data/unitemp")
  39. //Имя файла с настройками
  40. #define APP_FILENAME_SETTINGS "settings.cfg"
  41. //Имя файла с датчиками
  42. #define APP_FILENAME_SENSORS "sensors.cfg"
  43. //Размер буффера текста
  44. #define BUFF_SIZE 32
  45. #define UNITEMP_D
  46. #ifdef FURI_DEBUG
  47. #define UNITEMP_DEBUG(msg, ...) FURI_LOG_D(APP_NAME, msg, ##__VA_ARGS__)
  48. #else
  49. #define UNITEMP_DEBUG(msg, ...)
  50. #endif
  51. /* Объявление перечислений */
  52. //Единицы измерения температуры
  53. typedef enum {
  54. UT_TEMP_CELSIUS,
  55. UT_TEMP_FAHRENHEIT,
  56. UT_TEMP_COUNT
  57. } tempMeasureUnit;
  58. //Единицы измерения давления
  59. typedef enum {
  60. UT_PRESSURE_MM_HG,
  61. UT_PRESSURE_IN_HG,
  62. UT_PRESSURE_KPA,
  63. UT_PRESSURE_HPA,
  64. UT_PRESSURE_COUNT
  65. } pressureMeasureUnit;
  66. /* Объявление структур */
  67. //Настройки плагина
  68. typedef struct {
  69. //Бесконечная работа подсветки
  70. bool infinityBacklight;
  71. //Единица измерения температуры
  72. tempMeasureUnit temp_unit;
  73. //Единица измерения давления
  74. pressureMeasureUnit pressure_unit;
  75. // Do calculate and show heat index
  76. bool heat_index;
  77. //Последнее состояние OTG
  78. bool lastOTGState;
  79. } UnitempSettings;
  80. //Основная структура плагина
  81. typedef struct {
  82. //Система
  83. bool sensors_ready; //Флаг готовности датчиков к опросу
  84. bool sensors_update; // Флаг допустимости опроса датчиков
  85. //Основные настройки
  86. UnitempSettings settings;
  87. //Массив указателей на датчики
  88. Sensor** sensors;
  89. //Количество загруженных датчиков
  90. uint8_t sensors_count;
  91. //SD-карта
  92. Storage* storage; //Хранилище
  93. Stream* file_stream; //Файловый поток
  94. //Экран
  95. Gui* gui;
  96. ViewDispatcher* view_dispatcher;
  97. NotificationApp* notifications;
  98. Widget* widget;
  99. Popup* popup;
  100. //Буффер для различного текста
  101. char* buff;
  102. } Unitemp;
  103. /* Объявление прототипов функций */
  104. /**
  105. * @brief Calculates the heat index in Celsius from the temperature and humidity and stores it in the sensor heat_index field
  106. *
  107. * @param sensor The sensor struct, with temperature in Celcius and humidity in percent
  108. */
  109. void unitemp_calculate_heat_index(Sensor* sensor);
  110. /**
  111. * @brief Перевод значения температуры датчика из Цельсия в Фаренгейты
  112. *
  113. * @param sensor Указатель на датчик
  114. */
  115. void uintemp_celsiumToFarengate(Sensor* sensor);
  116. /**
  117. * @brief Конвертация давления из паскалей в мм рт.ст.
  118. *
  119. * @param sensor Указатель на датчик
  120. */
  121. void unitemp_pascalToMmHg(Sensor* sensor);
  122. /**
  123. * @brief Конвертация давления из паскалей в килопаскали
  124. *
  125. * @param sensor Указатель на датчик
  126. */
  127. void unitemp_pascalToKPa(Sensor* sensor);
  128. /**
  129. * @brief Конвертация давления из паскалей в дюйм рт.ст.
  130. *
  131. * @param sensor Указатель на датчик
  132. */
  133. void unitemp_pascalToHPa(Sensor* sensor);
  134. /**
  135. *
  136. * Mod BySepa - linktr.ee/BySepa
  137. *
  138. */
  139. void unitemp_pascalToInHg(Sensor* sensor);
  140. /**
  141. * @brief Сохранение настроек на SD-карту
  142. *
  143. * @return Истина если сохранение успешное
  144. */
  145. bool unitemp_saveSettings(void);
  146. /**
  147. * @brief Загрузка настроек с SD-карты
  148. *
  149. * @return Истина если загрузка успешная
  150. */
  151. bool unitemp_loadSettings(void);
  152. extern Unitemp* app;
  153. #endif