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

This commit is contained in:
MX 2024-06-01 16:55:04 +03:00
commit 4b5e7d90d6
No known key found for this signature in database
GPG Key ID: 7CCC66B7DBDD1C83
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
.idea/
# Sublime Text
.sublime-project.sublime-workspace
# Python VirtEnvironments
.env
.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": [
// We might be able to tighten this a bit more to only include the correct toolchain.
"--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;
}
}
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;
}

View File

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

View File

@ -13,6 +13,7 @@
*/
#define TAG "SubGhzProtocolPrinceton"
#define PRINCETON_GUARD_TIME_DEFALUT 30 //GUARD_TIME = PRINCETON_GUARD_TIME_DEFALUT * TE
static const SubGhzBlockConst subghz_protocol_princeton_const = {
.te_short = 390,
@ -29,6 +30,7 @@ struct SubGhzProtocolDecoderPrinceton {
uint32_t te;
uint32_t last_data;
uint32_t guard_time;
};
struct SubGhzProtocolEncoderPrinceton {
@ -38,6 +40,7 @@ struct SubGhzProtocolEncoderPrinceton {
SubGhzBlockGeneric generic;
uint32_t te;
uint32_t guard_time;
};
typedef enum {
@ -135,8 +138,9 @@ static bool
//Send Stop bit
instance->encoder.upload[index++] = level_duration_make(true, (uint32_t)instance->te);
//Send PT_GUARD
instance->encoder.upload[index++] = level_duration_make(false, (uint32_t)instance->te * 30);
//Send PT_GUARD_TIME
instance->encoder.upload[index++] =
level_duration_make(false, (uint32_t)instance->te * instance->guard_time);
return true;
}
@ -165,6 +169,11 @@ SubGhzProtocolStatus
break;
}
//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, "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_count_bit = 0;
instance->te = 0;
instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT;
}
break;
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_count_bit = instance->decoder.decode_count_bit;
instance->guard_time = round((float)duration / instance->te);
if(instance->base.callback)
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");
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;
}
@ -349,6 +366,10 @@ SubGhzProtocolStatus
ret = SubGhzProtocolStatusErrorParserTe;
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);
return ret;

View File

@ -12,3 +12,4 @@ def generate(env):
env["LINK"] = env["CXX"]
env["CXX_NOCACHE"] = env["CXX"]
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 itertools
import json
from shlex import quote
from shlex import join, split
import SCons
from SCons.Tool.asm import ASPPSuffixes, ASSuffixes
@ -108,6 +108,10 @@ def make_emit_compilation_DB_entry(comstr):
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):
"""
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"],
)
# We assume first non-space character is the executable
executable = command.split(" ", 1)[0]
if not (tool_path := _TOOL_PATH_CACHE.get(executable, None)):
tool_path = env.WhereIs(executable) or executable
_TOOL_PATH_CACHE[executable] = tool_path
# If there are spaces in the executable path, we need to quote it
if " " in tool_path:
tool_path = quote(tool_path)
# Replacing the executable with the full path
command = tool_path + command[len(executable) :]
cmdline = split(command)
binaries_to_omit = env["COMPILATIONDB_OMIT_BINARIES"]
while (executable := cmdline[0]) in binaries_to_omit:
cmdline.pop(0)
if __is_value_true(env["COMPILATIONDB_USE_BINARY_ABSPATH"]):
if not (tool_path := _TOOL_PATH_CACHE.get(executable, None)):
tool_path = env.WhereIs(executable) or executable
_TOOL_PATH_CACHE[executable] = tool_path
# Replacing the executable with the full path
executable = tool_path
command = join((executable, *cmdline[1:]))
entry = {
"directory": env.Dir("#").abspath,
@ -150,7 +157,7 @@ def compilation_db_entry_action(target, source, env, **kw):
def write_compilation_db(target, source, env):
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_srcpath_filter = env.subst("$COMPILATIONDB_SRCPATH_FILTER")
@ -225,6 +232,8 @@ def generate(env, **kwargs):
COMPILATIONDB_USE_ABSPATH=False,
COMPILATIONDB_PATH_FILTER="",
COMPILATIONDB_SRCPATH_FILTER="",
COMPILATIONDB_OMIT_BINARIES=[],
COMPILATIONDB_USE_BINARY_ABSPATH=False,
)
components_by_suffix = itertools.chain(

View File

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