1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-13 13:09:49 +04:00

Merge remote-tracking branch 'OFW/dev' into dev

This commit is contained in:
MX
2024-06-01 16:55:04 +03:00
10 changed files with 95 additions and 15 deletions

13
.clangd Normal file
View File

@@ -0,0 +1,13 @@
CompileFlags:
Add:
- -Wno-unknown-warning-option
- -Wno-format
Remove:
- -mword-relocations
---
If:
PathMatch: .*\.h
Diagnostics:
UnusedIncludes: None

3
.gitignore vendored
View File

@@ -12,6 +12,9 @@ compile_commands.json
# JetBrains IDEs # JetBrains IDEs
.idea/ .idea/
# Sublime Text
.sublime-project.sublime-workspace
# Python VirtEnvironments # Python VirtEnvironments
.env .env
.venv .venv

21
.sublime-project vendored Normal file
View File

@@ -0,0 +1,21 @@
{
"folders":
[
{
"path": ".",
}
],
"settings": {
"LSP": {
"clangd": {
"initializationOptions": {
"clangd.compile-commands-dir": "build/latest",
"clangd.header-insertion": null,
"clangd.query-driver": "**",
"clangd.clang-tidy": true,
},
"enabled": true,
},
},
},
}

View File

@@ -19,6 +19,8 @@
"clangd.arguments": [ "clangd.arguments": [
// We might be able to tighten this a bit more to only include the correct toolchain. // We might be able to tighten this a bit more to only include the correct toolchain.
"--query-driver=**", "--query-driver=**",
"--compile-commands-dir=${workspaceFolder}/build/latest" "--compile-commands-dir=${workspaceFolder}/build/latest",
"--clang-tidy",
"--header-insertion=never"
] ]
} }

View File

@@ -81,6 +81,14 @@ bool subghz_txrx_gen_data_protocol_and_te(
ret = true; ret = true;
} }
} }
if(ret == SubGhzProtocolStatusOk) {
uint32_t guard_time = 30;
if(!flipper_format_update_uint32(
instance->fff_data, "Guard_time", (uint32_t*)&guard_time, 1)) {
ret = SubGhzProtocolStatusErrorParserOthers;
FURI_LOG_E(TAG, "Unable to update Guard_time");
}
}
return ret; return ret;
} }

View File

@@ -20,6 +20,7 @@ env = ENV.Clone(
"fbt_resources", "fbt_resources",
], ],
COMPILATIONDB_USE_ABSPATH=False, COMPILATIONDB_USE_ABSPATH=False,
COMPILATIONDB_USE_BINARY_ABSPATH=True,
BUILD_DIR=fw_build_meta["build_dir"], BUILD_DIR=fw_build_meta["build_dir"],
IS_BASE_FIRMWARE=fw_build_meta["type"] == "firmware", IS_BASE_FIRMWARE=fw_build_meta["type"] == "firmware",
FW_FLAVOR=fw_build_meta["flavor"], FW_FLAVOR=fw_build_meta["flavor"],

View File

