Update clang-tidy configuration and fix some warnings (#1474)
Don't enable coding conventions from unrelated projects. Only enable generic checks.
This commit is contained in:
@@ -28,7 +28,7 @@ AlarmController::AlarmController(Controllers::DateTime& dateTimeController) : da
|
||||
|
||||
namespace {
|
||||
void SetOffAlarm(TimerHandle_t xTimer) {
|
||||
auto controller = static_cast<Pinetime::Controllers::AlarmController*>(pvTimerGetTimerID(xTimer));
|
||||
auto* controller = static_cast<Pinetime::Controllers::AlarmController*>(pvTimerGetTimerID(xTimer));
|
||||
controller->SetOffAlarmNow();
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,8 @@ Battery::Battery() {
|
||||
}
|
||||
|
||||
void Battery::ReadPowerState() {
|
||||
isCharging = !nrf_gpio_pin_read(PinMap::Charging);
|
||||
isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
|
||||
isCharging = (nrf_gpio_pin_read(PinMap::Charging) == 0);
|
||||
isPowerPresent = (nrf_gpio_pin_read(PinMap::PowerPresent) == 0);
|
||||
|
||||
if (isPowerPresent && !isCharging) {
|
||||
isFull = true;
|
||||
@@ -81,10 +81,8 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) {
|
||||
// p_event->data.done.p_buffer[0] = (adc_voltage / reference_voltage) * 1024
|
||||
voltage = p_event->data.done.p_buffer[0] * (8 * 600) / 1024;
|
||||
|
||||
uint8_t newPercent;
|
||||
if (isFull) {
|
||||
newPercent = 100;
|
||||
} else {
|
||||
uint8_t newPercent = 100;
|
||||
if (!isFull) {
|
||||
newPercent = std::min(aprox.GetValue(voltage), isCharging ? uint8_t {99} : uint8_t {100});
|
||||
}
|
||||
|
||||
|
@@ -40,7 +40,7 @@ namespace {
|
||||
constexpr ble_uuid128_t navProgressCharUuid {CharUuid(0x04, 0x00)};
|
||||
|
||||
int NAVCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) {
|
||||
auto navService = static_cast<Pinetime::Controllers::NavigationService*>(arg);
|
||||
auto* navService = static_cast<Pinetime::Controllers::NavigationService*>(arg);
|
||||
return navService->OnCommand(conn_handle, attr_handle, ctxt);
|
||||
}
|
||||
} // namespace
|
||||
|
@@ -29,8 +29,9 @@ namespace {
|
||||
auto z1 = CompareShift(d, mn - 1, size);
|
||||
for (int i = mn; i < mx + 1; i++) {
|
||||
auto z = CompareShift(d, i, size);
|
||||
if (z2 > z1 && z1 < z)
|
||||
if (z2 > z1 && z1 < z) {
|
||||
return i;
|
||||
}
|
||||
z2 = z1;
|
||||
z1 = z;
|
||||
}
|
||||
@@ -52,41 +53,48 @@ int8_t Ppg::Preprocess(float spl) {
|
||||
|
||||
auto spl_int = static_cast<int8_t>(spl);
|
||||
|
||||
if (dataIndex < 200)
|
||||
if (dataIndex < 200) {
|
||||
data[dataIndex++] = spl_int;
|
||||
}
|
||||
return spl_int;
|
||||
}
|
||||
|
||||
float Ppg::HeartRate() {
|
||||
if (dataIndex < 200)
|
||||
int Ppg::HeartRate() {
|
||||
if (dataIndex < 200) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NRF_LOG_INFO("PREPROCESS, offset = %d", offset);
|
||||
auto hr = ProcessHeartRate();
|
||||
dataIndex = 0;
|
||||
return hr;
|
||||
}
|
||||
float Ppg::ProcessHeartRate() {
|
||||
auto t0 = Trough(data.data(), dataIndex, 7, 48);
|
||||
if (t0 < 0)
|
||||
return 0;
|
||||
|
||||
float t1 = t0 * 2;
|
||||
int Ppg::ProcessHeartRate() {
|
||||
int t0 = Trough(data.data(), dataIndex, 7, 48);
|
||||
if (t0 < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int t1 = t0 * 2;
|
||||
t1 = Trough(data.data(), dataIndex, t1 - 5, t1 + 5);
|
||||
if (t1 < 0)
|
||||
if (t1 < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float t2 = static_cast<int>(t1 * 3) / 2;
|
||||
int t2 = (t1 * 3) / 2;
|
||||
t2 = Trough(data.data(), dataIndex, t2 - 5, t2 + 5);
|
||||
if (t2 < 0)
|
||||
if (t2 < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float t3 = static_cast<int>(t2 * 4) / 3;
|
||||
int t3 = (t2 * 4) / 3;
|
||||
t3 = Trough(data.data(), dataIndex, t3 - 4, t3 + 4);
|
||||
if (t3 < 0)
|
||||
return static_cast<int>(60 * 24 * 3) / static_cast<int>(t2);
|
||||
if (t3 < 0) {
|
||||
return (60 * 24 * 3) / t2;
|
||||
}
|
||||
|
||||
return static_cast<int>(60 * 24 * 4) / static_cast<int>(t3);
|
||||
return (60 * 24 * 4) / t3;
|
||||
}
|
||||
|
||||
void Ppg::SetOffset(uint16_t offset) {
|
||||
|
@@ -12,9 +12,9 @@ namespace Pinetime {
|
||||
public:
|
||||
Ppg();
|
||||
int8_t Preprocess(float spl);
|
||||
float HeartRate();
|
||||
int HeartRate();
|
||||
|
||||
void SetOffset(uint16_t i);
|
||||
void SetOffset(uint16_t offset);
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
@@ -25,7 +25,7 @@ namespace Pinetime {
|
||||
Ptagc agc;
|
||||
Biquad lpf;
|
||||
|
||||
float ProcessHeartRate();
|
||||
int ProcessHeartRate();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -14,13 +14,15 @@ Ptagc::Ptagc(float start, float decay, float threshold) : peak {start}, decay {d
|
||||
}
|
||||
|
||||
float Ptagc::Step(float spl) {
|
||||
if (std::abs(spl) > peak)
|
||||
if (std::abs(spl) > peak) {
|
||||
peak *= boost;
|
||||
else
|
||||
} else {
|
||||
peak *= decay;
|
||||
}
|
||||
|
||||
if ((spl > (peak * threshold)) || (spl < (peak * -threshold)))
|
||||
if ((spl > (peak * threshold)) || (spl < (peak * -threshold))) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
spl = 100.0f * spl / (2.0f * peak);
|
||||
return spl;
|
||||
|
@@ -26,10 +26,9 @@ bool MotionController::Should_RaiseWake(bool isSleeping) {
|
||||
if (not isSleeping) {
|
||||
if (y <= 0) {
|
||||
return false;
|
||||
} else {
|
||||
lastYForWakeUp = 0;
|
||||
return false;
|
||||
}
|
||||
lastYForWakeUp = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (y >= 0) {
|
||||
|
Reference in New Issue
Block a user