summaryrefslogtreecommitdiff
path: root/src/systemtask
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2022-04-02 14:34:53 (GMT)
committerGitea <gitea@fake.local>2022-04-02 14:34:53 (GMT)
commit187ea0f06d93c7f7df5779cb321a28ad040234ee (patch)
tree3d6d1b2f60573045734153d975e9b0aa1b327394 /src/systemtask
parentadc7909c9823c5cd9fc9888a84e84f9182b9088f (diff)
parentb498e1d633522eed975d78b04508834b7a79befe (diff)
Merge branch 'develop' of JF/PineTime into master
Diffstat (limited to 'src/systemtask')
-rw-r--r--src/systemtask/Messages.h1
-rw-r--r--src/systemtask/SystemMonitor.cpp26
-rw-r--r--src/systemtask/SystemMonitor.h40
-rw-r--r--src/systemtask/SystemTask.cpp30
-rw-r--r--src/systemtask/SystemTask.h9
5 files changed, 52 insertions, 54 deletions
diff --git a/src/systemtask/Messages.h b/src/systemtask/Messages.h
index 4d5ab4c..2e3456a 100644
--- a/src/systemtask/Messages.h
+++ b/src/systemtask/Messages.h
@@ -31,6 +31,7 @@ namespace Pinetime {
BatteryPercentageUpdated,
StartFileTransfer,
StopFileTransfer,
+ BleRadioEnableToggle
};
}
}
diff --git a/src/systemtask/SystemMonitor.cpp b/src/systemtask/SystemMonitor.cpp
new file mode 100644
index 0000000..90765e3
--- /dev/null
+++ b/src/systemtask/SystemMonitor.cpp
@@ -0,0 +1,26 @@
+#include "systemtask/SystemTask.h"
+#if configUSE_TRACE_FACILITY == 1
+// FreeRtosMonitor
+#include <FreeRTOS.h>
+#include <task.h>
+#include <nrf_log.h>
+
+void Pinetime::System::SystemMonitor::Process() {
+ if (xTaskGetTickCount() - lastTick > 10000) {
+ NRF_LOG_INFO("---------------------------------------\nFree heap : %d", xPortGetFreeHeapSize());
+ TaskStatus_t tasksStatus[10];
+ 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)
+ NRF_LOG_INFO("WARNING!!! Task %s task is nearly full, only %dB available",
+ tasksStatus[i].pcTaskName,
+ tasksStatus[i].usStackHighWaterMark * 4);
+ }
+ lastTick = xTaskGetTickCount();
+ }
+}
+#else
+// DummyMonitor
+void Pinetime::System::SystemMonitor::Process() {}
+#endif
diff --git a/src/systemtask/SystemMonitor.h b/src/systemtask/SystemMonitor.h
index 45c02c2..08c8740 100644
--- a/src/systemtask/SystemMonitor.h
+++ b/src/systemtask/SystemMonitor.h
@@ -1,44 +1,16 @@
#pragma once
-#include <FreeRTOS.h>
+#include <FreeRTOS.h> // declares configUSE_TRACE_FACILITY
#include <task.h>
-#include <nrf_log.h>
namespace Pinetime {
namespace System {
- struct DummyMonitor {};
- struct FreeRtosMonitor {};
-
- template <class T> class SystemMonitor {
- public:
- SystemMonitor() = delete;
- };
-
- template <> class SystemMonitor<DummyMonitor> {
+ class SystemMonitor {
public:
- void Process() const {
- }
- };
-
- template <> class SystemMonitor<FreeRtosMonitor> {
- public:
- void Process() const {
- if (xTaskGetTickCount() - lastTick > 10000) {
- NRF_LOG_INFO("---------------------------------------\nFree heap : %d", xPortGetFreeHeapSize());
- 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)
- NRF_LOG_INFO("WARNING!!! Task %s task is nearly full, only %dB available",
- tasksStatus[i].pcTaskName,
- tasksStatus[i].usStackHighWaterMark * 4);
- }
- lastTick = xTaskGetTickCount();
- }
- }
-
+ void Process();
+#if configUSE_TRACE_FACILITY == 1
private:
mutable TickType_t lastTick = 0;
- mutable TaskStatus_t tasksStatus[10];
+#endif
};
}
-} \ No newline at end of file
+}
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index 94d40c9..77cf411 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -1,18 +1,10 @@
#include "systemtask/SystemTask.h"
-#define min // workaround: nimble's min/max macros conflict with libstdc++
-#define max
-#include <host/ble_gap.h>
-#include <host/ble_gatt.h>
-#include <host/ble_hs_adv.h>
-#include <host/util/util.h>
-#include <nimble/hci_common.h>
-#undef max
-#undef min
#include <hal/nrf_rtc.h>
#include <libraries/gpiote/app_gpiote.h>
#include <libraries/log/nrf_log.h>
#include "BootloaderVersion.h"
+#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "drivers/Cst816s.h"
#include "drivers/St7789.h"
@@ -115,7 +107,7 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
void SystemTask::Start() {
systemTasksMsgQueue = xQueueCreate(10, 1);
- if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 350, this, 0, &taskHandle)) {
+ if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 350, this, 1, &taskHandle)) {
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
}
@@ -197,13 +189,13 @@ void SystemTask::Work() {
// Touchscreen
nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq,
static_cast<nrf_gpio_pin_pull_t>(GPIO_PIN_CNF_PULL_Pullup),
- static_cast<nrf_gpio_pin_sense_t> GPIO_PIN_CNF_SENSE_Low);
+ static_cast<nrf_gpio_pin_sense_t>(GPIO_PIN_CNF_SENSE_Low));
pinConfig.skip_gpio_setup = true;
pinConfig.hi_accuracy = false;
pinConfig.is_watcher = false;
pinConfig.sense = static_cast<nrf_gpiote_polarity_t>(NRF_GPIOTE_POLARITY_HITOLO);
- pinConfig.pull = static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Pullup;
+ pinConfig.pull = static_cast<nrf_gpio_pin_pull_t>(GPIO_PIN_CNF_PULL_Pullup);
nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
@@ -239,6 +231,7 @@ void SystemTask::Work() {
if (!bleController.IsFirmwareUpdating()) {
doNotGoToSleep = false;
}
+ ReloadIdleTimer();
break;
case Messages::DisableSleeping:
doNotGoToSleep = true;
@@ -261,7 +254,7 @@ void SystemTask::Work() {
displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToRunning);
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::WakeUp);
- if (!bleController.IsConnected()) {
+ if (bleController.IsRadioEnabled() && !bleController.IsConnected()) {
nimbleController.RestartFastAdv();
}
@@ -295,6 +288,9 @@ void SystemTask::Work() {
case Messages::OnNewTime:
ReloadIdleTimer();
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
+ if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) {
+ alarmController.ScheduleAlarm();
+ }
break;
case Messages::OnNewNotification:
if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::ON) {
@@ -444,7 +440,13 @@ void SystemTask::Work() {
motorController.RunForDuration(35);
displayApp.PushMessage(Pinetime::Applications::Display::Messages::ShowPairingKey);
break;
-
+ case Messages::BleRadioEnableToggle:
+ if(settingsController.GetBleRadioEnabled()) {
+ nimbleController.EnableRadio();
+ } else {
+ nimbleController.DisableRadio();
+ }
+ break;
default:
break;
}
diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h
index e2e6de7..c5b0379 100644
--- a/src/systemtask/SystemTask.h
+++ b/src/systemtask/SystemTask.h
@@ -3,6 +3,7 @@
#include <memory>
#include <FreeRTOS.h>
+#include <queue.h>
#include <task.h>
#include <timers.h>
#include <heartratetask/HeartRateTask.h>
@@ -12,7 +13,6 @@
#include <components/motion/MotionController.h>
#include "systemtask/SystemMonitor.h"
-#include "components/battery/BatteryController.h"
#include "components/ble/NimbleController.h"
#include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
@@ -46,6 +46,7 @@ namespace Pinetime {
class Hrs3300;
}
namespace Controllers {
+ class Battery;
class TouchHandler;
class ButtonHandler;
}
@@ -147,11 +148,7 @@ namespace Pinetime {
bool stepCounterMustBeReset = false;
static constexpr TickType_t batteryMeasurementPeriod = pdMS_TO_TICKS(10 * 60 * 1000);
-#if configUSE_TRACE_FACILITY == 1
- SystemMonitor<FreeRtosMonitor> monitor;
-#else
- SystemMonitor<DummyMonitor> monitor;
-#endif
+ SystemMonitor monitor;
};
}
}