#include #include #include "../module-gui/gui/core/ImageManager.hpp" #include "log/log.hpp" #include "memory/usermem.h" #include "ticks.hpp" //module-applications #include "application-clock/ApplicationClock.hpp" #include "application-call/ApplicationCall.hpp" #include "application-viewer/ApplicationViewer.hpp" #include "application-desktop/ApplicationDesktop.hpp" #include "application-settings/ApplicationSettings.hpp" #include "application-notes/ApplicationNotes.hpp" //module-services #include "service-gui/ServiceGUI.hpp" #include "service-gui/messages/DrawMessage.hpp" #include "ServiceEink.hpp" #include "service-appmgr/ApplicationManager.hpp" #include "service-evtmgr/EventManager.hpp" #include "service-db/ServiceDB.hpp" #include "service-db/api/DBServiceAPI.hpp" #include "service-cellular/ServiceCellular.hpp" #include "service-cellular/api/CellularServiceAPI.hpp" #include "service-audio/ServiceAudio.hpp" #include "service-audio/api/AudioServiceAPI.hpp" //module-bsp #include "bsp/bsp.hpp" #include "bsp/rtc/rtc.hpp" #include "bsp/keyboard/keyboard.hpp" //module-vfs #include "vfs.hpp" //module-sys #include "SystemManager/SystemManager.hpp" class vfs vfs; class BlinkyService : public sys::Service { public: BlinkyService(const std::string &name) : sys::Service(name) { timer_id = CreateTimer(2000, true); //ReloadTimer(timer_id); } ~BlinkyService() { } // Invoked upon receiving data message sys::Message_t DataReceivedHandler(sys::DataMessage *msgl) override { #if 0 // M.P: left here on purpose //auto ret = AudioServiceAPI::PlaybackStart(this,"/home/mateusz/Music/limowreck.mp3"); //auto ret = AudioServiceAPI::PlaybackStart(this,"sys/audio/teee.flac"); //AudioServiceAPI::SetOutputVolume(this,0.6); //auto ret = AudioServiceAPI::RecordingStart(this,"sys/audio/rec1mono.wav"); //vTaskDelay(3000); //ret = AudioServiceAPI::Stop(this); auto ret = AudioServiceAPI::RoutingStart(this); //AudioServiceAPI::RoutingRecordCtrl(this,true); vTaskDelay(1000); AudioServiceAPI::RoutingSpeakerPhone(this,true); vTaskDelay(2000); AudioServiceAPI::Stop(this); #endif return std::make_shared(); } // Invoked when timer ticked void TickHandler(uint32_t id) override { #if 0 // M.P: left here on purpose LOG_DEBUG("Blinky service tick!"); stopTimer(timer_id); std::shared_ptr msg = std::make_shared(static_cast(MessageType::AudioSetInputGain)); auto ret = sys::Bus::SendUnicast(msg,GetName(),this); #endif } // Invoked during initialization sys::ReturnCodes InitHandler() override { return sys::ReturnCodes::Success; } sys::ReturnCodes DeinitHandler() override { return sys::ReturnCodes::Success; } sys::ReturnCodes WakeUpHandler() override { return sys::ReturnCodes::Success; } sys::ReturnCodes SleepHandler() override { return sys::ReturnCodes::Success; } uint32_t timer_id = 0; }; int SystemStart(sys::SystemManager *sysmgr) { vfs.Init(); bool ret = false; ret = sysmgr->CreateService(std::make_shared("ServiceGUI", 480, 600), sysmgr); ret |= sysmgr->CreateService(std::make_shared("ServiceEink"), sysmgr); ret |= sysmgr->CreateService(std::make_shared("EventManager"), sysmgr); ret |= sysmgr->CreateService(std::make_shared(), sysmgr); ret |= sysmgr->CreateService(std::make_shared("Blinky"), sysmgr); ret |= sysmgr->CreateService(std::make_shared(), sysmgr); ret |= sysmgr->CreateService(std::make_shared(), sysmgr); //vector with launchers to applications std::vector > applications; //launcher for viewer applications.push_back(std::unique_ptr(new app::ApplicationViewerLauncher())); //launcher for desktop application applications.push_back(std::unique_ptr(new app::ApplicationDesktopLauncher())); //launcher for call application applications.push_back(std::unique_ptr(new app::ApplicationCallLauncher())); //launcher for settings application applications.push_back(std::unique_ptr(new app::ApplicationSettingsLauncher())); //launcher for notes application applications.push_back(std::unique_ptr(new app::ApplicationNotesLauncher())); //start application manager ret |= sysmgr->CreateService(std::make_shared("ApplicationManager", sysmgr, applications), sysmgr); if (ret) { return 0; } return 0; } int main() { LOG_PRINTF("Launching PurePhone..\n "); bsp::BoardInit(); auto sysmgr = std::make_shared(5000); sysmgr->StartSystem(); sysmgr->RegisterInitFunction(SystemStart); cpp_freertos::Thread::StartScheduler(); return 0; }