M image/user/db/settings_v2_002.sql => image/user/db/settings_v2_002.sql +2 -1
@@ 38,6 38,7 @@ INSERT OR IGNORE INTO settings_tab (path, value) VALUES
('keypad_light_state', '0'),
('gs_current_timezone_name', ''),
('gs_current_timezone_rules', ''),
- ('\ServiceTime\\gs_automatic_date_and_time_is_on', '1');
+ ('\ServiceTime\\gs_automatic_date_and_time_is_on', '1'),
+ ('temperature_unit', 'C');
M module-apps/apps-common/Temperature.hpp => module-apps/apps-common/Temperature.hpp +2 -2
@@ 33,10 33,10 @@ namespace gui::temperature
inline std::optional<Temperature::Unit> strToUnit(std::string_view str)
{
- if (str == gui::temperature::celsiusDegreeSymbol) {
+ if ((str == gui::temperature::celsiusDegreeSymbol) || (str == celsiusSymbol)) {
return gui::temperature::Temperature::Unit::Celsius;
}
- else if (str == gui::temperature::fahrenheitDegreeSymbol) {
+ else if ((str == gui::temperature::fahrenheitDegreeSymbol) || (str == fahrenheitSymbol)) {
return gui::temperature::Temperature::Unit::Fahrenheit;
}
M module-services/service-evtmgr/EventManager.cpp => module-services/service-evtmgr/EventManager.cpp +3 -0
@@ 283,6 283,9 @@ int EventManagerCommon::dumpLogsToFile()
void EventManagerCommon::handleMinuteUpdate(time_t timestamp)
{
+ if (onMinuteTick) {
+ onMinuteTick(timestamp);
+ }
if (!targetApplication.empty()) {
auto message = std::make_shared<sevm::RtcMinuteAlarmMessage>(MessageType::EVMMinuteUpdated);
message->timestamp = timestamp;
M module-services/service-evtmgr/service-evtmgr/EventManagerCommon.hpp => module-services/service-evtmgr/service-evtmgr/EventManagerCommon.hpp +1 -0
@@ 35,6 35,7 @@ class EventManagerCommon : public sys::Service
sys::TimerHandle loggerTimer;
protected:
+ std::function<void(const time_t)> onMinuteTick;
virtual void handleKeyEvent(sys::Message *msg);
virtual void initProductEvents();
virtual auto createEventWorker() -> std::unique_ptr<WorkerEventCommon>;
M products/BellHybrid/services/evtmgr/CMakeLists.txt => products/BellHybrid/services/evtmgr/CMakeLists.txt +9 -0
@@ 1,19 1,28 @@
add_library(evtmgr STATIC)
+add_library(bell::evtmgr ALIAS evtmgr)
target_sources(evtmgr
PRIVATE
EventManager.cpp
+ internal/StaticData.cpp
+ internal/TemperatureApi.cpp
+
+ internal/StaticData.hpp
PUBLIC
include/evtmgr/EventManager.hpp
+ include/evtmgr/api/TemperatureApi.hpp
)
target_include_directories(evtmgr
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_link_libraries(evtmgr
PRIVATE
+ module-bsp
module-utils
service-evtmgr
)
M products/BellHybrid/services/evtmgr/EventManager.cpp => products/BellHybrid/services/evtmgr/EventManager.cpp +24 -0
@@ 1,4 1,28 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+#include "internal/StaticData.hpp"
+
#include <evtmgr/EventManager.hpp>
+#include <module-bsp/hal/temperature_source/TemperatureSource.hpp>
+
+namespace
+{
+ auto updateTemperature = [](hal::temperature::AbstractTemperatureSource &source) {
+ const auto temp = source.read();
+ if (not temp) {
+ LOG_FATAL("Error during reading from temperature source");
+ }
+ else {
+ evtmgr::internal::StaticData::get().setCurrentTemperature(*temp);
+ };
+ };
+}
+
+EventManager::EventManager(const std::string &name)
+ : EventManagerCommon(name), temperatureSource{hal::temperature::AbstractTemperatureSource::Factory::create()}
+{
+ updateTemperature(*temperatureSource);
+
+ onMinuteTick = [this](const time_t) { updateTemperature(*temperatureSource); };
+}
M products/BellHybrid/services/evtmgr/include/evtmgr/EventManager.hpp => products/BellHybrid/services/evtmgr/include/evtmgr/EventManager.hpp +12 -1
@@ 5,8 5,19 @@
#include <service-evtmgr/EventManagerCommon.hpp>
+namespace hal::temperature
+{
+ class AbstractTemperatureSource;
+}
+
class EventManager : public EventManagerCommon
-{};
+{
+ public:
+ explicit EventManager(const std::string &name = service::name::evt_manager);
+
+ private:
+ std::shared_ptr<hal::temperature::AbstractTemperatureSource> temperatureSource;
+};
namespace sys
{
A products/BellHybrid/services/evtmgr/include/evtmgr/api/TemperatureApi.hpp => products/BellHybrid/services/evtmgr/include/evtmgr/api/TemperatureApi.hpp +11 -0
@@ 0,0 1,11 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <module-bsp/hal/temperature_source/TemperatureSource.hpp>
+
+namespace evtmgr::api
+{
+ hal::temperature::AbstractTemperatureSource::Temperature getCurrentTemperature();
+} // namespace evtmgr::api
A products/BellHybrid/services/evtmgr/internal/StaticData.cpp => products/BellHybrid/services/evtmgr/internal/StaticData.cpp +22 -0
@@ 0,0 1,22 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "StaticData.hpp"
+
+namespace evtmgr::internal
+{
+
+ void StaticData::setCurrentTemperature(hal::temperature::AbstractTemperatureSource::Temperature temperature)
+ {
+ currentTemperature = temperature;
+ }
+ hal::temperature::AbstractTemperatureSource::Temperature StaticData::getCurrentTemperature() const
+ {
+ return currentTemperature;
+ }
+ StaticData &StaticData::get()
+ {
+ static auto instance = StaticData{};
+ return instance;
+ }
+} // namespace evtmgr::internal
A products/BellHybrid/services/evtmgr/internal/StaticData.hpp => products/BellHybrid/services/evtmgr/internal/StaticData.hpp +26 -0
@@ 0,0 1,26 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <module-bsp/hal/temperature_source/TemperatureSource.hpp>
+
+namespace evtmgr::internal
+{
+ class StaticData
+ {
+ public:
+ StaticData(const StaticData &) = delete;
+ StaticData &operator=(const StaticData &) = delete;
+
+ static StaticData &get();
+
+ void setCurrentTemperature(hal::temperature::AbstractTemperatureSource::Temperature temperature);
+ [[nodiscard]] hal::temperature::AbstractTemperatureSource::Temperature getCurrentTemperature() const;
+
+ private:
+ StaticData() = default;
+
+ hal::temperature::AbstractTemperatureSource::Temperature currentTemperature;
+ };
+} // namespace evtmgr::internal
A products/BellHybrid/services/evtmgr/internal/TemperatureApi.cpp => products/BellHybrid/services/evtmgr/internal/TemperatureApi.cpp +14 -0
@@ 0,0 1,14 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "internal/StaticData.hpp"
+
+#include <evtmgr/api/TemperatureApi.hpp>
+
+namespace evtmgr::api
+{
+ hal::temperature::AbstractTemperatureSource::Temperature getCurrentTemperature()
+ {
+ return internal::StaticData::get().getCurrentTemperature();
+ }
+} // namespace evtmgr::api