create motorcontroller in main and pass by reference

This commit is contained in:
petter 2021-01-25 16:47:52 +01:00 committed by jlukanc
parent f27e632906
commit 3dd88339f3
7 changed files with 31 additions and 10 deletions

View file

@ -5,6 +5,7 @@
#include "components/ble/BleController.h" #include "components/ble/BleController.h"
#include "components/datetime/DateTimeController.h" #include "components/datetime/DateTimeController.h"
#include "components/ble/NotificationManager.h" #include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
#include "displayapp/screens/ApplicationList.h" #include "displayapp/screens/ApplicationList.h"
#include "displayapp/screens/Brightness.h" #include "displayapp/screens/Brightness.h"
#include "displayapp/screens/Clock.h" #include "displayapp/screens/Clock.h"
@ -32,6 +33,7 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver
Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog, Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog,
System::SystemTask &systemTask, System::SystemTask &systemTask,
Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::HeartRateController& heartRateController) : Pinetime::Controllers::HeartRateController& heartRateController) :
lcd{lcd}, lcd{lcd},
lvgl{lvgl}, lvgl{lvgl},
@ -43,6 +45,7 @@ DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Driver
currentScreen{new Screens::Clock(this, dateTimeController, batteryController, bleController, notificationManager, heartRateController) }, currentScreen{new Screens::Clock(this, dateTimeController, batteryController, bleController, notificationManager, heartRateController) },
systemTask{systemTask}, systemTask{systemTask},
notificationManager{notificationManager}, notificationManager{notificationManager},
motorController{motorController},
heartRateController{heartRateController} { heartRateController{heartRateController} {
msgQueue = xQueueCreate(queueSize, itemSize); msgQueue = xQueueCreate(queueSize, itemSize);
onClockApp = true; onClockApp = true;
@ -124,7 +127,7 @@ void DisplayApp::Refresh() {
currentScreen.reset(nullptr); currentScreen.reset(nullptr);
lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Up); lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Up);
onClockApp = false; onClockApp = false;
currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Preview)); currentScreen.reset(new Screens::Notifications(this, notificationManager, motorController, Screens::Notifications::Modes::Preview));
} }
} }
break; break;
@ -215,7 +218,7 @@ void DisplayApp::RunningState() {
case Apps::Music : currentScreen.reset(new Screens::Music(this, systemTask.nimble().music())); break; case Apps::Music : currentScreen.reset(new Screens::Music(this, systemTask.nimble().music())); break;
case Apps::Navigation : currentScreen.reset(new Screens::Navigation(this, systemTask.nimble().navigation())); break; case Apps::Navigation : currentScreen.reset(new Screens::Navigation(this, systemTask.nimble().navigation())); break;
case Apps::FirmwareValidation: currentScreen.reset(new Screens::FirmwareValidation(this, validator)); break; case Apps::FirmwareValidation: currentScreen.reset(new Screens::FirmwareValidation(this, validator)); break;
case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, Screens::Notifications::Modes::Normal)); break; case Apps::Notifications: currentScreen.reset(new Screens::Notifications(this, notificationManager, motorController, Screens::Notifications::Modes::Normal)); break;
case Apps::HeartRate: currentScreen.reset(new Screens::HeartRate(this, heartRateController)); break; case Apps::HeartRate: currentScreen.reset(new Screens::HeartRate(this, heartRateController)); break;
} }
nextApp = Apps::None; nextApp = Apps::None;

View file