@@ -13,6 +13,7 @@
*/ */
#define TAG "SubGhzProtocolPrinceton" #define TAG "SubGhzProtocolPrinceton"
#define PRINCETON_GUARD_TIME_DEFALUT 30 //GUARD_TIME = PRINCETON_GUARD_TIME_DEFALUT * TE
static const SubGhzBlockConst subghz_protocol_princeton_const = { static const SubGhzBlockConst subghz_protocol_princeton_const = {
.te_short = 390, .te_short = 390,
@@ -29,6 +30,7 @@ struct SubGhzProtocolDecoderPrinceton {
uint32_t te; uint32_t te;
uint32_t last_data; uint32_t last_data;
uint32_t guard_time;
}; };
struct SubGhzProtocolEncoderPrinceton { struct SubGhzProtocolEncoderPrinceton {
@@ -38,6 +40,7 @@ struct SubGhzProtocolEncoderPrinceton {
SubGhzBlockGeneric generic; SubGhzBlockGeneric generic;
uint32_t te; uint32_t te;
uint32_t guard_time;
}; };
typedef enum { typedef enum {
@@ -135,8 +138,9 @@ static bool
//Send Stop bit //Send Stop bit
instance->encoder.upload[index++] = level_duration_make(true, (uint32_t)instance->te); instance->encoder.upload[index++] = level_duration_make(true, (uint32_t)instance->te);
//Send PT_GUARD //Send PT_GUARD_TIME
instance->encoder.upload[index++] = level_duration_make(false, (uint32_t)instance->te * 30); instance->encoder.upload[index++] =
level_duration_make(false, (uint32_t)instance->te * instance->guard_time);
return true; return true;
} }
@@ -165,6 +169,11 @@ SubGhzProtocolStatus
break; break;
} }
//optional parameter parameter //optional parameter parameter
if(!flipper_format_read_uint32(
flipper_format, "Guard_time", (uint32_t*)&instance->guard_time, 1)) {
instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT;
}
flipper_format_read_uint32( flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1); flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
@@ -235,6 +244,7 @@ void subghz_protocol_decoder_princeton_feed(void* context, bool level, uint32_t
instance->decoder.decode_data = 0; instance->decoder.decode_data = 0;
instance->decoder.decode_count_bit = 0; instance->decoder.decode_count_bit = 0;
instance->te = 0; instance->te = 0;
instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT;
} }
break; break;
case PrincetonDecoderStepSaveDuration: case PrincetonDecoderStepSaveDuration:
@@ -257,6 +267,7 @@ void subghz_protocol_decoder_princeton_feed(void* context, bool level, uint32_t
instance->generic.data = instance->decoder.decode_data; instance->generic.data = instance->decoder.decode_data;
instance->generic.data_count_bit = instance->decoder.decode_count_bit; instance->generic.data_count_bit = instance->decoder.decode_count_bit;
instance->guard_time = round((float)duration / instance->te);
if(instance->base.callback) if(instance->base.callback)
instance->base.callback(&instance->base, instance->base.context); instance->base.callback(&instance->base, instance->base.context);
@@ -323,6 +334,12 @@ SubGhzProtocolStatus subghz_protocol_decoder_princeton_serialize(
FURI_LOG_E(TAG, "Unable to add TE"); FURI_LOG_E(TAG, "Unable to add TE");
ret = SubGhzProtocolStatusErrorParserTe; ret = SubGhzProtocolStatusErrorParserTe;
} }
if((ret == SubGhzProtocolStatusOk) &&
!flipper_format_write_uint32(flipper_format, "Guard_time", &instance->guard_time, 1)) {
FURI_LOG_E(TAG, "Unable to add Guard_time");
ret = SubGhzProtocolStatusErrorParserOthers;
}
return ret; return ret;
} }
@@ -349,6 +366,10 @@ SubGhzProtocolStatus
ret = SubGhzProtocolStatusErrorParserTe; ret = SubGhzProtocolStatusErrorParserTe;
break; break;
} }
if(!flipper_format_read_uint32(
flipper_format, "Guard_time", (uint32_t*)&instance->guard_time, 1)) {
instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT;
}
} while(false); } while(false);
return ret; return ret;

View File

@@ -12,3 +12,4 @@ def generate(env):
env["LINK"] = env["CXX"] env["LINK"] = env["CXX"]
env["CXX_NOCACHE"] = env["CXX"] env["CXX_NOCACHE"] = env["CXX"]
env["CXX"] = "$CCACHE $CXX_NOCACHE" env["CXX"] = "$CCACHE $CXX_NOCACHE"
env.AppendUnique(COMPILATIONDB_OMIT_BINARIES=["ccache"])

View File

