|
|
@@ -0,0 +1,85 @@
|
|
|
+#include "mcumodule.h"
|
|
|
+#include "logger.h"
|
|
|
+
|
|
|
+#include <QSettings>
|
|
|
+
|
|
|
+MCUModule::MCUModule(QObject *parent)
|
|
|
+ : QObject{parent}
|
|
|
+ , m_isHeating(false)
|
|
|
+ , m_screenBrightness(0)
|
|
|
+ , m_keyBrightness(0)
|
|
|
+ , m_screenTemp(0)
|
|
|
+ , m_interfaceTemp(0)
|
|
|
+{
|
|
|
+ QSettings settings("storage/conf/settings.ini", QSettings::IniFormat);
|
|
|
+ settings.setIniCodec("UTF-8");
|
|
|
+ settings.beginGroup("MCU");
|
|
|
+ if(settings.contains("SCREEN_BRIGHTNESS"))
|
|
|
+ m_screenBrightness = settings.value("SCREEN_BRIGHTNESS").toInt();
|
|
|
+ if(settings.contains("KEY_BRIGHTNESS"))
|
|
|
+ m_keyBrightness = settings.value("KEY_BRIGHTNESS").toInt();
|
|
|
+ settings.endGroup();
|
|
|
+}
|
|
|
+
|
|
|
+bool MCUModule::isHeating() const
|
|
|
+{
|
|
|
+ return m_isHeating;
|
|
|
+}
|
|
|
+
|
|
|
+void MCUModule::setIsHeatng(const bool &newIsHeating)
|
|
|
+{
|
|
|
+ if(newIsHeating != m_isHeating) {
|
|
|
+ m_isHeating = newIsHeating;
|
|
|
+ CRITICAL_LOG(spdlog::level::info, "heating state: {}", newIsHeating);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int MCUModule::screenBrightness() const
|
|
|
+{
|
|
|
+ return m_screenBrightness;
|
|
|
+}
|
|
|
+
|
|
|
+void MCUModule::setScreenBrightness(const int &newScreenBrightness)
|
|
|
+{
|
|
|
+ m_screenBrightness = newScreenBrightness;
|
|
|
+ QSettings settings("storage/conf/settings.ini", QSettings::IniFormat);
|
|
|
+ settings.setIniCodec("UTF-8");
|
|
|
+ settings.beginGroup("MCU");
|
|
|
+ settings.setValue("SCREEN_BRIGHTNESS", newScreenBrightness);
|
|
|
+ settings.endGroup();
|
|
|
+}
|
|
|
+
|
|
|
+int MCUModule::keyBrightness() const
|
|
|
+{
|
|
|
+ return m_keyBrightness;
|
|
|
+}
|
|
|
+
|
|
|
+void MCUModule::setKeyBrightness(const int &newKeyBrightness)
|
|
|
+{
|
|
|
+ m_keyBrightness = newKeyBrightness;
|
|
|
+ QSettings settings("storage/conf/settings.ini", QSettings::IniFormat);
|
|
|
+ settings.setIniCodec("UTF-8");
|
|
|
+ settings.beginGroup("MCU");
|
|
|
+ settings.setValue("KEY_BRIGHTNESS", newKeyBrightness);
|
|
|
+ settings.endGroup();
|
|
|
+}
|
|
|
+
|
|
|
+int MCUModule::screenTemp() const
|
|
|
+{
|
|
|
+ return m_screenTemp;
|
|
|
+}
|
|
|
+
|
|
|
+void MCUModule::setScreenTemp(const int &newScreenTemp)
|
|
|
+{
|
|
|
+ m_screenTemp = newScreenTemp;
|
|
|
+}
|
|
|
+
|
|
|
+int MCUModule::interfaceTemp() const
|
|
|
+{
|
|
|
+ return m_interfaceTemp;
|
|
|
+}
|
|
|
+
|
|
|
+void MCUModule::setInterfaceTemp(const int &newInterfaceTemp)
|
|
|
+{
|
|
|
+ m_interfaceTemp = newInterfaceTemp;
|
|
|
+}
|