@ -23,6 +23,7 @@ namespace Pinetime {
class Ble; class Ble;
class DateTime; class DateTime;
class NotificationManager; class NotificationManager;
class MotorController;
class HeartRateController; class HeartRateController;
} }
@ -44,6 +45,7 @@ namespace Pinetime {
Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog, Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog,
System::SystemTask &systemTask, System::SystemTask &systemTask,
Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Controllers::HeartRateController& heartRateController); Pinetime::Controllers::HeartRateController& heartRateController);
void Start(); void Start();
void PushMessage(Messages msg); void PushMessage(Messages msg);
@ -87,6 +89,7 @@ namespace Pinetime {
Controllers::BrightnessController brightnessController; Controllers::BrightnessController brightnessController;
std::unique_ptr<Screens::Modal> modal; std::unique_ptr<Screens::Modal> modal;
Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::MotorController& motorController;
Pinetime::Controllers::FirmwareValidator validator; Pinetime::Controllers::FirmwareValidator validator;
TouchModes touchMode = TouchModes::Gestures; TouchModes touchMode = TouchModes::Gestures;
Pinetime::Controllers::HeartRateController& heartRateController; Pinetime::Controllers::HeartRateController& heartRateController;

View file

@ -3,12 +3,16 @@
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
Notifications::Notifications(DisplayApp *app, Pinetime::Controllers::NotificationManager &notificationManager, Modes mode) : Notifications::Notifications(DisplayApp *app,
Screen(app), notificationManager{notificationManager}, mode{mode} { Pinetime::Controllers::NotificationManager &notificationManager,
Pinetime::Controllers::MotorController& motorController,
Modes mode) :
Screen(app), notificationManager{notificationManager},
motorController{motorController}, mode{mode} {
notificationManager.ClearNewNotificationFlag(); notificationManager.ClearNewNotificationFlag();
auto notification = notificationManager.GetLastNotification(); auto notification = notificationManager.GetLastNotification();
motorController.Init(); //start the vibration timer setups
if(notification.valid) { if(notification.valid) {
currentId = notification.id; currentId = notification.id;

View file

@ -13,7 +13,10 @@ namespace Pinetime {
class Notifications : public Screen { class Notifications : public Screen {
public: public:
enum class Modes {Normal, Preview}; enum class Modes {Normal, Preview};
explicit Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, Modes mode); explicit Notifications(DisplayApp* app,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::MotorController& motorController,
Modes mode);
~Notifications() override; ~Notifications() override;
bool Refresh() override; bool Refresh() override;
@ -46,7 +49,7 @@ namespace Pinetime {
const char* text; const char* text;
}; };
Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::MotorController motorController; Pinetime::Controllers::MotorController& motorController;
Modes mode = Modes::Normal; Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem; std::unique_ptr<NotificationItem> currentItem;
Controllers::NotificationManager::Notification::Id currentId; Controllers::NotificationManager::Notification::Id currentId;

View file

@ -30,6 +30,7 @@
#include "components/battery/BatteryController.h" #include "components/battery/BatteryController.h"
#include "components/ble/BleController.h" #include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h" #include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
#include "components/datetime/DateTimeController.h" #include "components/datetime/DateTimeController.h"
#include "displayapp/DisplayApp.h" #include "displayapp/DisplayApp.h"
#include "displayapp/LittleVgl.h" #include "displayapp/LittleVgl.h"
@ -99,6 +100,7 @@ static constexpr uint8_t pinTouchIrq = 28;
std::unique_ptr<Pinetime::System::SystemTask> systemTask; std::unique_ptr<Pinetime::System::SystemTask> systemTask;
Pinetime::Controllers::NotificationManager notificationManager; Pinetime::Controllers::NotificationManager notificationManager;
Pinetime::Controllers::MotorController motorController;
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
if(pin == pinTouchIrq) { if(pin == pinTouchIrq) {
@ -241,7 +243,7 @@ int main(void) {
debounceTimer = xTimerCreate ("debounceTimer", 200, pdFALSE, (void *) 0, DebounceTimerCallback); debounceTimer = xTimerCreate ("debounceTimer", 200, pdFALSE, (void *) 0, DebounceTimerCallback);
systemTask.reset(new Pinetime::System::SystemTask(spi, lcd, spiNorFlash, twiMaster, touchPanel, lvgl, batteryController, bleController, systemTask.reset(new Pinetime::System::SystemTask(spi, lcd, spiNorFlash, twiMaster, touchPanel, lvgl, batteryController, bleController,
dateTimeController, notificationManager, heartRateSensor)); dateTimeController, notificationManager, motorController, heartRateSensor));
systemTask->Start(); systemTask->Start();
nimble_port_init(); nimble_port_init();

View file

@ -41,13 +41,14 @@ SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd,
Controllers::Battery &batteryController, Controllers::Ble &bleController, Controllers::Battery &batteryController, Controllers::Ble &bleController,
Controllers::DateTime &dateTimeController, Controllers::DateTime &dateTimeController,
Pinetime::Controllers::NotificationManager& notificationManager, Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Drivers::Hrs3300& heartRateSensor) : Pinetime::Drivers::Hrs3300& heartRateSensor) :
spi{spi}, lcd{lcd}, spiNorFlash{spiNorFlash}, spi{spi}, lcd{lcd}, spiNorFlash{spiNorFlash},
twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController}, twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController},
heartRateController{*this}, heartRateController{*this},
bleController{bleController}, dateTimeController{dateTimeController}, bleController{bleController}, dateTimeController{dateTimeController},
watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager}, watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager},
heartRateSensor{heartRateSensor}, motorController{motorController}, heartRateSensor{heartRateSensor},
nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) { nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash, heartRateController) {
systemTasksMsgQueue = xQueueCreate(10, 1); systemTasksMsgQueue = xQueueCreate(10, 1);
} }
@ -81,12 +82,14 @@ void SystemTask::Work() {
batteryController.Init(); batteryController.Init();
displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController, displayApp.reset(new Pinetime::Applications::DisplayApp(lcd, lvgl, touchPanel, batteryController, bleController,
dateTimeController, watchdogView, *this, notificationManager, heartRateController)); dateTimeController, watchdogView, *this, notificationManager,
motorController, heartRateController));
displayApp->Start(); displayApp->Start();
batteryController.Update(); batteryController.Update();
displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel); displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::UpdateBatteryLevel);
motorController.Init();
heartRateSensor.Init(); heartRateSensor.Init();
heartRateSensor.Disable(); heartRateSensor.Disable();

