This commit is contained in:
VerstreuteSeele
2022-12-27 11:11:02 +01:00
312 changed files with 1918 additions and 884 deletions
@@ -568,12 +568,12 @@ void dap_common_usb_set_state_callback(DapStateCallback callback) {
static void* dap_usb_alloc_string_descr(const char* str) {
furi_assert(str);
uint8_t len = strlen(str);
uint8_t wlen = (len + 1) * sizeof(uint16_t);
size_t len = strlen(str);
size_t wlen = (len + 1) * sizeof(uint16_t);
struct usb_string_descriptor* dev_str_desc = malloc(wlen);
dev_str_desc->bLength = wlen;
dev_str_desc->bDescriptorType = USB_DTYPE_STRING;
for(uint8_t i = 0; i < len; i++) {
for(size_t i = 0; i < len; i++) {
dev_str_desc->wString[i] = str[i];
}
@@ -974,4 +974,4 @@ static usbd_respond hid_control(usbd_device* dev, usbd_ctlreq* req, usbd_rqc_cal
}
return usbd_fail;
}
}
@@ -1,7 +1,6 @@
# PLUGIN BY eugene-kirzhanov
App(
appid="2048_improved",
name="2048 (Improved)",
appid="2048",
name="2048 (Original)",
apptype=FlipperAppType.EXTERNAL,
entry_point="game_2048_app",
cdefines=["APP_2048_GAME"],
@@ -1,6 +1,7 @@
# PLUGIN BY eugene-kirzhanov
App(
appid="2048",
name="2048 (Original)",
appid="2048_improved",
name="2048 (Improved)",
apptype=FlipperAppType.EXTERNAL,
entry_point="game_2048_app",
cdefines=["APP_GAME_2048"],
@@ -249,30 +249,19 @@ static void hid_keyboard_draw_callback(Canvas* canvas, void* context) {
static uint8_t hid_keyboard_get_selected_key(HidKeyboardModel* model) {
HidKeyboardKey key = hid_keyboard_keyset[model->y][model->x];
// Use upper case if shift is toggled
bool useUppercase = model->shift;
// Check if the key has an upper case version
bool hasUppercase = key.shift_key != 0;
if(useUppercase && hasUppercase)
return key.value;
else
return key.value;
return key.value;
}
static void hid_keyboard_get_select_key(HidKeyboardModel* model, HidKeyboardPoint delta) {
// Keep going until a valid spot is found, this allows for nulls and zero width keys in the map
do {
if(((int8_t)model->y) + delta.y < 0)
model->y = ROW_COUNT - 1;
else
model->y = (model->y + delta.y) % ROW_COUNT;
const int delta_sum = model->y + delta.y;
model->y = delta_sum < 0 ? ROW_COUNT - 1 : delta_sum % ROW_COUNT;
} while(delta.y != 0 && hid_keyboard_keyset[model->y][model->x].value == 0);
do {
if(((int8_t)model->x) + delta.x < 0)
model->x = COLUMN_COUNT - 1;
else
model->x = (model->x + delta.x) % COLUMN_COUNT;
const int delta_sum = model->x + delta.x;
model->x = delta_sum < 0 ? COLUMN_COUNT - 1 : delta_sum % COLUMN_COUNT;
} while(delta.x != 0 && hid_keyboard_keyset[model->y][model->x].width ==
0); // Skip zero width keys, pretend they are one key
}
@@ -180,7 +180,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
// note stack view_port
x_pos = 73;
y_pos = 0;
y_pos = 0; //-V1048
canvas_set_color(canvas, ColorBlack);
canvas_set_font(canvas, FontPrimary);
canvas_draw_frame(canvas, x_pos, y_pos, 49, 64);
+1 -1
View File
@@ -524,7 +524,7 @@ static void prepare_nrf24(bool fsend_packet) {
nrf24_HANDLE,
REG_FEATURE,
0); // Enables the W_TX_PAYLOAD_NOACK command, Disable Payload with ACK, set Dynamic Payload
nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, NRF_channel);
nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, NRF_channel);
} else if(setup_from_log) { // Scan
nrf24_write_reg(
nrf24_HANDLE,
@@ -111,9 +111,9 @@ static void init_opt_select_LUT(void) {
***********************************************************************************/
#define loclass_opt__select(x, y, r) \
(4 & (((r & (r << 2)) >> 5) ^ ((r & ~(r << 2)) >> 4) ^ ((r | r << 2) >> 3))) | \
(2 & (((r | r << 2) >> 6) ^ ((r | r << 2) >> 1) ^ (r >> 5) ^ r ^ ((x ^ y) << 1))) | \
(1 & (((r & ~(r << 2)) >> 4) ^ ((r & (r << 2)) >> 3) ^ r ^ x))
(4 & ((((r) & ((r) << 2)) >> 5) ^ (((r) & ~((r) << 2)) >> 4) ^ (((r) | (r) << 2) >> 3))) | \
(2 & ((((r) | (r) << 2) >> 6) ^ (((r) | (r) << 2) >> 1) ^ ((r) >> 5) ^ (r) ^ (((x) ^ (y)) << 1))) | \
(1 & ((((r) & ~((r) << 2)) >> 4) ^ (((r) & ((r) << 2)) >> 3) ^ (r) ^ (x)))
static void loclass_opt_successor(const uint8_t* k, LoclassState_t* s, uint8_t y) {
uint16_t Tt = s->t & 0xc533;
@@ -149,30 +149,11 @@ static void loclass_opt_suc(
uint8_t length,
bool add32Zeroes) {
for(int i = 0; i < length; i++) {
uint8_t head;
head = in[i];
loclass_opt_successor(k, s, head);
head >>= 1;
loclass_opt_successor(k, s, head);
head >>= 1;
loclass_opt_successor(k, s, head);
head >>= 1;
loclass_opt_successor(k, s, head);
head >>= 1;
loclass_opt_successor(k, s, head);
head >>= 1;
loclass_opt_successor(k, s, head);
head >>= 1;
loclass_opt_successor(k, s, head);
head >>= 1;
loclass_opt_successor(k, s, head);
uint8_t head = in[i];
for(int j = 0; j < 8; j++) {
loclass_opt_successor(k, s, head);
head >>= 1;
}
}
//For tag MAC, an additional 32 zeroes
if(add32Zeroes) {
@@ -143,7 +143,7 @@ ReturnCode picopass_read_preauth(PicopassBlock* AA1) {
AA1[PICOPASS_CSN_BLOCK_INDEX].data[7]);
rfalPicoPassReadBlockRes cfg = {0};
err = rfalPicoPassPollerReadBlock(PICOPASS_CONFIG_BLOCK_INDEX, &cfg);
rfalPicoPassPollerReadBlock(PICOPASS_CONFIG_BLOCK_INDEX, &cfg);
memcpy(AA1[PICOPASS_CONFIG_BLOCK_INDEX].data, cfg.data, sizeof(cfg.data));
FURI_LOG_D(
TAG,
@@ -158,7 +158,7 @@ ReturnCode picopass_read_preauth(PicopassBlock* AA1) {
AA1[PICOPASS_CONFIG_BLOCK_INDEX].data[7]);
rfalPicoPassReadBlockRes aia;
err = rfalPicoPassPollerReadBlock(PICOPASS_AIA_BLOCK_INDEX, &aia);
rfalPicoPassPollerReadBlock(PICOPASS_AIA_BLOCK_INDEX, &aia);
memcpy(AA1[PICOPASS_AIA_BLOCK_INDEX].data, aia.data, sizeof(aia.data));
FURI_LOG_D(
TAG,
@@ -221,7 +221,7 @@ ReturnCode picopass_auth(PicopassBlock* AA1, PicopassPacs* pacs) {
while(iclass_elite_dict_get_next_key(dict, key)) {
FURI_LOG_D(
TAG,
"Try to auth with key %d %02x%02x%02x%02x%02x%02x%02x%02x",
"Try to auth with key %zu %02x%02x%02x%02x%02x%02x%02x%02x",
index++,
key[0],
key[1],
@@ -249,9 +249,7 @@ ReturnCode picopass_auth(PicopassBlock* AA1, PicopassPacs* pacs) {
}
}
if(dict) {
iclass_elite_dict_free(dict);
}
iclass_elite_dict_free(dict);
return err;
}
@@ -54,7 +54,7 @@ bool picopass_scene_save_name_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == PicopassCustomEventTextInputDone) {
if(strcmp(picopass->dev->dev_name, "")) {
if(strcmp(picopass->dev->dev_name, "") != 0) {
// picopass_device_delete(picopass->dev, true);
}
strlcpy(
@@ -307,7 +307,7 @@ bool pcsg_view_receiver_input(InputEvent* event, void* context) {
pcsg_receiver->view,
PCSGReceiverModel * model,
{
if(model->idx != model->history_item - 1) model->idx++;
if(model->history_item && model->idx != model->history_item - 1) model->idx++;
},
true);
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
@@ -15,12 +15,12 @@ static void
app->pwm_freq = freq;
app->pwm_duty = duty;
if(app->pwm_ch != pwm_ch_id[channel_id]) {
if(app->pwm_ch != pwm_ch_id[channel_id]) { //-V1051
app->pwm_ch_prev = app->pwm_ch;
app->pwm_ch = pwm_ch_id[channel_id];
view_dispatcher_send_custom_event(app->view_dispatcher, SignalGenPwmEventChannelChange);
} else {
app->pwm_ch = pwm_ch_id[channel_id];
app->pwm_ch = pwm_ch_id[channel_id]; //-V1048
view_dispatcher_send_custom_event(app->view_dispatcher, SignalGenPwmEventUpdate);
}
}
@@ -127,12 +127,12 @@ static void signal_gen_pwm_draw_callback(Canvas* canvas, void* _model) {
char* line_label = NULL;
char val_text[16];
for(uint8_t line = 0; line < LineIndexTotalCount; line++) {
for(size_t line = 0; line < LineIndexTotalCount; line++) {
if(line == LineIndexChannel) {
line_label = "GPIO Pin";
} else if(line == LineIndexFrequency) {
line_label = "Frequency";
} else if(line == LineIndexDuty) {
} else if(line == LineIndexDuty) { //-V547
line_label = "Pulse width";
}
@@ -169,7 +169,7 @@ static void signal_gen_pwm_draw_callback(Canvas* canvas, void* _model) {
canvas_draw_icon(canvas, icon_x, text_y - 9, &I_SmallArrowUp_3x5);
canvas_draw_icon(canvas, icon_x, text_y + 5, &I_SmallArrowDown_3x5);
}
} else if(line == LineIndexDuty) {
} else if(line == LineIndexDuty) { //-V547
snprintf(val_text, sizeof(val_text), "%d%%", model->duty);
canvas_draw_str_aligned(canvas, VALUE_X, text_y, AlignCenter, AlignCenter, val_text);
if(model->duty != 0) {
+1 -1
View File
@@ -124,7 +124,7 @@ static void snake_game_update_timer_callback(FuriMessageQueue* event_queue) {
static void snake_game_init_game(SnakeState* const snake_state) {
Point p[] = {{8, 6}, {7, 6}, {6, 6}, {5, 6}, {4, 6}, {3, 6}, {2, 6}};
memcpy(snake_state->points, p, sizeof(p));
memcpy(snake_state->points, p, sizeof(p)); //-V1086
snake_state->len = 7;
+1 -1
View File
@@ -4,6 +4,6 @@
[![GitHub](https://img.shields.io/github/license/quen0n/unitemp-flipperzero)](https://github.com/quen0n/unitemp-flipperzero/blob/dev/LICENSE.md)
[Flipper Zero](https://flipperzero.one/) application for reading temperature, humidity and pressure sensors using Onewire, Singlewire, I2C protocols.
## List of supported sensors (supplemented)
![image](https://user-images.githubusercontent.com/10090793/208763931-d15e9883-1016-4add-bd00-14d7842fd82d.png)
![image](https://user-images.githubusercontent.com/10090793/209491886-f4c5ef6e-38b2-45b8-a8e7-4aeca9e155f2.png)
## Installation
Copy the contents of the repository to the `applications/plugins/unitemp` folder and build the project. Flash FZ along with resources. [More...](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/fbt.md)
+2
View File
@@ -81,6 +81,8 @@ static const SensorType* sensorTypes[] = {
&AM2320_SW,
&AM2320_I2C,
&AHT10,
&SHT30,
&GXHT30,
&LM75,
&BMP280,
&BME280};
+1
View File
@@ -322,4 +322,5 @@ const GPIO*
#include "./sensors/BMx280.h"
#include "./sensors/AM2320.h"
#include "./sensors/DHT20.h"
#include "./sensors/SHT30.h"
#endif
@@ -0,0 +1,90 @@
/*
Unitemp - Universal temperature reader
Copyright (C) 2022 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 "SHT30.h"
#include "../interfaces/I2CSensor.h"
const SensorType SHT30 = {
.typename = "SHT30",
.altname = "SHT30/31/35",
.interface = &I2C,
.datatype = UT_TEMPERATURE | UT_HUMIDITY,
.pollingInterval = 1000,
.allocator = unitemp_SHT30_I2C_alloc,
.mem_releaser = unitemp_SHT30_I2C_free,
.initializer = unitemp_SHT30_init,
.deinitializer = unitemp_SHT30_I2C_deinit,
.updater = unitemp_SHT30_I2C_update};
const SensorType GXHT30 = {
.typename = "GXHT30",
.altname = "GXHT30/31/35",
.interface = &I2C,
.datatype = UT_TEMPERATURE | UT_HUMIDITY,
.pollingInterval = 1000,
.allocator = unitemp_SHT30_I2C_alloc,
.mem_releaser = unitemp_SHT30_I2C_free,
.initializer = unitemp_GXHT30_init,
.deinitializer = unitemp_SHT30_I2C_deinit,
.updater = unitemp_SHT30_I2C_update};
bool unitemp_SHT30_I2C_alloc(Sensor* sensor, char* args) {
UNUSED(args);
I2CSensor* i2c_sensor = (I2CSensor*)sensor->instance;
//Адреса на шине I2C (7 бит)
i2c_sensor->minI2CAdr = 0x44 << 1;
i2c_sensor->maxI2CAdr = 0x45 << 1;
return true;
}
bool unitemp_SHT30_I2C_free(Sensor* sensor) {
//Нечего высвобождать, так как ничего не было выделено
UNUSED(sensor);
return true;
}
bool unitemp_SHT30_init(Sensor* sensor) {
UNUSED(sensor);
return true;
}
bool unitemp_GXHT30_init(Sensor* sensor) {
I2CSensor* i2c_sensor = (I2CSensor*)sensor->instance;
//Включение режима автоматического преобразования 2 раза в сек
uint8_t data[2] = {0x22, 0x36};
if(!unitemp_i2c_writeArray(i2c_sensor, 2, data)) return false;
return true;
}
bool unitemp_SHT30_I2C_deinit(Sensor* sensor) {
//Нечего деинициализировать
UNUSED(sensor);
return true;
}
UnitempStatus unitemp_SHT30_I2C_update(Sensor* sensor) {
I2CSensor* i2c_sensor = (I2CSensor*)sensor->instance;
//Получение данных
uint8_t data[6] = {0xE0, 0x00};
if(!unitemp_i2c_writeArray(i2c_sensor, 2, data)) return UT_SENSORSTATUS_TIMEOUT;
if(!unitemp_i2c_readArray(i2c_sensor, 6, data)) return UT_SENSORSTATUS_TIMEOUT;
sensor->temp = -45 + 175 * (((uint16_t)(data[0] << 8) | data[1]) / 65535.0f);
sensor->hum = 100 * (((uint16_t)(data[3] << 8) | data[4]) / 65535.0f);
return UT_SENSORSTATUS_OK;
}
@@ -0,0 +1,70 @@
/*
Unitemp - Universal temperature reader
Copyright (C) 2022 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_SHT30
#define UNITEMP_SHT30
#include "../unitemp.h"
#include "../Sensors.h"
extern const SensorType SHT30;
extern const SensorType GXHT30;
/**
* @brief Выделение памяти и установка начальных значений датчика SHT30
*
* @param sensor Указатель на создаваемый датчик
* @return Истина при успехе
*/
bool unitemp_SHT30_I2C_alloc(Sensor* sensor, char* args);
/**
* @brief Инициализации датчика SHT30
*
* @param sensor Указатель на датчик
* @return Истина если инициализация упспешная
*/
bool unitemp_SHT30_init(Sensor* sensor);
/**
* @brief Инициализации датчика GXHT30
*
* @param sensor Указатель на датчик
* @return Истина если инициализация упспешная
*/
bool unitemp_GXHT30_init(Sensor* sensor);
/**
* @brief Деинициализация датчика
*
* @param sensor Указатель на датчик
*/
bool unitemp_SHT30_I2C_deinit(Sensor* sensor);
/**
* @brief Обновление значений из датчика
*
* @param sensor Указатель на датчик
* @return Статус обновления
*/
UnitempStatus unitemp_SHT30_I2C_update(Sensor* sensor);
/**
* @brief Высвободить память датчика
*
* @param sensor Указатель на датчик
*/
bool unitemp_SHT30_I2C_free(Sensor* sensor);
#endif
Binary file not shown.
@@ -132,7 +132,7 @@ void unitemp_widget_delete_switch(Sensor* sensor) {
app->buff,
BUFF_SIZE,
"\e#I2C addr:\e# 0x%02X",
((I2CSensor*)current_sensor->instance)->currentI2CAdr);
((I2CSensor*)current_sensor->instance)->currentI2CAdr >> 1);
widget_add_text_box_element(
app->widget, 0, 28, 128, 23, AlignLeft, AlignTop, app->buff, false);
}
@@ -343,7 +343,7 @@ bool ws_protocol_decoder_oregon2_deserialize(void* context, FlipperFormat* flipp
flipper_format,
"VarData",
(uint8_t*)&instance->var_data,
sizeof(instance->var_data))) {
sizeof(instance->var_data))) { //-V1051
FURI_LOG_E(TAG, "Missing VarData");
break;
}
@@ -147,7 +147,7 @@ static void ws_protocol_oregon_v1_remote_controller(WSBlockGeneric* instance) {
instance->temp = -temp_raw;
}
instance->battery_low = !(instance->data >> 23) & 1;
instance->battery_low = !((instance->data >> 23) & 1ULL);
instance->btn = WS_NO_BTN;
instance->humidity = WS_NO_HUMIDITY;
@@ -79,7 +79,7 @@ bool ws_block_generic_serialize(
uint8_t key_data[sizeof(uint64_t)] = {0};
for(size_t i = 0; i < sizeof(uint64_t); i++) {
key_data[sizeof(uint64_t) - i - 1] = (instance->data >> i * 8) & 0xFF;
key_data[sizeof(uint64_t) - i - 1] = (instance->data >> (i * 8)) & 0xFF;
}
if(!flipper_format_write_hex(flipper_format, "Data", key_data, sizeof(uint64_t))) {
@@ -208,4 +208,4 @@ bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipp
} while(0);
return res;
}
}
@@ -4,8 +4,7 @@
#include "../protocols/ws_generic.h"
#include <input/input.h>
#include <gui/elements.h>
#define abs(x) ((x) > 0 ? (x) : -(x))
#include <float_tools.h>
struct WSReceiverInfo {
View* view;
@@ -79,7 +78,7 @@ void ws_view_receiver_info_draw(Canvas* canvas, WSReceiverInfoModel* model) {
elements_bold_rounded_frame(canvas, 0, 38, 127, 25);
canvas_set_font(canvas, FontPrimary);
if(model->generic->temp != WS_NO_TEMPERATURE) {
if(!float_is_equal(model->generic->temp, WS_NO_TEMPERATURE)) {
canvas_draw_icon(canvas, 6, 43, &I_Therm_7x16);
uint8_t temp_x1 = 0;
@@ -111,11 +111,8 @@ void ws_hopper_update(WeatherStationApp* app) {
switch(app->txrx->hopper_state) {
case WSHopperStateOFF:
return;
break;
case WSHopperStatePause:
return;
break;
case WSHopperStateRSSITimeOut:
if(app->txrx->hopper_timeout != 0) {
app->txrx->hopper_timeout--;
@@ -186,7 +186,7 @@ WSHistoryStateAddKey
}
// or add new record
if(!sensor_found) {
if(!sensor_found) { //-V547
WSHistoryItem* item = WSHistoryItemArray_push_raw(instance->history->data);
item->preset = malloc(sizeof(SubGhzRadioPreset));
item->type = decoder_base->protocol->type;