mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-20 04:54:45 -07:00
Merge branch 'dev' of https://github.com/DarkFlippers/unleashed-firmware into xfw-dev
This commit is contained in:
@@ -121,8 +121,9 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
|||||||
if(furi_hal_subghz_is_frequency_valid(current_frequency) &&
|
if(furi_hal_subghz_is_frequency_valid(current_frequency) &&
|
||||||
(current_frequency != 467750000) && (current_frequency != 464000000) &&
|
(current_frequency != 467750000) && (current_frequency != 464000000) &&
|
||||||
!((furi_hal_subghz.radio_type == SubGhzRadioExternal) &&
|
!((furi_hal_subghz.radio_type == SubGhzRadioExternal) &&
|
||||||
(current_frequency != 390000000) &&
|
((current_frequency == 390000000) || (current_frequency == 312000000) ||
|
||||||
(current_frequency >= 311900000 && current_frequency <= 312200000))) {
|
(current_frequency == 312100000) || (current_frequency == 312200000) ||
|
||||||
|
(current_frequency == 440175000)))) {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
||||||
cc1101_switch_to_idle(furi_hal_subghz.spi_bus_handle);
|
cc1101_switch_to_idle(furi_hal_subghz.spi_bus_handle);
|
||||||
frequency =
|
frequency =
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
uint8_t value_index_exm;
|
uint8_t value_index_exm;
|
||||||
uint8_t value_index_dpin;
|
uint8_t value_index_dpin;
|
||||||
uint8_t value_index_cnt;
|
uint8_t value_index_cnt;
|
||||||
|
uint8_t value_index_pwr;
|
||||||
|
|
||||||
#define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const))
|
#define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const))
|
||||||
const char* const radio_modules_variables_text[] = {
|
const char* const radio_modules_variables_text[] = {
|
||||||
@@ -11,6 +12,12 @@ const char* const radio_modules_variables_text[] = {
|
|||||||
"External",
|
"External",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define EXT_MOD_POWER_COUNT 2
|
||||||
|
const char* const ext_mod_power_text[EXT_MOD_POWER_COUNT] = {
|
||||||
|
"ON",
|
||||||
|
"OFF",
|
||||||
|
};
|
||||||
|
|
||||||
#define DEBUG_P_COUNT 2
|
#define DEBUG_P_COUNT 2
|
||||||
const char* const debug_pin_text[DEBUG_P_COUNT] = {
|
const char* const debug_pin_text[DEBUG_P_COUNT] = {
|
||||||
"OFF",
|
"OFF",
|
||||||
@@ -77,6 +84,19 @@ static void subghz_scene_receiver_config_set_debug_counter(VariableItem* item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void subghz_scene_receiver_config_set_ext_mod_power(VariableItem* item) {
|
||||||
|
uint8_t index = variable_item_get_current_value_index(item);
|
||||||
|
|
||||||
|
variable_item_set_current_value_text(item, ext_mod_power_text[index]);
|
||||||
|
|
||||||
|
furi_hal_subghz_set_external_power_disable(index == 1);
|
||||||
|
if(index == 1) {
|
||||||
|
furi_hal_subghz_disable_ext_power();
|
||||||
|
} else {
|
||||||
|
furi_hal_subghz_enable_ext_power();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void subghz_scene_ext_module_settings_on_enter(void* context) {
|
void subghz_scene_ext_module_settings_on_enter(void* context) {
|
||||||
SubGhz* subghz = context;
|
SubGhz* subghz = context;
|
||||||
|
|
||||||
@@ -92,10 +112,20 @@ void subghz_scene_ext_module_settings_on_enter(void* context) {
|
|||||||
variable_item_set_current_value_index(item, value_index_exm);
|
variable_item_set_current_value_index(item, value_index_exm);
|
||||||
variable_item_set_current_value_text(item, radio_modules_variables_text[value_index_exm]);
|
variable_item_set_current_value_text(item, radio_modules_variables_text[value_index_exm]);
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
subghz->variable_item_list,
|
||||||
|
"Ext Radio 5v",
|
||||||
|
EXT_MOD_POWER_COUNT,
|
||||||
|
subghz_scene_receiver_config_set_ext_mod_power,
|
||||||
|
subghz);
|
||||||
|
value_index_pwr = furi_hal_subghz_get_external_power_disable();
|
||||||
|
variable_item_set_current_value_index(item, value_index_pwr);
|
||||||
|
variable_item_set_current_value_text(item, ext_mod_power_text[value_index_pwr]);
|
||||||
|
|
||||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
subghz->variable_item_list,
|
subghz->variable_item_list,
|
||||||
"Debug Pin:",
|
"Debug Pin",
|
||||||
DEBUG_P_COUNT,
|
DEBUG_P_COUNT,
|
||||||
subghz_scene_receiver_config_set_debug_pin,
|
subghz_scene_receiver_config_set_debug_pin,
|
||||||
subghz);
|
subghz);
|
||||||
@@ -105,7 +135,7 @@ void subghz_scene_ext_module_settings_on_enter(void* context) {
|
|||||||
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
subghz->variable_item_list,
|
subghz->variable_item_list,
|
||||||
"Counter Mult:",
|
"Counter incr.",
|
||||||
DEBUG_COUNTER_COUNT,
|
DEBUG_COUNTER_COUNT,
|
||||||
subghz_scene_receiver_config_set_debug_counter,
|
subghz_scene_receiver_config_set_debug_counter,
|
||||||
subghz);
|
subghz);
|
||||||
|
|||||||
@@ -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
|
|||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1408,6 +1408,7 @@ Function,+,furi_hal_subghz_enable_ext_power,_Bool,
|
|||||||
Function,+,furi_hal_subghz_flush_rx,void,
|
Function,+,furi_hal_subghz_flush_rx,void,
|
||||||
Function,+,furi_hal_subghz_flush_tx,void,
|
Function,+,furi_hal_subghz_flush_tx,void,
|
||||||
Function,+,furi_hal_subghz_get_extend_settings,void,"_Bool*, _Bool*"
|
Function,+,furi_hal_subghz_get_extend_settings,void,"_Bool*, _Bool*"
|
||||||
|
Function,+,furi_hal_subghz_get_external_power_disable,_Bool,
|
||||||
Function,+,furi_hal_subghz_get_lqi,uint8_t,
|
Function,+,furi_hal_subghz_get_lqi,uint8_t,
|
||||||
Function,+,furi_hal_subghz_get_radio_type,SubGhzRadioType,
|
Function,+,furi_hal_subghz_get_radio_type,SubGhzRadioType,
|
||||||
Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t,
|
Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t,
|
||||||
@@ -1429,6 +1430,7 @@ Function,+,furi_hal_subghz_rx,void,
|
|||||||
Function,+,furi_hal_subghz_rx_pipe_not_empty,_Bool,
|
Function,+,furi_hal_subghz_rx_pipe_not_empty,_Bool,
|
||||||
Function,+,furi_hal_subghz_set_async_mirror_pin,void,const GpioPin*
|
Function,+,furi_hal_subghz_set_async_mirror_pin,void,const GpioPin*
|
||||||
Function,+,furi_hal_subghz_set_extend_settings,void,"_Bool, _Bool"
|
Function,+,furi_hal_subghz_set_extend_settings,void,"_Bool, _Bool"
|
||||||
|
Function,+,furi_hal_subghz_set_external_power_disable,void,_Bool
|
||||||
Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t
|
Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t
|
||||||
Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t
|
Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t
|
||||||
Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
||||||
|
|||||||
|
@@ -39,6 +39,7 @@ volatile FuriHalSubGhz furi_hal_subghz = {
|
|||||||
.spi_bus_handle = &furi_hal_spi_bus_handle_subghz,
|
.spi_bus_handle = &furi_hal_spi_bus_handle_subghz,
|
||||||
.cc1101_g0_pin = &gpio_cc1101_g0,
|
.cc1101_g0_pin = &gpio_cc1101_g0,
|
||||||
.rolling_counter_mult = 1,
|
.rolling_counter_mult = 1,
|
||||||
|
.ext_module_power_disabled = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool furi_hal_subghz_set_radio_type(SubGhzRadioType state) {
|
bool furi_hal_subghz_set_radio_type(SubGhzRadioType state) {
|
||||||
@@ -70,6 +71,14 @@ void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult) {
|
|||||||
furi_hal_subghz.rolling_counter_mult = mult;
|
furi_hal_subghz.rolling_counter_mult = mult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void furi_hal_subghz_set_external_power_disable(bool state) {
|
||||||
|
furi_hal_subghz.ext_module_power_disabled = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool furi_hal_subghz_get_external_power_disable(void) {
|
||||||
|
return furi_hal_subghz.ext_module_power_disabled;
|
||||||
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
|
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
|
||||||
furi_hal_subghz.async_mirror_pin = pin;
|
furi_hal_subghz.async_mirror_pin = pin;
|
||||||
}
|
}
|
||||||
@@ -79,6 +88,9 @@ void furi_hal_subghz_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_subghz_enable_ext_power(void) {
|
bool furi_hal_subghz_enable_ext_power(void) {
|
||||||
|
if(furi_hal_subghz.ext_module_power_disabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if(furi_hal_subghz.radio_type != SubGhzRadioInternal) {
|
if(furi_hal_subghz.radio_type != SubGhzRadioInternal) {
|
||||||
uint8_t attempts = 0;
|
uint8_t attempts = 0;
|
||||||
while(!furi_hal_power_is_otg_enabled() && attempts++ < 2) {
|
while(!furi_hal_power_is_otg_enabled() && attempts++ < 2) {
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ typedef struct {
|
|||||||
FuriHalSpiBusHandle* spi_bus_handle;
|
FuriHalSpiBusHandle* spi_bus_handle;
|
||||||
const GpioPin* cc1101_g0_pin;
|
const GpioPin* cc1101_g0_pin;
|
||||||
uint8_t rolling_counter_mult;
|
uint8_t rolling_counter_mult;
|
||||||
|
bool ext_module_power_disabled;
|
||||||
} FuriHalSubGhz;
|
} FuriHalSubGhz;
|
||||||
|
|
||||||
extern volatile FuriHalSubGhz furi_hal_subghz;
|
extern volatile FuriHalSubGhz furi_hal_subghz;
|
||||||
@@ -335,6 +336,14 @@ uint8_t furi_hal_subghz_get_rolling_counter_mult(void);
|
|||||||
*/
|
*/
|
||||||
void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult);
|
void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult);
|
||||||
|
|
||||||
|
/** If true - disable 5v power of the external radio module
|
||||||
|
*/
|
||||||
|
void furi_hal_subghz_set_external_power_disable(bool state);
|
||||||
|
|
||||||
|
/** Get the current state of the external power disable flag
|
||||||
|
*/
|
||||||
|
bool furi_hal_subghz_get_external_power_disable(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user