View file

@ -12,6 +12,7 @@
#include "components/battery/BatteryController.h" #include "components/battery/BatteryController.h"
#include "components/ble/NimbleController.h" #include "components/ble/NimbleController.h"
#include "components/ble/NotificationManager.h" #include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
#include "displayapp/DisplayApp.h" #include "displayapp/DisplayApp.h"
#include "drivers/Watchdog.h" #include "drivers/Watchdog.h"
@ -38,6 +39,7 @@ namespace Pinetime {
Controllers::Battery &batteryController, Controllers::Ble &bleController, Controllers::Battery &batteryController, Controllers::Ble &bleController,
Controllers::DateTime &dateTimeController, Controllers::DateTime &dateTimeController,
Pinetime::Controllers::NotificationManager& manager, Pinetime::Controllers::NotificationManager& manager,
Pinetime::Controllers::MotorController& motorController,
Pinetime::Drivers::Hrs3300& heartRateSensor); Pinetime::Drivers::Hrs3300& heartRateSensor);
@ -74,6 +76,7 @@ namespace Pinetime {
Pinetime::Drivers::Watchdog watchdog; Pinetime::Drivers::Watchdog watchdog;
Pinetime::Drivers::WatchdogView watchdogView; Pinetime::Drivers::WatchdogView watchdogView;
Pinetime::Controllers::NotificationManager& notificationManager; Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::MotorController& motorController;
Pinetime::Drivers::Hrs3300& heartRateSensor; Pinetime::Drivers::Hrs3300& heartRateSensor;
Pinetime::Controllers::NimbleController nimbleController; Pinetime::Controllers::NimbleController nimbleController;