@@ -32,7 +32,7 @@ which is the name that most clang tools search for by default.
import fnmatch import fnmatch
import itertools import itertools
import json import json
from shlex import quote from shlex import join, split
import SCons import SCons
from SCons.Tool.asm import ASPPSuffixes, ASSuffixes from SCons.Tool.asm import ASPPSuffixes, ASSuffixes
@@ -108,6 +108,10 @@ def make_emit_compilation_DB_entry(comstr):
return emit_compilation_db_entry return emit_compilation_db_entry
def __is_value_true(value):
return value in [True, 1, "True", "true"]
def compilation_db_entry_action(target, source, env, **kw): def compilation_db_entry_action(target, source, env, **kw):
""" """
Create a dictionary with evaluated command line, target, source Create a dictionary with evaluated command line, target, source
@@ -126,16 +130,19 @@ def compilation_db_entry_action(target, source, env, **kw):
env=env["__COMPILATIONDB_ENV"], env=env["__COMPILATIONDB_ENV"],
) )
# We assume first non-space character is the executable cmdline = split(command)
executable = command.split(" ", 1)[0] binaries_to_omit = env["COMPILATIONDB_OMIT_BINARIES"]
if not (tool_path := _TOOL_PATH_CACHE.get(executable, None)): while (executable := cmdline[0]) in binaries_to_omit:
tool_path = env.WhereIs(executable) or executable cmdline.pop(0)
_TOOL_PATH_CACHE[executable] = tool_path
# If there are spaces in the executable path, we need to quote it if __is_value_true(env["COMPILATIONDB_USE_BINARY_ABSPATH"]):
if " " in tool_path: if not (tool_path := _TOOL_PATH_CACHE.get(executable, None)):
tool_path = quote(tool_path) tool_path = env.WhereIs(executable) or executable
# Replacing the executable with the full path _TOOL_PATH_CACHE[executable] = tool_path
command = tool_path + command[len(executable) :] # Replacing the executable with the full path
executable = tool_path
command = join((executable, *cmdline[1:]))
entry = { entry = {
"directory": env.Dir("#").abspath, "directory": env.Dir("#").abspath,
@@ -150,7 +157,7 @@ def compilation_db_entry_action(target, source, env, **kw):
def write_compilation_db(target, source, env): def write_compilation_db(target, source, env):
entries = [] entries = []
use_abspath = env["COMPILATIONDB_USE_ABSPATH"] in [True, 1, "True", "true"] use_abspath = __is_value_true(env["COMPILATIONDB_USE_ABSPATH"])
use_path_filter = env.subst("$COMPILATIONDB_PATH_FILTER") use_path_filter = env.subst("$COMPILATIONDB_PATH_FILTER")
use_srcpath_filter = env.subst("$COMPILATIONDB_SRCPATH_FILTER") use_srcpath_filter = env.subst("$COMPILATIONDB_SRCPATH_FILTER")
@@ -225,6 +232,8 @@ def generate(env, **kwargs):
COMPILATIONDB_USE_ABSPATH=False, COMPILATIONDB_USE_ABSPATH=False,
COMPILATIONDB_PATH_FILTER="", COMPILATIONDB_PATH_FILTER="",
COMPILATIONDB_SRCPATH_FILTER="", COMPILATIONDB_SRCPATH_FILTER="",
COMPILATIONDB_OMIT_BINARIES=[],
COMPILATIONDB_USE_BINARY_ABSPATH=False,
) )
components_by_suffix = itertools.chain( components_by_suffix = itertools.chain(

View File

@@ -102,6 +102,7 @@ env = core_env.Clone(
core_env.subst("$SDK_DEFINITION"), load_version_only=True core_env.subst("$SDK_DEFINITION"), load_version_only=True
).version, ).version,
APPCHECK_COMSTR="\tAPPCHK\t${SOURCE}\n\t\tTarget: ${TARGET_HW}, API: ${UFBT_API_VERSION}", APPCHECK_COMSTR="\tAPPCHK\t${SOURCE}\n\t\tTarget: ${TARGET_HW}, API: ${UFBT_API_VERSION}",
COMPILATIONDB_USE_BINARY_ABSPATH=True,
) )
wrap_tempfile(env, "LINKCOM") wrap_tempfile(env, "LINKCOM")