mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 15:11:51 +02:00
Merge 88e5c641fa
into 8598142c27
This commit is contained in:
commit
7556d77025
|
@ -2,20 +2,22 @@
|
|||
Language: Cpp
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: true
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignConsecutiveMacros: true
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 0
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortLambdasOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: None
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
|
@ -28,29 +30,30 @@ BraceWrapping:
|
|||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterExternBlock: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: true
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
SplitEmptyRecord: true
|
||||
BreakAfterAttributes: Never
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 140
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CommentPragmas: "^ IWYU pragma:"
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 2
|
||||
|
@ -75,24 +78,26 @@ IncludeCategories:
|
|||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
- Regex: '.*'
|
||||
- Regex: ".*"
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IncludeIsMainRegex: "(Test)?$"
|
||||
IncludeIsMainSourceRegex: ""
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: true
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: BeforeHash
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
# Requires Clang >= 15, could also cause incorrect code formatting:
|
||||
# InsertBraces: true
|
||||
# Could lead to incorrect formatting, but I think that the tradeoff is worth it
|
||||
InsertBraces: true
|
||||
InsertNewlineAtEOF: true
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
LineEnding: LF
|
||||
MacroBlockBegin: ""
|
||||
MacroBlockEnd: ""
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: All
|
||||
PackConstructorInitializers: NextLine
|
||||
|
@ -107,12 +112,14 @@ PenaltyReturnTypeOnItsOwnLine: 60
|
|||
PointerAlignment: Left
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
RemoveSemicolon: true
|
||||
SeparateDefinitionBlocks: Always
|
||||
SortIncludes: false
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
|
@ -120,22 +127,19 @@ SpaceBeforeCtorInitializerColon: true
|
|||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatementsExceptForEachMacros
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
Standard: Latest
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
...
|
||||
|
|
22
.github/workflows/format.yml
vendored
22
.github/workflows/format.yml
vendored
|
@ -4,16 +4,16 @@ on:
|
|||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- '**.cpp'
|
||||
- '**.h'
|
||||
- '!src/libs/**'
|
||||
- '!src/FreeRTOS/**'
|
||||
- "src/**.cpp"
|
||||
- "src/**.h"
|
||||
- "!src/libs/**"
|
||||
- "!src/FreeRTOS/**"
|
||||
|
||||
jobs:
|
||||
test-format:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1000
|
||||
|
||||
|
@ -23,19 +23,19 @@ jobs:
|
|||
- name: Install clang-format
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install clang-format-14
|
||||
sudo apt-get -y install clang-format-16
|
||||
|
||||
- name: Check formatting
|
||||
run: tests/test-format.sh
|
||||
|
||||
- name: Upload patches
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
with:
|
||||
name: Patches
|
||||
path: ./*.patch
|
||||
test-clang-tidy:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: infinitime/infinitime-build
|
||||
steps:
|
||||
|
@ -46,7 +46,7 @@ jobs:
|
|||
- name: Workaround permission issues
|
||||
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Checkout source files
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1000
|
||||
|
@ -55,7 +55,7 @@ jobs:
|
|||
- name: Install clang-tidy
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -y install clang-tidy-14
|
||||
apt-get -y install clang-tidy-16
|
||||
- name: Prepare environment
|
||||
shell: bash
|
||||
env:
|
||||
|
|
|
@ -6,7 +6,7 @@ if [ -z "$(command -v "git-$name")" ]; then
|
|||
name="$(basename -a $(find $(echo "$PATH" | tr ':' ' ') -maxdepth 1 -type f -executable -name 'git-clang-format*') | sort | tail -n 1 | sed 's/^git-//')"
|
||||
fi
|
||||
|
||||
minVersion="14.0.0"
|
||||
minVersion="16.0.0"
|
||||
|
||||
for file in $(find $(echo "$PATH" | tr ':' ' ') -maxdepth 1 -type f -executable -name 'clang-format*'); do
|
||||
curBin="$file"
|
||||
|
@ -23,7 +23,7 @@ if [ -z "$name" ] || [ -z "$bin" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
args="--binary $bin -q --extensions cpp,h --style file --staged -- :!src/FreeRTOS :!src/libs"
|
||||
args="--binary $bin -q --extensions cpp,h --style file --staged -- src :!src/FreeRTOS :!src/libs"
|
||||
|
||||
changedFiles="$(git "$name" --diffstat $args)"
|
||||
git "$name" $args
|
||||
|
|
|
@ -81,8 +81,9 @@ int AlertNotificationClient::OnCharacteristicsDiscoveryEvent(uint16_t connection
|
|||
NRF_LOG_INFO("ANS Characteristic discovery complete");
|
||||
if (isCharacteristicDiscovered) {
|
||||
ble_gattc_disc_all_dscs(connectionHandle, newAlertHandle, ansEndHandle, OnAlertNotificationDescriptorDiscoveryEventCallback, this);
|
||||
} else
|
||||
} else {
|
||||
onServiceDiscovered(connectionHandle);
|
||||
}
|
||||
} else {
|
||||
if (characteristic != nullptr && ble_uuid_cmp(&supportedNewAlertCategoryUuid.u, &characteristic->uuid.u) == 0) {
|
||||
NRF_LOG_INFO("ANS Characteristic discovered : supportedNewAlertCategoryUuid");
|
||||
|
@ -101,9 +102,10 @@ int AlertNotificationClient::OnCharacteristicsDiscoveryEvent(uint16_t connection
|
|||
} else if (characteristic != nullptr && ble_uuid_cmp(&controlPointUuid.u, &characteristic->uuid.u) == 0) {
|
||||
NRF_LOG_INFO("ANS Characteristic discovered : controlPointUuid");
|
||||
controlPointHandle = characteristic->val_handle;
|
||||
} else
|
||||
} else {
|
||||
NRF_LOG_INFO("ANS Characteristic discovered : 0x%x", characteristic->val_handle);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -135,9 +137,10 @@ int AlertNotificationClient::OnDescriptorDiscoveryEventCallback(uint16_t connect
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (!isDescriptorFound)
|
||||
if (!isDescriptorFound) {
|
||||
onServiceDiscovered(connectionHandle);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -150,8 +153,9 @@ void AlertNotificationClient::OnNotification(ble_gap_event* event) {
|
|||
|
||||
// Ignore notifications with empty message
|
||||
const auto packetLen = OS_MBUF_PKTLEN(event->notify_rx.om);
|
||||
if (packetLen <= headerSize)
|
||||
if (packetLen <= headerSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t bufferSize = std::min(packetLen + stringTerminatorSize, maxBufferSize);
|
||||
auto messageSize = std::min(maxMessageSize, (bufferSize - headerSize));
|
||||
|
|
|
@ -87,20 +87,23 @@ int DfuService::OnServiceData(uint16_t connectionHandle, uint16_t attributeHandl
|
|||
ble_gatts_find_chr(&serviceUuid.u, &revisionCharacteristicUuid.u, nullptr, &revisionCharacteristicHandle);
|
||||
|
||||
if (attributeHandle == packetCharacteristicHandle) {
|
||||
if (context->op == BLE_GATT_ACCESS_OP_WRITE_CHR)
|
||||
if (context->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
|
||||
return WritePacketHandler(connectionHandle, context->om);
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (attributeHandle == controlPointCharacteristicHandle) {
|
||||
if (context->op == BLE_GATT_ACCESS_OP_WRITE_CHR)
|
||||
if (context->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
|
||||
return ControlPointHandler(connectionHandle, context->om);
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (attributeHandle == revisionCharacteristicHandle) {
|
||||
if (context->op == BLE_GATT_ACCESS_OP_READ_CHR)
|
||||
if (context->op == BLE_GATT_ACCESS_OP_READ_CHR) {
|
||||
return SendDfuRevision(context->om);
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
NRF_LOG_INFO("[DFU] Unknown Characteristic : %d", attributeHandle);
|
||||
return 0;
|
||||
|
@ -321,8 +324,9 @@ DfuService::NotificationManager::NotificationManager() {
|
|||
}
|
||||
|
||||
bool DfuService::NotificationManager::AsyncSend(uint16_t connection, uint16_t charactHandle, uint8_t* data, size_t s) {
|
||||
if (size != 0 || s > 10)
|
||||
if (size != 0 || s > 10) {
|
||||
return false;
|
||||
}
|
||||
|
||||
connectionHandle = connection;
|
||||
characteristicHandle = charactHandle;
|
||||
|
@ -353,8 +357,9 @@ void DfuService::NotificationManager::Reset() {
|
|||
}
|
||||
|
||||
void DfuService::DfuImage::Init(size_t chunkSize, size_t totalSize, uint16_t expectedCrc) {
|
||||
if (chunkSize != 20)
|
||||
if (chunkSize != 20) {
|
||||
return;
|
||||
}
|
||||
this->chunkSize = chunkSize;
|
||||
this->totalSize = totalSize;
|
||||
this->expectedCrc = expectedCrc;
|
||||
|
@ -364,8 +369,9 @@ void DfuService::DfuImage::Init(size_t chunkSize, size_t totalSize, uint16_t exp
|
|||
}
|
||||
|
||||
void DfuService::DfuImage::Append(uint8_t* data, size_t size) {
|
||||
if (!ready)
|
||||
if (!ready) {
|
||||
return;
|
||||
}
|
||||
ASSERT(size <= 20);
|
||||
|
||||
std::memcpy(tempBuffer + bufferWriteIndex, data, size);
|
||||
|
@ -380,10 +386,11 @@ void DfuService::DfuImage::Append(uint8_t* data, size_t size) {
|
|||
if (bufferWriteIndex > 0 && totalWriteIndex + bufferWriteIndex == totalSize) {
|
||||
spiNorFlash.Write(writeOffset + totalWriteIndex, tempBuffer, bufferWriteIndex);
|
||||
totalWriteIndex += bufferWriteIndex;
|
||||
if (totalSize < maxSize)
|
||||
if (totalSize < maxSize) {
|
||||
WriteMagicNumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DfuService::DfuImage::WriteMagicNumber() {
|
||||
uint32_t magic[4] = {
|
||||
|
@ -417,8 +424,9 @@ bool DfuService::DfuImage::Validate() {
|
|||
if (first) {
|
||||
crc = ComputeCrc(tempBuffer, readSize, NULL);
|
||||
first = false;
|
||||
} else
|
||||
} else {
|
||||
crc = ComputeCrc(tempBuffer, readSize, &crc);
|
||||
}
|
||||
currentOffset += readSize;
|
||||
}
|
||||
|
||||
|
@ -440,7 +448,8 @@ uint16_t DfuService::DfuImage::ComputeCrc(uint8_t const* p_data, uint32_t size,
|
|||
}
|
||||
|
||||
bool DfuService::DfuImage::IsComplete() {
|
||||
if (!ready)
|
||||
if (!ready) {
|
||||
return false;
|
||||
}
|
||||
return totalWriteIndex == totalSize;
|
||||
}
|
||||
|
|
|
@ -57,8 +57,9 @@ int HeartRateService::OnHeartRateRequested(uint16_t attributeHandle, ble_gatt_ac
|
|||
}
|
||||
|
||||
void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) {
|
||||
if (!heartRateMeasurementNotificationEnable)
|
||||
if (!heartRateMeasurementNotificationEnable) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t buffer[2] = {0, heartRateValue}; // [0] = flags, [1] = hr value
|
||||
auto* om = ble_hs_mbuf_from_flat(buffer, 2);
|
||||
|
@ -73,11 +74,13 @@ void HeartRateService::OnNewHeartRateValue(uint8_t heartRateValue) {
|
|||
}
|
||||
|
||||
void HeartRateService::SubscribeNotification(uint16_t attributeHandle) {
|
||||
if (attributeHandle == heartRateMeasurementHandle)
|
||||
if (attributeHandle == heartRateMeasurementHandle) {
|
||||
heartRateMeasurementNotificationEnable = true;
|
||||
}
|
||||
}
|
||||
|
||||
void HeartRateService::UnsubscribeNotification(uint16_t attributeHandle) {
|
||||
if (attributeHandle == heartRateMeasurementHandle)
|
||||
if (attributeHandle == heartRateMeasurementHandle) {
|
||||
heartRateMeasurementNotificationEnable = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,8 +76,9 @@ int MotionService::OnStepCountRequested(uint16_t attributeHandle, ble_gatt_acces
|
|||
}
|
||||
|
||||
void MotionService::OnNewStepCountValue(uint32_t stepCount) {
|
||||
if (!stepCountNoficationEnabled)
|
||||
if (!stepCountNoficationEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t buffer = stepCount;
|
||||
auto* om = ble_hs_mbuf_from_flat(&buffer, 4);
|
||||
|
@ -92,8 +93,9 @@ void MotionService::OnNewStepCountValue(uint32_t stepCount) {
|
|||
}
|
||||
|
||||
void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
|
||||
if (!motionValuesNoficationEnabled)
|
||||
if (!motionValuesNoficationEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t buffer[3] = {x, y, z};
|
||||
auto* om = ble_hs_mbuf_from_flat(buffer, 3 * sizeof(int16_t));
|
||||
|
@ -108,18 +110,20 @@ void MotionService::OnNewMotionValues(int16_t x, int16_t y, int16_t z) {
|
|||
}
|
||||
|
||||
void MotionService::SubscribeNotification(uint16_t attributeHandle) {
|
||||
if (attributeHandle == stepCountHandle)
|
||||
if (attributeHandle == stepCountHandle) {
|
||||
stepCountNoficationEnabled = true;
|
||||
else if (attributeHandle == motionValuesHandle)
|
||||
} else if (attributeHandle == motionValuesHandle) {
|
||||
motionValuesNoficationEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MotionService::UnsubscribeNotification(uint16_t attributeHandle) {
|
||||
if (attributeHandle == stepCountHandle)
|
||||
if (attributeHandle == stepCountHandle) {
|
||||
stepCountNoficationEnabled = false;
|
||||
else if (attributeHandle == motionValuesHandle)
|
||||
} else if (attributeHandle == motionValuesHandle) {
|
||||
motionValuesNoficationEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool MotionService::IsMotionNotificationSubscribed() const {
|
||||
return motionValuesNoficationEnabled;
|
||||
|
|
|
@ -57,26 +57,26 @@ namespace Pinetime {
|
|||
|
||||
Pinetime::Controllers::MusicService& music() {
|
||||
return musicService;
|
||||
};
|
||||
}
|
||||
|
||||
Pinetime::Controllers::NavigationService& navigation() {
|
||||
return navService;
|
||||
};
|
||||
}
|
||||
|
||||
Pinetime::Controllers::AlertNotificationService& alertService() {
|
||||
return anService;
|
||||
};
|
||||
}
|
||||
|
||||
Pinetime::Controllers::SimpleWeatherService& weather() {
|
||||
return weatherService;
|
||||
};
|
||||
}
|
||||
|
||||
uint16_t connHandle();
|
||||
void NotifyBatteryLevel(uint8_t level);
|
||||
|
||||
void RestartFastAdv() {
|
||||
fastAdvCount = 0;
|
||||
};
|
||||
}
|
||||
|
||||
void EnableRadio();
|
||||
void DisableRadio();
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace Pinetime {
|
|||
|
||||
static constexpr size_t MaximumMessageSize() {
|
||||
return MessageSize;
|
||||
};
|
||||
}
|
||||
|
||||
bool IsEmpty() const {
|
||||
return size == 0;
|
||||
|
|
|
@ -114,8 +114,9 @@ void DateTime::UpdateTime(uint32_t systickCounter, bool forceUpdate) {
|
|||
// Notify new day to SystemTask
|
||||
if (hour == 0 and not isMidnightAlreadyNotified) {
|
||||
isMidnightAlreadyNotified = true;
|
||||
if (systemTask != nullptr)
|
||||
if (systemTask != nullptr) {
|
||||
systemTask->PushMessage(System::Messages::OnNewDay);
|
||||
}
|
||||
} else if (hour != 0) {
|
||||
isMidnightAlreadyNotified = false;
|
||||
}
|
||||
|
|
|
@ -11,9 +11,10 @@ bool FirmwareValidator::IsValidated() const {
|
|||
}
|
||||
|
||||
void FirmwareValidator::Validate() {
|
||||
if (!IsValidated())
|
||||
if (!IsValidated()) {
|
||||
Pinetime::Drivers::InternalFlash::WriteWord(validBitAdress, validBitValue);
|
||||
}
|
||||
}
|
||||
|
||||
void FirmwareValidator::Reset() {
|
||||
NVIC_SystemReset();
|
||||
|
|
|
@ -276,10 +276,12 @@ float Ppg::HeartRateAverage(float hr) {
|
|||
for (const float& value : dataAverage) {
|
||||
if (value > 0.0f) {
|
||||
avg += value;
|
||||
if (value < min)
|
||||
if (value < min) {
|
||||
min = value;
|
||||
if (value > max)
|
||||
}
|
||||
if (value > max) {
|
||||
max = value;
|
||||
}
|
||||
total++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,10 @@ void RleDecoder::DecodeNext(uint8_t* output, size_t maxBytes) {
|
|||
}
|
||||
processedCount = 0;
|
||||
|
||||
if (color == backgroundColor)
|
||||
if (color == backgroundColor) {
|
||||
color = foregroundColor;
|
||||
else
|
||||
} else {
|
||||
color = backgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,158 +65,163 @@ namespace Pinetime {
|
|||
settingsChanged = true;
|
||||
}
|
||||
settings.watchFace = face;
|
||||
};
|
||||
}
|
||||
|
||||
Pinetime::Applications::WatchFace GetWatchFace() const {
|
||||
return settings.watchFace;
|
||||
};
|
||||
}
|
||||
|
||||
void SetChimeOption(ChimesOption chimeOption) {
|
||||
if (chimeOption != settings.chimesOption) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.chimesOption = chimeOption;
|
||||
};
|
||||
}
|
||||
|
||||
ChimesOption GetChimeOption() const {
|
||||
return settings.chimesOption;
|
||||
};
|
||||
}
|
||||
|
||||
void SetPTSColorTime(Colors colorTime) {
|
||||
if (colorTime != settings.PTS.ColorTime)
|
||||
if (colorTime != settings.PTS.ColorTime) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.PTS.ColorTime = colorTime;
|
||||
};
|
||||
}
|
||||
|
||||
Colors GetPTSColorTime() const {
|
||||
return settings.PTS.ColorTime;
|
||||
};
|
||||
}
|
||||
|
||||
void SetPTSColorBar(Colors colorBar) {
|
||||
if (colorBar != settings.PTS.ColorBar)
|
||||
if (colorBar != settings.PTS.ColorBar) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.PTS.ColorBar = colorBar;
|
||||
};
|
||||
}
|
||||
|
||||
Colors GetPTSColorBar() const {
|
||||
return settings.PTS.ColorBar;
|
||||
};
|
||||
}
|
||||
|
||||
void SetPTSColorBG(Colors colorBG) {
|
||||
if (colorBG != settings.PTS.ColorBG)
|
||||
if (colorBG != settings.PTS.ColorBG) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.PTS.ColorBG = colorBG;
|
||||
};
|
||||
}
|
||||
|
||||
Colors GetPTSColorBG() const {
|
||||
return settings.PTS.ColorBG;
|
||||
};
|
||||
}
|
||||
|
||||
void SetInfineatShowSideCover(bool show) {
|
||||
if (show != settings.watchFaceInfineat.showSideCover) {
|
||||
settings.watchFaceInfineat.showSideCover = show;
|
||||
settingsChanged = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool GetInfineatShowSideCover() const {
|
||||
return settings.watchFaceInfineat.showSideCover;
|
||||
};
|
||||
}
|
||||
|
||||
void SetInfineatColorIndex(int index) {
|
||||
if (index != settings.watchFaceInfineat.colorIndex) {
|
||||
settings.watchFaceInfineat.colorIndex = index;
|
||||
settingsChanged = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int GetInfineatColorIndex() const {
|
||||
return settings.watchFaceInfineat.colorIndex;
|
||||
};
|
||||
}
|
||||
|
||||
void SetPTSGaugeStyle(PTSGaugeStyle gaugeStyle) {
|
||||
if (gaugeStyle != settings.PTS.gaugeStyle)
|
||||
if (gaugeStyle != settings.PTS.gaugeStyle) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.PTS.gaugeStyle = gaugeStyle;
|
||||
};
|
||||
}
|
||||
|
||||
PTSGaugeStyle GetPTSGaugeStyle() const {
|
||||
return settings.PTS.gaugeStyle;
|
||||
};
|
||||
}
|
||||
|
||||
void SetPTSWeather(PTSWeather weatherEnable) {
|
||||
if (weatherEnable != settings.PTS.weatherEnable)
|
||||
if (weatherEnable != settings.PTS.weatherEnable) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.PTS.weatherEnable = weatherEnable;
|
||||
};
|
||||
}
|
||||
|
||||
PTSWeather GetPTSWeather() const {
|
||||
return settings.PTS.weatherEnable;
|
||||
};
|
||||
}
|
||||
|
||||
void SetAppMenu(uint8_t menu) {
|
||||
appMenu = menu;
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t GetAppMenu() const {
|
||||
return appMenu;
|
||||
};
|
||||
}
|
||||
|
||||
void SetSettingsMenu(uint8_t menu) {
|
||||
settingsMenu = menu;
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t GetSettingsMenu() const {
|
||||
return settingsMenu;
|
||||
};
|
||||
}
|
||||
|
||||
void SetClockType(ClockType clocktype) {
|
||||
if (clocktype != settings.clockType) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.clockType = clocktype;
|
||||
};
|
||||
}
|
||||
|
||||
ClockType GetClockType() const {
|
||||
return settings.clockType;
|
||||
};
|
||||
}
|
||||
|
||||
void SetWeatherFormat(WeatherFormat weatherFormat) {
|
||||
if (weatherFormat != settings.weatherFormat) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.weatherFormat = weatherFormat;
|
||||
};
|
||||
}
|
||||
|
||||
WeatherFormat GetWeatherFormat() const {
|
||||
return settings.weatherFormat;
|
||||
};
|
||||
}
|
||||
|
||||
void SetNotificationStatus(Notification status) {
|
||||
if (status != settings.notificationStatus) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.notificationStatus = status;
|
||||
};
|
||||
}
|
||||
|
||||
Notification GetNotificationStatus() const {
|
||||
return settings.notificationStatus;
|
||||
};
|
||||
}
|
||||
|
||||
void SetScreenTimeOut(uint32_t timeout) {
|
||||
if (timeout != settings.screenTimeOut) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.screenTimeOut = timeout;
|
||||
};
|
||||
}
|
||||
|
||||
uint32_t GetScreenTimeOut() const {
|
||||
return settings.screenTimeOut;
|
||||
};
|
||||
}
|
||||
|
||||
bool GetAlwaysOnDisplay() const {
|
||||
return settings.alwaysOnDisplay && GetNotificationStatus() != Notification::Sleep;
|
||||
};
|
||||
}
|
||||
|
||||
void SetAlwaysOnDisplaySetting(bool state) {
|
||||
if (state != settings.alwaysOnDisplay) {
|
||||
|
@ -258,7 +263,7 @@ namespace Pinetime {
|
|||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
std::bitset<5> getWakeUpModes() const {
|
||||
return settings.wakeUpMode;
|
||||
|
@ -273,30 +278,30 @@ namespace Pinetime {
|
|||
settingsChanged = true;
|
||||
}
|
||||
settings.brightLevel = level;
|
||||
};
|
||||
}
|
||||
|
||||
Controllers::BrightnessController::Levels GetBrightness() const {
|
||||
return settings.brightLevel;
|
||||
};
|
||||
}
|
||||
|
||||
void SetStepsGoal(uint32_t goal) {
|
||||
if (goal != settings.stepsGoal) {
|
||||
settingsChanged = true;
|
||||
}
|
||||
settings.stepsGoal = goal;
|
||||
};
|
||||
}
|
||||
|
||||
uint32_t GetStepsGoal() const {
|
||||
return settings.stepsGoal;
|
||||
};
|
||||
}
|
||||
|
||||
void SetBleRadioEnabled(bool enabled) {
|
||||
bleRadioEnabled = enabled;
|
||||
};
|
||||
}
|
||||
|
||||
bool GetBleRadioEnabled() const {
|
||||
return bleRadioEnabled;
|
||||
};
|
||||
}
|
||||
|
||||
private:
|
||||
Pinetime::Controllers::FS& fs;
|
||||
|
|
|
@ -513,9 +513,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
|||
std::find_if(userWatchFaces.begin(), userWatchFaces.end(), [this](const WatchFaceDescription& watchfaceDescription) {
|
||||
return watchfaceDescription.watchFace == settingsController.GetWatchFace();
|
||||
});
|
||||
if (watchFace != userWatchFaces.end())
|
||||
if (watchFace != userWatchFaces.end()) {
|
||||
currentScreen.reset(watchFace->create(controllers));
|
||||
else {
|
||||
} else {
|
||||
currentScreen.reset(userWatchFaces[0].create(controllers));
|
||||
}
|
||||
settingsController.SetAppMenu(0);
|
||||
|
|
|
@ -31,9 +31,10 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
|||
|
||||
void DisplayApp::Start() {
|
||||
msgQueue = xQueueCreate(queueSize, itemSize);
|
||||
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 512, this, 0, &taskHandle))
|
||||
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 512, this, 0, &taskHandle)) {
|
||||
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayApp::Process(void* instance) {
|
||||
auto* app = static_cast<DisplayApp*>(instance);
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace Pinetime {
|
|||
|
||||
void Start(Pinetime::System::BootErrors) {
|
||||
Start();
|
||||
};
|
||||
}
|
||||
|
||||
void PushMessage(Pinetime::Applications::Display::Messages msg);
|
||||
void Register(Pinetime::System::SystemTask* systemTask);
|
||||
|
|
|
@ -176,9 +176,9 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
|
|||
toScroll = height;
|
||||
}
|
||||
|
||||
if (scrollOffset >= toScroll)
|
||||
if (scrollOffset >= toScroll) {
|
||||
scrollOffset -= toScroll;
|
||||
else {
|
||||
} else {
|
||||
toScroll -= scrollOffset;
|
||||
scrollOffset = (totalNbLines) -toScroll;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace Pinetime {
|
|||
controllers.settingsController.GetClockType(),
|
||||
*controllers.systemTask,
|
||||
controllers.motorController);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,9 @@ void BatteryIcon::SetColor(lv_color_t color) {
|
|||
}
|
||||
|
||||
const char* BatteryIcon::GetPlugIcon(bool isCharging) {
|
||||
if (isCharging)
|
||||
if (isCharging) {
|
||||
return Symbols::plug;
|
||||
else
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,9 +150,10 @@ void Dice::Refresh() {
|
|||
|
||||
Roll();
|
||||
}
|
||||
} else if (currentRollHysteresis > 0)
|
||||
} else if (currentRollHysteresis > 0) {
|
||||
--currentRollHysteresis;
|
||||
}
|
||||
}
|
||||
|
||||
void Dice::Roll() {
|
||||
uint8_t resultIndividual;
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::Dice(controllers.motionController, controllers.motorController, controllers.settingsController);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::HeartRate(controllers.heartRateController, *controllers.systemTask);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::InfiniPaint(controllers.lvgl, controllers.motorController);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::Metronome(controllers.motorController, *controllers.systemTask);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::Motion(controllers.motionController);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::Music(*controllers.musicService);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::Navigation(*controllers.navigationService);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
const char* NotificationIcon::GetIcon(bool newNotificationAvailable) {
|
||||
if (newNotificationAvailable)
|
||||
if (newNotificationAvailable) {
|
||||
return Symbols::info;
|
||||
else
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::Paddle(controllers.lvgl);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::Steps(controllers.motionController, controllers.settingsController);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::StopWatch(*controllers.systemTask);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
|
|||
|
||||
extern int mallocFailedCount;
|
||||
extern int stackOverflowCount;
|
||||
|
||||
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
|
||||
lv_mem_monitor_t mon;
|
||||
lv_mem_monitor(&mon);
|
||||
|
|
|
@ -56,6 +56,6 @@ namespace Pinetime::Applications {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::Timer(controllers.timer);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& /*controllers*/) {
|
||||
return new Screens::Twos();
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace Pinetime {
|
|||
controllers.bleController,
|
||||
controllers.notificationManager,
|
||||
controllers.settingsController);
|
||||
};
|
||||
}
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||
return true;
|
||||
|
|
|
@ -116,7 +116,7 @@ namespace Pinetime {
|
|||
controllers.heartRateController,
|
||||
controllers.motionController,
|
||||
controllers.filesystem);
|
||||
};
|
||||
}
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
return Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem);
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace Pinetime {
|
|||
controllers.heartRateController,
|
||||
controllers.motionController,
|
||||
*controllers.weatherController);
|
||||
};
|
||||
}
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||
return true;
|
||||
|
|
|
@ -374,8 +374,9 @@ void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
|||
}
|
||||
if (object == btnPrevColor) {
|
||||
colorIndex -= 1;
|
||||
if (colorIndex < 0)
|
||||
if (colorIndex < 0) {
|
||||
colorIndex = nColors - 1;
|
||||
}
|
||||
settingsController.SetInfineatColorIndex(colorIndex);
|
||||
}
|
||||
if (object == btnNextColor || object == btnPrevColor) {
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace Pinetime {
|
|||
controllers.settingsController,
|
||||
controllers.motionController,
|
||||
controllers.filesystem);
|
||||
};
|
||||
}
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
return Screens::WatchFaceInfineat::IsAvailable(filesystem);
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace Pinetime {
|
|||
controllers.settingsController,
|
||||
controllers.motionController,
|
||||
*controllers.weatherController);
|
||||
};
|
||||
}
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||
return true;
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace Pinetime {
|
|||
controllers.settingsController,
|
||||
controllers.heartRateController,
|
||||
controllers.motionController);
|
||||
};
|
||||
}
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||
return true;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Pinetime {
|
|||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::Weather(controllers.settingsController, *controllers.weatherController);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace {
|
|||
}
|
||||
}
|
||||
return optionArray;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
|
||||
|
|
|
@ -42,7 +42,7 @@ void Counter::UpBtnPressed() {
|
|||
if (ValueChangedHandler != nullptr) {
|
||||
ValueChangedHandler(userData);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void Counter::DownBtnPressed() {
|
||||
value--;
|
||||
|
@ -54,7 +54,7 @@ void Counter::DownBtnPressed() {
|
|||
if (ValueChangedHandler != nullptr) {
|
||||
ValueChangedHandler(userData);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void Counter::SetValue(int newValue) {
|
||||
value = newValue;
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Pinetime {
|
|||
|
||||
lv_obj_t* GetObject() const {
|
||||
return counterContainer;
|
||||
};
|
||||
}
|
||||
|
||||
private:
|
||||
void UpdateLabel();
|
||||
|
|
|
@ -45,12 +45,14 @@ Bma421::Bma421(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaster}
|
|||
}
|
||||
|
||||
void Bma421::Init() {
|
||||
if (not isResetOk)
|
||||
if (not isResetOk) {
|
||||
return; // Call SoftReset (and reset TWI device) first!
|
||||
}
|
||||
|
||||
auto ret = bma423_init(&bma);
|
||||
if (ret != BMA4_OK)
|
||||
if (ret != BMA4_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (bma.chip_id) {
|
||||
case BMA423_CHIP_ID:
|
||||
|
@ -65,32 +67,38 @@ void Bma421::Init() {
|
|||
}
|
||||
|
||||
ret = bma423_write_config_file(&bma);
|
||||
if (ret != BMA4_OK)
|
||||
if (ret != BMA4_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = bma4_set_interrupt_mode(BMA4_LATCH_MODE, &bma);
|
||||
if (ret != BMA4_OK)
|
||||
if (ret != BMA4_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = bma423_feature_enable(BMA423_STEP_CNTR, 1, &bma);
|
||||
if (ret != BMA4_OK)
|
||||
if (ret != BMA4_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = bma423_step_detector_enable(0, &bma);
|
||||
if (ret != BMA4_OK)
|
||||
if (ret != BMA4_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = bma4_set_accel_enable(1, &bma);
|
||||
if (ret != BMA4_OK)
|
||||
if (ret != BMA4_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
accel_conf.odr = BMA4_OUTPUT_DATA_RATE_100HZ;
|
||||
accel_conf.range = BMA4_ACCEL_RANGE_2G;
|
||||
accel_conf.bandwidth = BMA4_ACCEL_NORMAL_AVG4;
|
||||
accel_conf.perf_mode = BMA4_CIC_AVG_MODE;
|
||||
ret = bma4_set_accel_config(&accel_conf, &bma);
|
||||
if (ret != BMA4_OK)
|
||||
if (ret != BMA4_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
isOk = true;
|
||||
}
|
||||
|
@ -109,8 +117,9 @@ void Bma421::Write(uint8_t registerAddress, const uint8_t* data, size_t size) {
|
|||
}
|
||||
|
||||
Bma421::Values Bma421::Process() {
|
||||
if (not isOk)
|
||||
if (not isOk) {
|
||||
return {};
|
||||
}
|
||||
struct bma4_accel rawData;
|
||||
struct bma4_accel data;
|
||||
bma4_read_accel_xyz(&rawData, &bma);
|
||||
|
|
|
@ -1607,10 +1607,7 @@ int8_t bma4_get_offset_comp(uint8_t *offset_en, struct bma4_dev *dev);
|
|||
* @retval < 0 -> Fail
|
||||
*
|
||||
*/
|
||||
int8_t bma4_extract_accel(struct bma4_accel *accel_data,
|
||||
uint16_t *accel_length,
|
||||
struct bma4_fifo_frame *fifo,
|
||||
const struct bma4_dev *dev);
|
||||
int8_t bma4_extract_accel(struct bma4_accel* accel_data, uint16_t* accel_length, struct bma4_fifo_frame* fifo, const struct bma4_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bma4
|
||||
|
@ -1650,10 +1647,7 @@ int8_t bma4_extract_accel(struct bma4_accel *accel_data,
|
|||
* @retval < 0 -> Fail
|
||||
*
|
||||
*/
|
||||
int8_t bma4_extract_mag(const struct bma4_mag *mag_data,
|
||||
uint16_t *mag_length,
|
||||
struct bma4_fifo_frame *fifo,
|
||||
const struct bma4_dev *dev);
|
||||
int8_t bma4_extract_mag(const struct bma4_mag* mag_data, uint16_t* mag_length, struct bma4_fifo_frame* fifo, const struct bma4_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bma4
|
||||
|
@ -2039,8 +2033,7 @@ int8_t bma4_get_fifo_config(uint8_t *fifo_config, struct bma4_dev *dev);
|
|||
* @retval 0 -> Success
|
||||
* @retval < 0 -> Fail
|
||||
*/
|
||||
int8_t bma4_set_int_pin_config(const struct bma4_int_pin_config *int_pin_config, uint8_t int_line,
|
||||
struct bma4_dev *dev);
|
||||
int8_t bma4_set_int_pin_config(const struct bma4_int_pin_config* int_pin_config, uint8_t int_line, struct bma4_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bma4ApiIntConfig
|
||||
|
|
|
@ -184,8 +184,7 @@ extern "C" {
|
|||
/*!
|
||||
* @brief Any/No motion configuration
|
||||
*/
|
||||
struct bma423_any_no_mot_config
|
||||
{
|
||||
struct bma423_any_no_mot_config {
|
||||
/*! Expressed in 50 Hz samples (20 ms) */
|
||||
uint16_t duration;
|
||||
|
||||
|
@ -201,8 +200,7 @@ struct bma423_any_no_mot_config
|
|||
/*!
|
||||
* @brief Axes re-mapping configuration
|
||||
*/
|
||||
struct bma423_axes_remap
|
||||
{
|
||||
struct bma423_axes_remap {
|
||||
/*! Re-mapped x-axis */
|
||||
uint8_t x_axis;
|
||||
|
||||
|
@ -225,8 +223,7 @@ struct bma423_axes_remap
|
|||
/*!
|
||||
* @brief Step counter param settings
|
||||
*/
|
||||
struct bma423_stepcounter_settings
|
||||
{
|
||||
struct bma423_stepcounter_settings {
|
||||
/*! Step Counter param 1 */
|
||||
uint16_t param1;
|
||||
|
||||
|
|
|
@ -644,12 +644,9 @@
|
|||
#endif
|
||||
|
||||
/**\name BIT SLICE GET AND SET FUNCTIONS */
|
||||
#define BMA4_GET_BITSLICE(regvar, bitname) \
|
||||
((regvar & bitname##_MSK) >> bitname##_POS)
|
||||
#define BMA4_GET_BITSLICE(regvar, bitname) ((regvar & bitname##_MSK) >> bitname##_POS)
|
||||
|
||||
#define BMA4_SET_BITSLICE(regvar, bitname, val) \
|
||||
((regvar & ~bitname##_MSK) | \
|
||||
((val << bitname##_POS) & bitname##_MSK))
|
||||
#define BMA4_SET_BITSLICE(regvar, bitname, val) ((regvar & ~bitname##_MSK) | ((val << bitname##_POS) & bitname##_MSK))
|
||||
|
||||
#define BMA4_GET_DIFF(x, y) ((x) - (y))
|
||||
|
||||
|
@ -658,9 +655,7 @@
|
|||
|
||||
#define BMA4_SET_BIT_VAL_0(reg_data, bitname) (reg_data & ~(bitname##_MSK))
|
||||
|
||||
#define BMA4_SET_BITS_POS_0(reg_data, bitname, data) \
|
||||
((reg_data & ~(bitname##_MSK)) | \
|
||||
(data & bitname##_MSK))
|
||||
#define BMA4_SET_BITS_POS_0(reg_data, bitname, data) ((reg_data & ~(bitname##_MSK)) | (data & bitname##_MSK))
|
||||
|
||||
#define BMA4_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
|
||||
|
||||
|
@ -716,8 +711,7 @@ typedef BMA4_INTF_RET_TYPE (*bma4_read_fptr_t)(uint8_t reg_addr, uint8_t *read_d
|
|||
* @retval != BMA4_INTF_RET_SUCCESS -> Failure Info
|
||||
*
|
||||
*/
|
||||
typedef BMA4_INTF_RET_TYPE (*bma4_write_fptr_t)(uint8_t reg_addr, const uint8_t *read_data, uint32_t len,
|
||||
void *intf_ptr);
|
||||
typedef BMA4_INTF_RET_TYPE (*bma4_write_fptr_t)(uint8_t reg_addr, const uint8_t* read_data, uint32_t len, void* intf_ptr);
|
||||
|
||||
/*!
|
||||
* @brief Delay function pointer which should be mapped to
|
||||
|
@ -734,17 +728,10 @@ typedef void (*bma4_delay_us_fptr_t)(uint32_t period, void *intf_ptr);
|
|||
/*! @name Enum Declarations */
|
||||
/******************************************************************************/
|
||||
/*! @name Enum to define BMA4 variants */
|
||||
enum bma4_variant {
|
||||
BMA42X_VARIANT = 1,
|
||||
BMA42X_B_VARIANT,
|
||||
BMA45X_VARIANT
|
||||
};
|
||||
enum bma4_variant { BMA42X_VARIANT = 1, BMA42X_B_VARIANT, BMA45X_VARIANT };
|
||||
|
||||
/* Enumerator describing interfaces */
|
||||
enum bma4_intf {
|
||||
BMA4_SPI_INTF,
|
||||
BMA4_I2C_INTF
|
||||
};
|
||||
enum bma4_intf { BMA4_SPI_INTF, BMA4_I2C_INTF };
|
||||
|
||||
/**\name STRUCTURE DEFINITIONS*/
|
||||
|
||||
|
@ -752,8 +739,7 @@ enum bma4_intf {
|
|||
* @brief
|
||||
* This structure holds asic info. for feature configuration.
|
||||
*/
|
||||
struct bma4_asic_data
|
||||
{
|
||||
struct bma4_asic_data {
|
||||
/* Feature config start addr (0-3 bits)*/
|
||||
uint8_t asic_lsb;
|
||||
|
||||
|
@ -764,8 +750,7 @@ struct bma4_asic_data
|
|||
/*!
|
||||
* @brief Auxiliary configuration structure for user settings
|
||||
*/
|
||||
struct bma4_aux_config
|
||||
{
|
||||
struct bma4_aux_config {
|
||||
/*! Device address of auxiliary sensor */
|
||||
uint8_t aux_dev_addr;
|
||||
|
||||
|
@ -783,8 +768,7 @@ struct bma4_aux_config
|
|||
* @brief
|
||||
* This structure holds all relevant information about BMA4
|
||||
*/
|
||||
struct bma4_dev
|
||||
{
|
||||
struct bma4_dev {
|
||||
/*! Chip id of BMA4 */
|
||||
uint8_t chip_id;
|
||||
|
||||
|
@ -851,8 +835,7 @@ struct bma4_dev
|
|||
* @brief This structure holds the information for usage of
|
||||
* FIFO by the user.
|
||||
*/
|
||||
struct bma4_fifo_frame
|
||||
{
|
||||
struct bma4_fifo_frame {
|
||||
/*! Data buffer of user defined length is to be mapped here */
|
||||
uint8_t* data;
|
||||
|
||||
|
@ -892,8 +875,7 @@ struct bma4_fifo_frame
|
|||
/*!
|
||||
* @brief Error Status structure
|
||||
*/
|
||||
struct bma4_err_reg
|
||||
{
|
||||
struct bma4_err_reg {
|
||||
/*! Indicates fatal error */
|
||||
uint8_t fatal_err;
|
||||
|
||||
|
@ -913,8 +895,7 @@ struct bma4_err_reg
|
|||
/*!
|
||||
* @brief Asic Status structure
|
||||
*/
|
||||
struct bma4_asic_status
|
||||
{
|
||||
struct bma4_asic_status {
|
||||
/*! Asic is in sleep/halt state */
|
||||
uint8_t sleep;
|
||||
|
||||
|
@ -933,8 +914,7 @@ struct bma4_asic_status
|
|||
/*!
|
||||
* @brief Interrupt Pin Configuration structure
|
||||
*/
|
||||
struct bma4_int_pin_config
|
||||
{
|
||||
struct bma4_int_pin_config {
|
||||
/*! Trigger condition of interrupt pin */
|
||||
uint8_t edge_ctrl;
|
||||
|
||||
|
@ -954,8 +934,7 @@ struct bma4_int_pin_config
|
|||
/*!
|
||||
* @brief Accelerometer configuration structure
|
||||
*/
|
||||
struct bma4_accel_config
|
||||
{
|
||||
struct bma4_accel_config {
|
||||
/*! Output data rate in Hz */
|
||||
uint8_t odr;
|
||||
|
||||
|
@ -972,8 +951,7 @@ struct bma4_accel_config
|
|||
/*!
|
||||
* @brief Auxiliary magnetometer configuration structure
|
||||
*/
|
||||
struct bma4_aux_mag_config
|
||||
{
|
||||
struct bma4_aux_mag_config {
|
||||
/*! Poll rate for the sensor attached to the Magnetometer interface */
|
||||
uint8_t odr;
|
||||
|
||||
|
@ -987,8 +965,7 @@ struct bma4_aux_mag_config
|
|||
/*!
|
||||
* @brief ASIC Config structure
|
||||
*/
|
||||
struct bma4_asic_config
|
||||
{
|
||||
struct bma4_asic_config {
|
||||
/*! Enable/Disable ASIC Wake Up */
|
||||
uint8_t asic_en;
|
||||
|
||||
|
@ -1009,8 +986,7 @@ struct bma4_asic_config
|
|||
* @brief bmm150 or akm09916
|
||||
* magnetometer values structure
|
||||
*/
|
||||
struct bma4_mag
|
||||
{
|
||||
struct bma4_mag {
|
||||
/*! BMM150 and AKM09916 X raw data */
|
||||
int32_t x;
|
||||
|
||||
|
@ -1024,8 +1000,7 @@ struct bma4_mag
|
|||
/*!
|
||||
* @brief bmm150 xyz data structure
|
||||
*/
|
||||
struct bma4_mag_xyzr
|
||||
{
|
||||
struct bma4_mag_xyzr {
|
||||
/*! BMM150 X raw data */
|
||||
int16_t x;
|
||||
|
||||
|
@ -1042,8 +1017,7 @@ struct bma4_mag_xyzr
|
|||
/*!
|
||||
* @brief Accel xyz data structure
|
||||
*/
|
||||
struct bma4_accel
|
||||
{
|
||||
struct bma4_accel {
|
||||
/*! Accel X data */
|
||||
int16_t x;
|
||||
|
||||
|
@ -1057,8 +1031,7 @@ struct bma4_accel
|
|||
/*!
|
||||
* @brief FIFO mag data structure
|
||||
*/
|
||||
struct bma4_mag_fifo_data
|
||||
{
|
||||
struct bma4_mag_fifo_data {
|
||||
/*! The value of mag x LSB data */
|
||||
uint8_t mag_x_lsb;
|
||||
|
||||
|
@ -1087,8 +1060,7 @@ struct bma4_mag_fifo_data
|
|||
/*!
|
||||
* @brief Accel self test difference data structure
|
||||
*/
|
||||
struct bma4_selftest_delta_limit
|
||||
{
|
||||
struct bma4_selftest_delta_limit {
|
||||
/*! Accel X data */
|
||||
int32_t x;
|
||||
|
||||
|
@ -1100,8 +1072,7 @@ struct bma4_selftest_delta_limit
|
|||
};
|
||||
|
||||
/*! @name Structure to enable an accel axis for FOC */
|
||||
struct bma4_accel_foc_g_value
|
||||
{
|
||||
struct bma4_accel_foc_g_value {
|
||||
/* '0' to disable x-axis and '1' to enable x-axis */
|
||||
uint8_t x;
|
||||
|
||||
|
@ -1116,8 +1087,7 @@ struct bma4_accel_foc_g_value
|
|||
};
|
||||
|
||||
/*! @name Structure to store temporary accelerometer values */
|
||||
struct bma4_foc_temp_value
|
||||
{
|
||||
struct bma4_foc_temp_value {
|
||||
/*! X data */
|
||||
int32_t x;
|
||||
|
||||
|
@ -1129,8 +1099,7 @@ struct bma4_foc_temp_value
|
|||
};
|
||||
|
||||
/* Structure to store temporary axes data values */
|
||||
struct bma4_temp_axes_val
|
||||
{
|
||||
struct bma4_temp_axes_val {
|
||||
/* X data */
|
||||
int32_t x;
|
||||
|
||||
|
|
|
@ -103,14 +103,16 @@ Hrs3300::PackedHrsAls Hrs3300::ReadHrsAls() {
|
|||
|
||||
void Hrs3300::WriteRegister(uint8_t reg, uint8_t data) {
|
||||
auto ret = twiMaster.Write(twiAddress, reg, &data, 1);
|
||||
if (ret != TwiMaster::ErrorCodes::NoError)
|
||||
if (ret != TwiMaster::ErrorCodes::NoError) {
|
||||
NRF_LOG_INFO("WRITE ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t Hrs3300::ReadRegister(uint8_t reg) {
|
||||
uint8_t value;
|
||||
auto ret = twiMaster.Read(twiAddress, reg, &value, 1);
|
||||
if (ret != TwiMaster::ErrorCodes::NoError)
|
||||
if (ret != TwiMaster::ErrorCodes::NoError) {
|
||||
NRF_LOG_INFO("READ ERROR");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -181,8 +181,9 @@ void SpiMaster::PrepareRx(const uint32_t bufferAddress, const size_t size) {
|
|||
}
|
||||
|
||||
bool SpiMaster::Write(uint8_t pinCsn, const uint8_t* data, size_t size, const std::function<void()>& preTransactionHook) {
|
||||
if (data == nullptr)
|
||||
if (data == nullptr) {
|
||||
return false;
|
||||
}
|
||||
auto ok = xSemaphoreTake(mutex, portMAX_DELAY);
|
||||
ASSERT(ok == true);
|
||||
|
||||
|
|
|
@ -92,14 +92,16 @@ void SpiNorFlash::SectorErase(uint32_t sectorAddress) {
|
|||
static_cast<uint8_t>(sectorAddress)};
|
||||
|
||||
WriteEnable();
|
||||
while (!WriteEnabled())
|
||||
while (!WriteEnabled()) {
|
||||
vTaskDelay(1);
|
||||
}
|
||||
|
||||
spi.Read(reinterpret_cast<uint8_t*>(&cmd), cmdSize, nullptr, 0);
|
||||
|
||||
while (WriteInProgress())
|
||||
while (WriteInProgress()) {
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t SpiNorFlash::ReadSecurityRegister() {
|
||||
auto cmd = static_cast<uint8_t>(Commands::ReadSecurityRegister);
|
||||
|
@ -132,13 +134,15 @@ void SpiNorFlash::Write(uint32_t address, const uint8_t* buffer, size_t size) {
|
|||
static_cast<uint8_t>(addr)};
|
||||
|
||||
WriteEnable();
|
||||
while (!WriteEnabled())
|
||||
while (!WriteEnabled()) {
|
||||
vTaskDelay(1);
|
||||
}
|
||||
|
||||
spi.WriteCmdAndBuffer(cmd, cmdSize, b, toWrite);
|
||||
|
||||
while (WriteInProgress())
|
||||
while (WriteInProgress()) {
|
||||
vTaskDelay(1);
|
||||
}
|
||||
|
||||
addr += toWrite;
|
||||
b += toWrite;
|
||||
|
|
|
@ -152,8 +152,9 @@ int main(void) {
|
|||
logger.Init();
|
||||
nrf_drv_clock_init();
|
||||
|
||||
if (pdPASS != xTaskCreate(Process, "MAIN", 512, nullptr, 0, &taskHandle))
|
||||
if (pdPASS != xTaskCreate(Process, "MAIN", 512, nullptr, 0, &taskHandle)) {
|
||||
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
||||
}
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
||||
|
|
|
@ -12,11 +12,12 @@ void Pinetime::System::SystemMonitor::Process() {
|
|||
auto nb = uxTaskGetSystemState(tasksStatus, 10, nullptr);
|
||||
for (uint32_t i = 0; i < nb; i++) {
|
||||
NRF_LOG_INFO("Task [%s] - %d", tasksStatus[i].pcTaskName, tasksStatus[i].usStackHighWaterMark);
|
||||
if (tasksStatus[i].usStackHighWaterMark < 20)
|
||||
if (tasksStatus[i].usStackHighWaterMark < 20) {
|
||||
NRF_LOG_INFO("WARNING!!! Task %s task is nearly full, only %dB available",
|
||||
tasksStatus[i].pcTaskName,
|
||||
tasksStatus[i].usStackHighWaterMark * 4);
|
||||
}
|
||||
}
|
||||
lastTick = xTaskGetTickCount();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -401,7 +401,7 @@ void SystemTask::GoToRunning() {
|
|||
}
|
||||
|
||||
state = SystemTaskState::Running;
|
||||
};
|
||||
}
|
||||
|
||||
void SystemTask::GoToSleep() {
|
||||
if (IsSleeping()) {
|
||||
|
@ -415,7 +415,7 @@ void SystemTask::GoToSleep() {
|
|||
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
|
||||
|
||||
state = SystemTaskState::GoingToSleep;
|
||||
};
|
||||
}
|
||||
|
||||
void SystemTask::UpdateMotion() {
|
||||
if (IsSleeping() && !(settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) ||
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace Pinetime {
|
|||
|
||||
Pinetime::Controllers::NimbleController& nimble() {
|
||||
return nimbleController;
|
||||
};
|
||||
}
|
||||
|
||||
bool IsSleeping() const {
|
||||
return state != SystemTaskState::Running;
|
||||
|
|
|
@ -20,7 +20,7 @@ do
|
|||
*.cpp|*.h)
|
||||
echo Checking "$file"
|
||||
PATCH="$(basename "$file").patch"
|
||||
git clang-format-14 -q --style file --diff "$GITHUB_BASE_REF" "$file" > "$PATCH"
|
||||
git clang-format-16 -q --style file --diff "$GITHUB_BASE_REF" "$file" > "$PATCH"
|
||||
if [ -s "$PATCH" ]
|
||||
then
|
||||
printf "\033[31mError:\033[0m Formatting error in %s\n" "$file"
|
||||
|
|
|
@ -17,7 +17,7 @@ do
|
|||
src/libs/*|src/FreeRTOS/*) continue ;;
|
||||
*.cpp|*.h)
|
||||
echo "::group::$file"
|
||||
clang-tidy-14 -p build "$file" || true
|
||||
clang-tidy-16 -p build "$file" || true
|
||||
echo "::endgroup::"
|
||||
esac
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue