Browse Source

thermostat: Settings: add functions to save room temperature and programs

master
Richard Genoud 4 years ago
parent
commit
e1b83ac242
2 changed files with 40 additions and 0 deletions
  1. +2
    -0
      soft/thermostat/inc/settings.h
  2. +38
    -0
      soft/thermostat/src/settings.cpp

+ 2
- 0
soft/thermostat/inc/settings.h View File

@ -61,6 +61,8 @@ public:
const QDateTime &getEndHoliday(void) { return m_end_holiday; }
void setEndHoliday(const QDateTime &endDate);
const struct Room &getRoom(int idx) { return m_rooms.at(idx); }
void setRoomDefaultTemperature(int idx, double temperature);
void setRoomPrograms(int idx, QVector<struct Program> &progs);
struct Brocker m_broker;


+ 38
- 0
soft/thermostat/src/settings.cpp View File

@ -117,6 +117,44 @@ Settings::Settings(QObject *parent) : QSettings(parent)
m_broker.port = this->value("broker/port", 1883).toInt();
}
void Settings::setRoomDefaultTemperature(int idx, double temperature)
{
if ((idx < 0) || (idx >= MAX_NB_ZONES)) {
// ERROR
return;
}
this->beginWriteArray("rooms");
this->setArrayIndex(idx);
this->setValue("default_temperature", temperature);
this->endArray();
this->sync();
}
void Settings::setRoomPrograms(int idx, QVector<struct Program> &progs)
{
if ((idx < 0) || (idx >= MAX_NB_ZONES)) {
// ERROR
return;
}
this->beginWriteArray("rooms");
this->setArrayIndex(idx);
this->remove("temperature_schedule");
this->beginWriteArray("temperature_schedule");
for (int i = 0; i < progs.count(); i++) {
this->setArrayIndex(i);
this->setValue("temperature", progs.at(i).temperature);
this->setValue("days_of_week", progs.at(i).DoW);
this->setValue("start_time", progs.at(i).start_time.toString("H:m"));
this->setValue("end_time", progs.at(i).end_time.toString("H:m"));
}
this->endArray();
this->endArray();
this->sync();
}
void Settings::setPowerState(enum power_states state)
{
switch (state) {


Loading…
Cancel
Save