Victor пре 3 година
родитељ
комит
3d0f3615cd
6 измењених фајлова са 160 додато и 3 уклоњено
  1. 9 2
      README.md
  2. 2 1
      Sensors.c
  3. 1 0
      Sensors.h
  4. 83 0
      sensors/MAX6675.c
  5. 65 0
      sensors/MAX6675.h
  6. BIN
      sensors/Sensors.xlsx

+ 9 - 2
README.md

@@ -5,13 +5,20 @@
 [![Build dev](https://github.com/quen0n/unitemp-flipperzero/actions/workflows/build_dev.yml/badge.svg?branch=dev)](https://github.com/quen0n/unitemp-flipperzero/actions/workflows/build_dev.yml)  
 [![Build dev](https://github.com/quen0n/unitemp-flipperzero/actions/workflows/build_dev.yml/badge.svg?branch=dev)](https://github.com/quen0n/unitemp-flipperzero/actions/workflows/build_dev.yml)  
 [Flipper Zero](https://flipperzero.one/) application for reading temperature, humidity and pressure sensors like a DHT11/22, DS18B20, BMP280, HTU21 and more. 
 [Flipper Zero](https://flipperzero.one/) application for reading temperature, humidity and pressure sensors like a DHT11/22, DS18B20, BMP280, HTU21 and more. 
 ## List of supported sensors (supplemented)
 ## List of supported sensors (supplemented)
-![image](https://user-images.githubusercontent.com/10090793/211131502-c1560eb5-f59c-4cfa-86f7-27f037490a35.png)
+![image](https://user-images.githubusercontent.com/10090793/215224104-1f39dcb5-f732-4632-a49a-d9a0e72bcc04.png)
+
 ## Installation
 ## Installation
 1) Download [latest version](https://cloud.quenon.ru/index.php/s/h98rT9UnaOL4wxR/download?path=%2F&files=unitemp-latest.fap)
 1) Download [latest version](https://cloud.quenon.ru/index.php/s/h98rT9UnaOL4wxR/download?path=%2F&files=unitemp-latest.fap)
 2) Copy `unitemp-latest.fap` to `SD card/apps/GPIO` with qFlipper or mobile application
 2) Copy `unitemp-latest.fap` to `SD card/apps/GPIO` with qFlipper or mobile application
 3) Open application on your Flipper: `Applications->GPIO->Temp sensors reader`  
 3) Open application on your Flipper: `Applications->GPIO->Temp sensors reader`  
-Note: If you get the message "API version mismatch" after updating the firmware, download and install Unitemp again 
+Note: If you get the message "API version mismatch" after updating the firmware, download and install Unitemp again
+## Need help? Discussions?
+Join the discussion, ask a question or just send a photo of the flipper with sensors to [Discord](https://discord.com/channels/740930220399525928/1056727938747351060)
+## Gratitudes
+Thanks to [@Svaarich](https://github.com/Svaarich) for the UI design and to the Unleashed firmware community for sensors testing and feedbacks.
+
 ## Some community photos
 ## Some community photos
 ![image](https://user-images.githubusercontent.com/10090793/210120132-7ddbc937-0a6b-4472-bd1c-7fbc3ecdf2ad.png)
 ![image](https://user-images.githubusercontent.com/10090793/210120132-7ddbc937-0a6b-4472-bd1c-7fbc3ecdf2ad.png)
 ![image](https://user-images.githubusercontent.com/10090793/210120135-12fc5810-77ff-49db-b799-e9479e1f57a7.png)
 ![image](https://user-images.githubusercontent.com/10090793/210120135-12fc5810-77ff-49db-b799-e9479e1f57a7.png)
 ![image](https://user-images.githubusercontent.com/10090793/210120143-a2bae3ce-4190-421f-8c4f-c7c744903bd6.png)
 ![image](https://user-images.githubusercontent.com/10090793/210120143-a2bae3ce-4190-421f-8c4f-c7c744903bd6.png)
+![image](https://user-images.githubusercontent.com/10090793/215224085-8099408e-b3de-4a0c-854e-fe4e4faa8ea3.png)

+ 2 - 1
Sensors.c

@@ -93,7 +93,8 @@ static const SensorType* sensorTypes[] = {
     &BMP180,
     &BMP180,
     &BMP280,
     &BMP280,
     &BME280,
     &BME280,
-    &MAX31855};
+    &MAX31855,
+    &MAX6675};
 
 
 const SensorType* unitemp_sensors_getTypeFromInt(uint8_t index) {
 const SensorType* unitemp_sensors_getTypeFromInt(uint8_t index) {
     if(index > SENSOR_TYPES_COUNT) return NULL;
     if(index > SENSOR_TYPES_COUNT) return NULL;

+ 1 - 0
Sensors.h

@@ -327,4 +327,5 @@ const GPIO*
 #include "./sensors/HTU21x.h"
 #include "./sensors/HTU21x.h"
 #include "./sensors/HDC1080.h"
 #include "./sensors/HDC1080.h"
 #include "./sensors/MAX31855.h"
 #include "./sensors/MAX31855.h"
+#include "./sensors/MAX6675.h"
 #endif
 #endif

+ 83 - 0
sensors/MAX6675.c

@@ -0,0 +1,83 @@
+/*
+    Unitemp - Universal temperature reader
+    Copyright (C) 2022-2023  Victor Nikitchuk (https://github.com/quen0n)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
+*/
+#include "MAX6675.h"
+
+const SensorType MAX6675 = {
+    .typename = "MAX6675",
+    .altname = "MAX6675 (Thermocouple)",
+    .interface = &SPI,
+    .datatype = UT_TEMPERATURE,
+    .pollingInterval = 500,
+    .allocator = unitemp_MAX6675_alloc,
+    .mem_releaser = unitemp_MAX6675_free,
+    .initializer = unitemp_MAX6675_init,
+    .deinitializer = unitemp_MAX6675_deinit,
+    .updater = unitemp_MAX6675_update};
+
+bool unitemp_MAX6675_alloc(Sensor* sensor, char* args) {
+    UNUSED(sensor);
+    UNUSED(args);
+    return true;
+}
+
+bool unitemp_MAX6675_free(Sensor* sensor) {
+    UNUSED(sensor);
+    return true;
+}
+
+bool unitemp_MAX6675_init(Sensor* sensor) {
+    SPISensor* instance = sensor->instance;
+    furi_hal_spi_bus_handle_init(instance->spi);
+    UNUSED(instance);
+    return true;
+}
+
+bool unitemp_MAX6675_deinit(Sensor* sensor) {
+    UNUSED(sensor);
+    return true;
+}
+
+UnitempStatus unitemp_MAX6675_update(Sensor* sensor) {
+    SPISensor* instance = sensor->instance;
+
+    furi_hal_spi_acquire(instance->spi);
+    furi_hal_gpio_write(instance->CS_pin->pin, false);
+
+    uint8_t buff[2] = {0};
+
+    furi_hal_spi_bus_rx(instance->spi, buff, 2, 0xFF);
+    furi_hal_spi_release(instance->spi);
+
+    uint32_t raw = (buff[0] << 8) | buff[1];
+
+    if(raw == 0xFFFFFFFF || raw == 0) return UT_SENSORSTATUS_TIMEOUT;
+
+    //Определение состояния термопары
+    uint8_t state = raw & 0b100;
+    //Обрыв
+    if(state == 0b100) {
+        UNITEMP_DEBUG("%s has thermocouple open circuit", sensor->name);
+        return UT_SENSORSTATUS_ERROR;
+    }
+
+    sensor->temp = (int16_t)(raw) / 32.0f;
+
+    UNITEMP_DEBUG("RAW: %04lX", raw);
+
+    return UT_SENSORSTATUS_OK;
+}

+ 65 - 0
sensors/MAX6675.h

@@ -0,0 +1,65 @@
+/*
+    Unitemp - Universal temperature reader
+    Copyright (C) 2022-2023  Victor Nikitchuk (https://github.com/quen0n)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
+*/
+#ifndef UNITEMP_MAX6675
+#define UNITEMP_MAX6675
+
+#include "../unitemp.h"
+#include "../Sensors.h"
+#include "../interfaces/SPISensor.h"
+
+extern const SensorType MAX6675;
+
+/**
+ * @brief Выделение памяти и установка начальных значений датчика MAX6675
+ *
+ * @param sensor Указатель на создаваемый датчик
+ * @return Истина при успехе
+ */
+bool unitemp_MAX6675_alloc(Sensor* sensor, char* args);
+
+/**
+ * @brief Инициализации датчика MAX6675
+ *
+ * @param sensor Указатель на датчик
+ * @return Истина если инициализация упспешная
+ */
+bool unitemp_MAX6675_init(Sensor* sensor);
+
+/**
+ * @brief Деинициализация датчика
+ *
+ * @param sensor Указатель на датчик
+ */
+bool unitemp_MAX6675_deinit(Sensor* sensor);
+
+/**
+ * @brief Обновление значений из датчика
+ *
+ * @param sensor Указатель на датчик
+ * @return Статус обновления
+ */
+UnitempStatus unitemp_MAX6675_update(Sensor* sensor);
+
+/**
+ * @brief Высвободить память датчика
+ *
+ * @param sensor Указатель на датчик
+ */
+bool unitemp_MAX6675_free(Sensor* sensor);
+
+#endif

BIN
sensors/Sensors.xlsx