mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 13:03:13 +00:00
Update unitemp
This commit is contained in:
parent
71daa3e0f8
commit
ee41413c6a
10 changed files with 66 additions and 150 deletions
|
@ -2,11 +2,13 @@
|
||||||
* If you have copied apps into `apps` folder - remove `apps` folder on your microSD before installing this release to avoid issues!
|
* If you have copied apps into `apps` folder - remove `apps` folder on your microSD before installing this release to avoid issues!
|
||||||
* SubGHz: Default custom buttons layout for non standard remotes (for example your remote has broken buttons and transmit only 0xC, now you can use other buttons)
|
* SubGHz: Default custom buttons layout for non standard remotes (for example your remote has broken buttons and transmit only 0xC, now you can use other buttons)
|
||||||
* SubGHz: Fix issues with external module 5v power (now all works automatically, enabling +5v manually not required) (**Only for modules that work with 5v->3.3v converter!!!!!**)
|
* SubGHz: Fix issues with external module 5v power (now all works automatically, enabling +5v manually not required) (**Only for modules that work with 5v->3.3v converter!!!!!**)
|
||||||
|
* SubGHz: Option to disable automatic 5v power for external modules - (5v is enabled by default, if you are using module without converter you can set this option to OFF)
|
||||||
* SubGHz: Fix and update subghz protocols to use new error system
|
* SubGHz: Fix and update subghz protocols to use new error system
|
||||||
* SubGHz: Fix default frequency being overwritten bug (Add manually fixes)
|
* SubGHz: Fix default frequency being overwritten bug (Add manually fixes)
|
||||||
* SubGHz: Fix 464Mhz and (390MHz for external module only) was showing up in Frequency analyzer all the time due to noise
|
* SubGHz: Fix 464Mhz and (390MHz for external module only) was showing up in Frequency analyzer all the time due to noise
|
||||||
* iButton: Fix ibutton app - add manually - duplicate names
|
* iButton: Fix ibutton app - add manually - duplicate names
|
||||||
* Plugins: NFC Magic fix - reinit nfc at app start
|
* Plugins: NFC Magic fix - reinit nfc at app start
|
||||||
|
* Plugins: Update **Unitemp - Temperature sensors reader** (DHT11/22, DS18B20, BMP280, HTU21x and more) [(by quen0n)](https://github.com/quen0n/unitemp-flipperzero)
|
||||||
* Plugins: Update **SWD Probe** [(by g3gg0)](https://github.com/g3gg0/flipper-swd_probe)
|
* Plugins: Update **SWD Probe** [(by g3gg0)](https://github.com/g3gg0/flipper-swd_probe)
|
||||||
* Plugins: Massive plugins refactoring - not full refactoring, only small issues is fixed and moved all plugins to furi mutex instead of valuemutex
|
* Plugins: Massive plugins refactoring - not full refactoring, only small issues is fixed and moved all plugins to furi mutex instead of valuemutex
|
||||||
* Plugins: Many small issues was found and fixed due mutex upgrade
|
* Plugins: Many small issues was found and fixed due mutex upgrade
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
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?
|
## 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)
|
Join the discussion, ask a question or just send a photo of the flipper with sensors to [Discord](https://discord.com/channels/740930220399525928/1056727938747351060). [Invite link](https://discord.com/invite/flipper)
|
||||||
## Gratitudes
|
## Gratitudes
|
||||||
Thanks to [@Svaarich](https://github.com/Svaarich) for the UI design and to the Unleashed firmware community for sensors testing and feedbacks.
|
Thanks to [@Svaarich](https://github.com/Svaarich) for the UI design and to the Unleashed firmware community for sensors testing and feedbacks.
|
||||||
|
|
||||||
|
@ -21,4 +21,4 @@ Thanks to [@Svaarich](https://github.com/Svaarich) for the UI design and to the
|
||||||
![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)
|
![image](https://user-images.githubusercontent.com/10090793/215224085-8099408e-b3de-4a0c-854e-fe4e4faa8ea3.png)
|
||||||
|
|
|
@ -149,8 +149,7 @@ uint8_t unitemp_gpio_getAviablePortsCount(const Interface* interface, const GPIO
|
||||||
for(uint8_t i = 0; i < GPIO_ITEMS; i++) {
|
for(uint8_t i = 0; i < GPIO_ITEMS; i++) {
|
||||||
//Проверка для one wire
|
//Проверка для one wire
|
||||||
if(interface == &ONE_WIRE) {
|
if(interface == &ONE_WIRE) {
|
||||||
if(((gpio_interfaces_list[i] == NULL || gpio_interfaces_list[i] == &ONE_WIRE) &&
|
if(((gpio_interfaces_list[i] == NULL || gpio_interfaces_list[i] == &ONE_WIRE)) ||
|
||||||
(i != 12)) || //Почему-то не работает на 17 порте
|
|
||||||
(unitemp_gpio_getFromIndex(i) == extraport)) {
|
(unitemp_gpio_getFromIndex(i) == extraport)) {
|
||||||
aviable_ports_count++;
|
aviable_ports_count++;
|
||||||
}
|
}
|
||||||
|
@ -208,9 +207,7 @@ const GPIO*
|
||||||
for(uint8_t i = 0; i < GPIO_ITEMS; i++) {
|
for(uint8_t i = 0; i < GPIO_ITEMS; i++) {
|
||||||
//Проверка для one wire
|
//Проверка для one wire
|
||||||
if(interface == &ONE_WIRE) {
|
if(interface == &ONE_WIRE) {
|
||||||
//Почему-то не работает на 17 порте
|
if(((gpio_interfaces_list[i] == NULL || gpio_interfaces_list[i] == &ONE_WIRE)) ||
|
||||||
if(((gpio_interfaces_list[i] == NULL || gpio_interfaces_list[i] == &ONE_WIRE) &&
|
|
||||||
(i != 12)) || //Почему-то не работает на 17 порте
|
|
||||||
(unitemp_gpio_getFromIndex(i) == extraport)) {
|
(unitemp_gpio_getFromIndex(i) == extraport)) {
|
||||||
if(aviable_index == index) {
|
if(aviable_index == index) {
|
||||||
return unitemp_gpio_getFromIndex(i);
|
return unitemp_gpio_getFromIndex(i);
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "OneWireSensor.h"
|
#include "OneWireSensor.h"
|
||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <furi_hal.h>
|
#include <furi_hal.h>
|
||||||
#include <one_wire/one_wire_host.h>
|
|
||||||
|
|
||||||
const SensorType Dallas = {
|
const SensorType Dallas = {
|
||||||
.typename = "Dallas",
|
.typename = "Dallas",
|
||||||
|
@ -37,8 +36,6 @@ const SensorType Dallas = {
|
||||||
// Переменные для хранения промежуточного результата сканирования шины
|
// Переменные для хранения промежуточного результата сканирования шины
|
||||||
// найденный восьмибайтовый адрес
|
// найденный восьмибайтовый адрес
|
||||||
static uint8_t onewire_enum[8] = {0};
|
static uint8_t onewire_enum[8] = {0};
|
||||||
// последний нулевой бит, где была неоднозначность (нумеруя с единицы)
|
|
||||||
static uint8_t onewire_enum_fork_bit = 65;
|
|
||||||
|
|
||||||
OneWireBus* uintemp_onewire_bus_alloc(const GPIO* gpio) {
|
OneWireBus* uintemp_onewire_bus_alloc(const GPIO* gpio) {
|
||||||
if(gpio == NULL) {
|
if(gpio == NULL) {
|
||||||
|
@ -55,9 +52,11 @@ OneWireBus* uintemp_onewire_bus_alloc(const GPIO* gpio) {
|
||||||
}
|
}
|
||||||
|
|
||||||
OneWireBus* bus = malloc(sizeof(OneWireBus));
|
OneWireBus* bus = malloc(sizeof(OneWireBus));
|
||||||
|
|
||||||
bus->device_count = 0;
|
bus->device_count = 0;
|
||||||
bus->gpio = gpio;
|
bus->gpio = gpio;
|
||||||
bus->powerMode = PWR_PASSIVE;
|
bus->powerMode = PWR_PASSIVE;
|
||||||
|
|
||||||
UNITEMP_DEBUG("one wire bus (port %d) allocated", gpio->num);
|
UNITEMP_DEBUG("one wire bus (port %d) allocated", gpio->num);
|
||||||
|
|
||||||
return bus;
|
return bus;
|
||||||
|
@ -69,6 +68,8 @@ bool unitemp_onewire_bus_init(OneWireBus* bus) {
|
||||||
//Выход если шина уже была инициализирована
|
//Выход если шина уже была инициализирована
|
||||||
if(bus->device_count > 1) return true;
|
if(bus->device_count > 1) return true;
|
||||||
|
|
||||||
|
bus->host = onewire_host_alloc(bus->gpio->pin);
|
||||||
|
|
||||||
unitemp_gpio_lock(bus->gpio, &ONE_WIRE);
|
unitemp_gpio_lock(bus->gpio, &ONE_WIRE);
|
||||||
//Высокий уровень по умолчанию
|
//Высокий уровень по умолчанию
|
||||||
furi_hal_gpio_write(bus->gpio->pin, true);
|
furi_hal_gpio_write(bus->gpio->pin, true);
|
||||||
|
@ -81,6 +82,7 @@ bool unitemp_onewire_bus_init(OneWireBus* bus) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool unitemp_onewire_bus_deinit(OneWireBus* bus) {
|
bool unitemp_onewire_bus_deinit(OneWireBus* bus) {
|
||||||
UNITEMP_DEBUG("devices on wire %d: %d", bus->gpio->num, bus->device_count);
|
UNITEMP_DEBUG("devices on wire %d: %d", bus->gpio->num, bus->device_count);
|
||||||
bus->device_count--;
|
bus->device_count--;
|
||||||
|
@ -100,84 +102,34 @@ bool unitemp_onewire_bus_deinit(OneWireBus* bus) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool unitemp_onewire_bus_start(OneWireBus* bus) {
|
inline bool unitemp_onewire_bus_start(OneWireBus* bus) {
|
||||||
furi_hal_gpio_write(bus->gpio->pin, false);
|
return onewire_host_reset(bus->host);
|
||||||
furi_delay_us(500);
|
|
||||||
|
|
||||||
furi_hal_gpio_write(bus->gpio->pin, true);
|
|
||||||
|
|
||||||
//Ожидание подъёма шины
|
|
||||||
uint32_t t = furi_get_tick();
|
|
||||||
while(!furi_hal_gpio_read(bus->gpio->pin)) {
|
|
||||||
//Выход если шина не поднялась
|
|
||||||
if(furi_get_tick() - t > 10) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
furi_delay_us(100);
|
|
||||||
bool status = !furi_hal_gpio_read(bus->gpio->pin);
|
|
||||||
furi_delay_us(400);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unitemp_onewire_bus_send_bit(OneWireBus* bus, bool state) {
|
inline void unitemp_onewire_bus_send_bit(OneWireBus* bus, bool state) {
|
||||||
//Необходимо для стабильной работы при пассивном питании
|
onewire_host_write_bit(bus->host, state);
|
||||||
if(bus->powerMode == PWR_PASSIVE) furi_delay_us(100);
|
|
||||||
|
|
||||||
if(state) {
|
|
||||||
// write 1
|
|
||||||
furi_hal_gpio_write(bus->gpio->pin, false);
|
|
||||||
furi_delay_us(1);
|
|
||||||
furi_hal_gpio_write(bus->gpio->pin, true);
|
|
||||||
furi_delay_us(90);
|
|
||||||
} else {
|
|
||||||
furi_hal_gpio_write(bus->gpio->pin, false);
|
|
||||||
furi_delay_us(90);
|
|
||||||
furi_hal_gpio_write(bus->gpio->pin, true);
|
|
||||||
//Ожидание подъёма шины
|
|
||||||
uint32_t t = furi_get_tick();
|
|
||||||
while(!furi_hal_gpio_read(bus->gpio->pin)) {
|
|
||||||
//Выход если шина не поднялась
|
|
||||||
if(furi_get_tick() - t > 10) return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unitemp_onewire_bus_send_byte(OneWireBus* bus, uint8_t data) {
|
inline void unitemp_onewire_bus_send_byte(OneWireBus* bus, uint8_t data) {
|
||||||
for(int i = 0; i < 8; i++) {
|
onewire_host_write(bus->host, data);
|
||||||
unitemp_onewire_bus_send_bit(bus, (data & (1 << i)) != 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unitemp_onewire_bus_send_byteArray(OneWireBus* bus, uint8_t* data, uint8_t len) {
|
void unitemp_onewire_bus_send_byteArray(OneWireBus* bus, uint8_t* data, uint8_t len) {
|
||||||
for(uint8_t i = 0; i < len; i++) {
|
for(uint8_t i = 0; i < len; i++) {
|
||||||
unitemp_onewire_bus_send_byte(bus, data[i]);
|
onewire_host_write(bus->host, data[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool unitemp_onewire_bus_read_bit(OneWireBus* bus) {
|
inline bool unitemp_onewire_bus_read_bit(OneWireBus* bus) {
|
||||||
furi_delay_ms(1);
|
return onewire_host_read_bit(bus->host);
|
||||||
furi_hal_gpio_write(bus->gpio->pin, false);
|
|
||||||
furi_delay_us(2); // Длительность низкого уровня, минимум 1 мкс
|
|
||||||
furi_hal_gpio_write(bus->gpio->pin, true);
|
|
||||||
furi_delay_us(8); // Пауза до момента сэмплирования, всего не более 15 мкс
|
|
||||||
bool r = furi_hal_gpio_read(bus->gpio->pin);
|
|
||||||
furi_delay_us(80); // Ожидание до следующего тайм-слота, минимум 60 мкс с начала низкого уровня
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t unitemp_onewire_bus_read_byte(OneWireBus* bus) {
|
inline uint8_t unitemp_onewire_bus_read_byte(OneWireBus* bus) {
|
||||||
uint8_t r = 0;
|
return onewire_host_read(bus->host);
|
||||||
for(uint8_t p = 8; p; p--) {
|
|
||||||
r >>= 1;
|
|
||||||
if(unitemp_onewire_bus_read_bit(bus)) r |= 0x80;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unitemp_onewire_bus_read_byteArray(OneWireBus* bus, uint8_t* data, uint8_t len) {
|
void unitemp_onewire_bus_read_byteArray(OneWireBus* bus, uint8_t* data, uint8_t len) {
|
||||||
for(uint8_t i = 0; i < len; i++) {
|
onewire_host_read_bytes(bus->host, data, len);
|
||||||
data[i] = unitemp_onewire_bus_read_byte(bus);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t onewire_CRC_update(uint8_t crc, uint8_t b) {
|
static uint8_t onewire_CRC_update(uint8_t crc, uint8_t b) {
|
||||||
|
@ -222,77 +174,16 @@ bool unitemp_onewire_sensor_readID(OneWireSensor* instance) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unitemp_onewire_bus_enum_init(void) {
|
void unitemp_onewire_bus_enum_init(OneWireBus* bus) {
|
||||||
for(uint8_t p = 0; p < 8; p++) {
|
onewire_host_reset_search(bus->host);
|
||||||
onewire_enum[p] = 0;
|
|
||||||
}
|
|
||||||
onewire_enum_fork_bit = 65; // правее правого
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* unitemp_onewire_bus_enum_next(OneWireBus* bus) {
|
uint8_t* unitemp_onewire_bus_enum_next(OneWireBus* bus) {
|
||||||
furi_delay_ms(10);
|
if(onewire_host_search(bus->host, onewire_enum, NORMAL_SEARCH)) {
|
||||||
if(!onewire_enum_fork_bit) { // Если на предыдущем шаге уже не было разногласий
|
return onewire_enum;
|
||||||
UNITEMP_DEBUG("All devices on wire %d is found", unitemp_gpio_toInt(bus->gpio));
|
} else {
|
||||||
return 0; // то просто выходим ничего не возвращая
|
return NULL;
|
||||||
}
|
}
|
||||||
if(!unitemp_onewire_bus_start(bus)) {
|
|
||||||
UNITEMP_DEBUG("Wire %d is empty", unitemp_gpio_toInt(bus->gpio));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
uint8_t bp = 8;
|
|
||||||
uint8_t* pprev = &onewire_enum[0];
|
|
||||||
uint8_t prev = *pprev;
|
|
||||||
uint8_t next = 0;
|
|
||||||
|
|
||||||
uint8_t p = 1;
|
|
||||||
unitemp_onewire_bus_send_byte(bus, 0xF0);
|
|
||||||
uint8_t newfork = 0;
|
|
||||||
for(;;) {
|
|
||||||
uint8_t not0 = unitemp_onewire_bus_read_bit(bus);
|
|
||||||
uint8_t not1 = unitemp_onewire_bus_read_bit(bus);
|
|
||||||
if(!not0) { // Если присутствует в адресах бит ноль
|
|
||||||
if(!not1) { // Но также присустствует бит 1 (вилка)
|
|
||||||
if(p <
|
|
||||||
onewire_enum_fork_bit) { // Если мы левее прошлого правого конфликтного бита,
|
|
||||||
if(prev & 1) {
|
|
||||||
next |= 0x80; // то копируем значение бита из прошлого прохода
|
|
||||||
} else {
|
|
||||||
newfork = p; // если ноль, то запомним конфликтное место
|
|
||||||
}
|
|
||||||
} else if(p == onewire_enum_fork_bit) {
|
|
||||||
next |=
|
|
||||||
0x80; // если на этом месте в прошлый раз был правый конфликт с нулём, выведем 1
|
|
||||||
} else {
|
|
||||||
newfork = p; // правее - передаём ноль и запоминаем конфликтное место
|
|
||||||
}
|
|
||||||
} // в противном случае идём, выбирая ноль в адресе
|
|
||||||
} else {
|
|
||||||
if(!not1) { // Присутствует единица
|
|
||||||
next |= 0x80;
|
|
||||||
} else { // Нет ни нулей ни единиц - ошибочная ситуация
|
|
||||||
|
|
||||||
UNITEMP_DEBUG("Wrong wire %d situation", unitemp_gpio_toInt(bus->gpio));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unitemp_onewire_bus_send_bit(bus, next & 0x80);
|
|
||||||
bp--;
|
|
||||||
if(!bp) {
|
|
||||||
*pprev = next;
|
|
||||||
if(p >= 64) break;
|
|
||||||
next = 0;
|
|
||||||
pprev++;
|
|
||||||
prev = *pprev;
|
|
||||||
bp = 8;
|
|
||||||
} else {
|
|
||||||
if(p >= 64) break;
|
|
||||||
prev >>= 1;
|
|
||||||
next >>= 1;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
onewire_enum_fork_bit = newfork;
|
|
||||||
return &onewire_enum[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unitemp_onewire_bus_select_sensor(OneWireSensor* instance) {
|
void unitemp_onewire_bus_select_sensor(OneWireSensor* instance) {
|
||||||
|
@ -364,7 +255,6 @@ bool unitemp_onewire_sensor_init(Sensor* sensor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unitemp_onewire_bus_init(instance->bus);
|
unitemp_onewire_bus_init(instance->bus);
|
||||||
furi_delay_ms(1);
|
|
||||||
|
|
||||||
if(instance->familyCode == FC_DS18B20 || instance->familyCode == FC_DS1822) {
|
if(instance->familyCode == FC_DS18B20 || instance->familyCode == FC_DS1822) {
|
||||||
//Установка разрядности в 10 бит
|
//Установка разрядности в 10 бит
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#define UNITEMP_OneWire
|
#define UNITEMP_OneWire
|
||||||
|
|
||||||
#include "../unitemp.h"
|
#include "../unitemp.h"
|
||||||
|
#include <one_wire/one_wire_host.h>
|
||||||
|
|
||||||
//Коды семейства устройств
|
//Коды семейства устройств
|
||||||
typedef enum DallasFamilyCode {
|
typedef enum DallasFamilyCode {
|
||||||
|
@ -42,6 +43,8 @@ typedef struct {
|
||||||
int8_t device_count;
|
int8_t device_count;
|
||||||
//Режим питания датчиков на шине
|
//Режим питания датчиков на шине
|
||||||
PowerMode powerMode;
|
PowerMode powerMode;
|
||||||
|
|
||||||
|
OneWireHost* host;
|
||||||
} OneWireBus;
|
} OneWireBus;
|
||||||
|
|
||||||
//Инстанс датчика one wire
|
//Инстанс датчика one wire
|
||||||
|
@ -155,7 +158,7 @@ bool unitemp_onewire_bus_read_bit(OneWireBus* bus);
|
||||||
*
|
*
|
||||||
* @param bus Указатель на шину one wire
|
* @param bus Указатель на шину one wire
|
||||||
* @return Байт информации
|
* @return Байт информации
|
||||||
*/
|
**/
|
||||||
uint8_t unitemp_onewire_bus_read_byte(OneWireBus* bus);
|
uint8_t unitemp_onewire_bus_read_byte(OneWireBus* bus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,7 +204,7 @@ void unitemp_onewire_bus_select_sensor(OneWireSensor* instance);
|
||||||
/**
|
/**
|
||||||
* @brief Инициализация процесса поиска адресов на шине one wire
|
* @brief Инициализация процесса поиска адресов на шине one wire
|
||||||
*/
|
*/
|
||||||
void unitemp_onewire_bus_enum_init(void);
|
void unitemp_onewire_bus_enum_init(OneWireBus* bus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Перечисляет устройства на шине one wire и получает очередной адрес
|
* @brief Перечисляет устройства на шине one wire и получает очередной адрес
|
||||||
|
|
|
@ -36,6 +36,9 @@ void unitemp_pascalToMmHg(Sensor* sensor) {
|
||||||
void unitemp_pascalToKPa(Sensor* sensor) {
|
void unitemp_pascalToKPa(Sensor* sensor) {
|
||||||
sensor->pressure = sensor->pressure / 1000.0f;
|
sensor->pressure = sensor->pressure / 1000.0f;
|
||||||
}
|
}
|
||||||
|
void unitemp_pascalToHPa(Sensor* sensor) {
|
||||||
|
sensor->pressure = sensor->pressure / 100.0f;
|
||||||
|
}
|
||||||
void unitemp_pascalToInHg(Sensor* sensor) {
|
void unitemp_pascalToInHg(Sensor* sensor) {
|
||||||
sensor->pressure = sensor->pressure * 0.0002953007;
|
sensor->pressure = sensor->pressure * 0.0002953007;
|
||||||
}
|
}
|
||||||
|
@ -306,4 +309,4 @@ int32_t unitemp_app() {
|
||||||
unitemp_free();
|
unitemp_free();
|
||||||
//Выход
|
//Выход
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ typedef enum {
|
||||||
UT_PRESSURE_MM_HG,
|
UT_PRESSURE_MM_HG,
|
||||||
UT_PRESSURE_IN_HG,
|
UT_PRESSURE_IN_HG,
|
||||||
UT_PRESSURE_KPA,
|
UT_PRESSURE_KPA,
|
||||||
|
UT_PRESSURE_HPA,
|
||||||
|
|
||||||
UT_PRESSURE_COUNT
|
UT_PRESSURE_COUNT
|
||||||
} pressureMeasureUnit;
|
} pressureMeasureUnit;
|
||||||
|
@ -135,6 +136,12 @@ void unitemp_pascalToKPa(Sensor* sensor);
|
||||||
*
|
*
|
||||||
* @param sensor Указатель на датчик
|
* @param sensor Указатель на датчик
|
||||||
*/
|
*/
|
||||||
|
void unitemp_pascalToHPa(Sensor* sensor);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Mod BySepa - linktr.ee/BySepa
|
||||||
|
*
|
||||||
|
*/
|
||||||
void unitemp_pascalToInHg(Sensor* sensor);
|
void unitemp_pascalToInHg(Sensor* sensor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,4 +158,4 @@ bool unitemp_saveSettings(void);
|
||||||
bool unitemp_loadSettings(void);
|
bool unitemp_loadSettings(void);
|
||||||
|
|
||||||
extern Unitemp* app;
|
extern Unitemp* app;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -116,14 +116,20 @@ static void _draw_humidity(Canvas* canvas, Sensor* sensor, const uint8_t pos[2])
|
||||||
static void _draw_pressure(Canvas* canvas, Sensor* sensor) {
|
static void _draw_pressure(Canvas* canvas, Sensor* sensor) {
|
||||||
const uint8_t x = 29, y = 39;
|
const uint8_t x = 29, y = 39;
|
||||||
//Рисование рамки
|
//Рисование рамки
|
||||||
canvas_draw_rframe(canvas, x, y, 69, 20, 3);
|
if(app->settings.pressure_unit == UT_PRESSURE_HPA) {
|
||||||
canvas_draw_rframe(canvas, x, y, 69, 19, 3);
|
canvas_draw_rframe(canvas, x, y, 84, 20, 3);
|
||||||
|
canvas_draw_rframe(canvas, x, y, 84, 19, 3);
|
||||||
|
} else {
|
||||||
|
canvas_draw_rframe(canvas, x, y, 69, 20, 3);
|
||||||
|
canvas_draw_rframe(canvas, x, y, 69, 19, 3);
|
||||||
|
}
|
||||||
|
|
||||||
//Рисование иконки
|
//Рисование иконки
|
||||||
canvas_draw_icon(canvas, x + 3, y + 4, &I_pressure_7x13);
|
canvas_draw_icon(canvas, x + 3, y + 4, &I_pressure_7x13);
|
||||||
|
|
||||||
int16_t press_int = sensor->pressure;
|
int16_t press_int = sensor->pressure;
|
||||||
int8_t press_dec = (int16_t)(sensor->temp * 10) % 10;
|
// Change Temp for Pressure
|
||||||
|
int8_t press_dec = (int16_t)(sensor->pressure * 10) % 10;
|
||||||
|
|
||||||
//Целая часть давления
|
//Целая часть давления
|
||||||
snprintf(app->buff, BUFF_SIZE, "%d", press_int);
|
snprintf(app->buff, BUFF_SIZE, "%d", press_int);
|
||||||
|
@ -136,15 +142,23 @@ static void _draw_pressure(Canvas* canvas, Sensor* sensor) {
|
||||||
snprintf(app->buff, BUFF_SIZE, ".%d", press_dec);
|
snprintf(app->buff, BUFF_SIZE, ".%d", press_dec);
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
canvas_draw_str(canvas, x + 27 + int_len / 2 + 2, y + 10 + 7, app->buff);
|
canvas_draw_str(canvas, x + 27 + int_len / 2 + 2, y + 10 + 7, app->buff);
|
||||||
|
} else if(app->settings.pressure_unit == UT_PRESSURE_HPA) {
|
||||||
|
uint8_t int_len = canvas_string_width(canvas, app->buff);
|
||||||
|
snprintf(app->buff, BUFF_SIZE, ".%d", press_dec);
|
||||||
|
canvas_set_font(canvas, FontPrimary);
|
||||||
|
canvas_draw_str(canvas, x + 32 + int_len / 2 + 2, y + 10 + 7, app->buff);
|
||||||
}
|
}
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
//Единица измерения
|
//Единица измерения
|
||||||
|
|
||||||
if(app->settings.pressure_unit == UT_PRESSURE_MM_HG) {
|
if(app->settings.pressure_unit == UT_PRESSURE_MM_HG) {
|
||||||
canvas_draw_icon(canvas, x + 50, y + 2, &I_mm_hg_15x15);
|
canvas_draw_icon(canvas, x + 50, y + 2, &I_mm_hg_15x15);
|
||||||
} else if(app->settings.pressure_unit == UT_PRESSURE_IN_HG) {
|
} else if(app->settings.pressure_unit == UT_PRESSURE_IN_HG) {
|
||||||
canvas_draw_icon(canvas, x + 50, y + 2, &I_in_hg_15x15);
|
canvas_draw_icon(canvas, x + 50, y + 2, &I_in_hg_15x15);
|
||||||
} else if(app->settings.pressure_unit == UT_PRESSURE_KPA) {
|
} else if(app->settings.pressure_unit == UT_PRESSURE_KPA) {
|
||||||
canvas_draw_str(canvas, x + 52, y + 13, "kPa");
|
canvas_draw_str(canvas, x + 52, y + 13, "kPa");
|
||||||
|
} else if(app->settings.pressure_unit == UT_PRESSURE_HPA) {
|
||||||
|
canvas_draw_str(canvas, x + 67, y + 13, "hPa");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ static void _onewire_scan(void) {
|
||||||
} while(_onewire_id_exist(id));
|
} while(_onewire_id_exist(id));
|
||||||
|
|
||||||
if(id == NULL) {
|
if(id == NULL) {
|
||||||
unitemp_onewire_bus_enum_init();
|
unitemp_onewire_bus_enum_init(ow_sensor->bus);
|
||||||
id = unitemp_onewire_bus_enum_next(ow_sensor->bus);
|
id = unitemp_onewire_bus_enum_next(ow_sensor->bus);
|
||||||
if(_onewire_id_exist(id)) {
|
if(_onewire_id_exist(id)) {
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -25,7 +25,7 @@ static VariableItemList* variable_item_list;
|
||||||
|
|
||||||
static const char states[2][9] = {"Auto", "Infinity"};
|
static const char states[2][9] = {"Auto", "Infinity"};
|
||||||
static const char temp_units[UT_TEMP_COUNT][3] = {"*C", "*F"};
|
static const char temp_units[UT_TEMP_COUNT][3] = {"*C", "*F"};
|
||||||
static const char pressure_units[UT_PRESSURE_COUNT][6] = {"mm Hg", "in Hg", "kPa"};
|
static const char pressure_units[UT_PRESSURE_COUNT][6] = {"mm Hg", "in Hg", "kPa", "hPA"};
|
||||||
|
|
||||||
//Элемент списка - бесконечная подсветка
|
//Элемент списка - бесконечная подсветка
|
||||||
VariableItem* infinity_backlight_item;
|
VariableItem* infinity_backlight_item;
|
||||||
|
@ -149,4 +149,4 @@ void unitemp_Settings_free(void) {
|
||||||
view_free(view);
|
view_free(view);
|
||||||
//Удаление вида после обработки
|
//Удаление вида после обработки
|
||||||
view_dispatcher_remove_view(app->view_dispatcher, VIEW_ID);
|
view_dispatcher_remove_view(app->view_dispatcher, VIEW_ID);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue