Commit 0603c0b43139fff062723a8880431bf2226aa50a
1 parent
5adb1f52f8
Exists in
master
and in
2 other branches
rtc 설정을 시스템에서 하도록 수정
- system.h, system.c 수정
Showing
9 changed files
with
60 additions
and
8 deletions
Show diff stats
app/gui/oven_control/config.cpp
@@ -265,7 +265,6 @@ bool Config::loadFavorite(void){ | @@ -265,7 +265,6 @@ bool Config::loadFavorite(void){ | ||
265 | itemp = strTemp.toInt(&rst,10); | 265 | itemp = strTemp.toInt(&rst,10); |
266 | if(rst && itemp < (uint32_t)config_invalid) { | 266 | if(rst && itemp < (uint32_t)config_invalid) { |
267 | m_setFavorite.insert(itemp); | 267 | m_setFavorite.insert(itemp); |
268 | - qDebug()<< "load favorite index " << itemp; | ||
269 | } | 268 | } |
270 | } | 269 | } |
271 | file.close(); | 270 | file.close(); |
@@ -328,9 +327,6 @@ void Config::execConfigWindow(QWidget *parent, Define::ConfigType idx){ | @@ -328,9 +327,6 @@ void Config::execConfigWindow(QWidget *parent, Define::ConfigType idx){ | ||
328 | QDialog *dlg; | 327 | QDialog *dlg; |
329 | bool bUsbDetect = false; | 328 | bool bUsbDetect = false; |
330 | switch(idx){ | 329 | switch(idx){ |
331 | - case config_datetime: | ||
332 | - dlg = new ConfigDateTimeDlg(parent); | ||
333 | - break; | ||
334 | case config_language: | 330 | case config_language: |
335 | dlg = new ConfigLanguageDlg(parent); | 331 | dlg = new ConfigLanguageDlg(parent); |
336 | break; | 332 | break; |
app/gui/oven_control/config.h
@@ -404,6 +404,7 @@ public: | @@ -404,6 +404,7 @@ public: | ||
404 | static QString getTempString(int cel_temp); | 404 | static QString getTempString(int cel_temp); |
405 | 405 | ||
406 | 406 | ||
407 | + | ||
407 | void execConfigWindow(QWidget *parent, Define::ConfigType idx); | 408 | void execConfigWindow(QWidget *parent, Define::ConfigType idx); |
408 | 409 | ||
409 | 410 |
app/gui/oven_control/configdatetimedlg.cpp
1 | +#include <QDateTime> | ||
1 | #include "configdatetimedlg.h" | 2 | #include "configdatetimedlg.h" |
2 | #include "ui_configdatetimedlg.h" | 3 | #include "ui_configdatetimedlg.h" |
4 | +#include "system.h" | ||
5 | + | ||
3 | 6 | ||
4 | ConfigDateTimeDlg::ConfigDateTimeDlg(QWidget *parent) : | 7 | ConfigDateTimeDlg::ConfigDateTimeDlg(QWidget *parent) : |
5 | QDialog(parent), | 8 | QDialog(parent), |
@@ -9,6 +12,14 @@ ConfigDateTimeDlg::ConfigDateTimeDlg(QWidget *parent) : | @@ -9,6 +12,14 @@ ConfigDateTimeDlg::ConfigDateTimeDlg(QWidget *parent) : | ||
9 | this->setWindowFlags( Qt::FramelessWindowHint); | 12 | this->setWindowFlags( Qt::FramelessWindowHint); |
10 | this->setAttribute( Qt::WA_DeleteOnClose); | 13 | this->setAttribute( Qt::WA_DeleteOnClose); |
11 | ui->ctrSpBxYear->setFormatterWidth(4); | 14 | ui->ctrSpBxYear->setFormatterWidth(4); |
15 | + QDateTime dt_tm = QDateTime::currentDateTime(); | ||
16 | + QDate dt_ = dt_tm.date(); | ||
17 | + QTime tm_ = dt_tm.time(); | ||
18 | + ui->ctrSpBxYear->setValue(dt_.year()); | ||
19 | + ui->ctrSpBxMonth->setValue(dt_.month()); | ||
20 | + ui->ctrSpBxDay->setValue(dt_.day()); | ||
21 | + ui->ctrSpBxHour->setValue(tm_.hour()); | ||
22 | + ui->ctrSpBxMin->setValue(tm_.minute()); | ||
12 | } | 23 | } |
13 | 24 | ||
14 | ConfigDateTimeDlg::~ConfigDateTimeDlg() | 25 | ConfigDateTimeDlg::~ConfigDateTimeDlg() |
@@ -18,6 +29,15 @@ ConfigDateTimeDlg::~ConfigDateTimeDlg() | @@ -18,6 +29,15 @@ ConfigDateTimeDlg::~ConfigDateTimeDlg() | ||
18 | 29 | ||
19 | void ConfigDateTimeDlg::on_ctrBtnOk_clicked() | 30 | void ConfigDateTimeDlg::on_ctrBtnOk_clicked() |
20 | { | 31 | { |
32 | + time_t tm_t; | ||
33 | + QDate dt_(ui->ctrSpBxYear->value(), ui->ctrSpBxMonth->value(), ui->ctrSpBxDay->value()); | ||
34 | + QTime tm_(ui->ctrSpBxHour->value(), ui->ctrSpBxMin->value()); | ||
35 | + QDateTime dt_tm; | ||
36 | + dt_tm.setTime(tm_); | ||
37 | + dt_tm.setDate(dt_); | ||
38 | + tm_t = (time_t)dt_tm.toTime_t(); | ||
39 | + System::setRtcTime(dt_tm); | ||
40 | + stime(&tm_t); | ||
21 | this->accept(); | 41 | this->accept(); |
22 | } | 42 | } |
23 | 43 |
app/gui/oven_control/configdatetimedlg.h
@@ -3,10 +3,12 @@ | @@ -3,10 +3,12 @@ | ||
3 | 3 | ||
4 | #include <QDialog> | 4 | #include <QDialog> |
5 | 5 | ||
6 | + | ||
6 | namespace Ui { | 7 | namespace Ui { |
7 | class ConfigDateTimeDlg; | 8 | class ConfigDateTimeDlg; |
8 | } | 9 | } |
9 | 10 | ||
11 | + | ||
10 | class ConfigDateTimeDlg : public QDialog | 12 | class ConfigDateTimeDlg : public QDialog |
11 | { | 13 | { |
12 | Q_OBJECT | 14 | Q_OBJECT |
app/gui/oven_control/configwindow.cpp
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | #include "config.h" | 7 | #include "config.h" |
8 | #include "configinfodlg.h" | 8 | #include "configinfodlg.h" |
9 | #include "yesnopopupdlg.h" | 9 | #include "yesnopopupdlg.h" |
10 | +#include "configdatetimedlg.h" | ||
10 | 11 | ||
11 | 12 | ||
12 | 13 | ||
@@ -102,6 +103,11 @@ void ConfigWindow::onConfigBtnClicked(uint16_t id){ | @@ -102,6 +103,11 @@ void ConfigWindow::onConfigBtnClicked(uint16_t id){ | ||
102 | Config *cfg = Config::getInstance(); | 103 | Config *cfg = Config::getInstance(); |
103 | QDialog* dlg; | 104 | QDialog* dlg; |
104 | switch(id){ | 105 | switch(id){ |
106 | + case config_datetime: | ||
107 | + dlg = new ConfigDateTimeDlg(this); | ||
108 | + dlg->show(); | ||
109 | + if(m_nCurConfigPos != config_menu_favorite) reloadValue(); | ||
110 | + break; | ||
105 | case config_enter_engineer_mode: | 111 | case config_enter_engineer_mode: |
106 | { | 112 | { |
107 | EngineerMenuWindow *w = new EngineerMenuWindow(this); | 113 | EngineerMenuWindow *w = new EngineerMenuWindow(this); |
app/gui/oven_control/rtc_control.cpp
app/gui/oven_control/rtc_control.h
app/gui/oven_control/system.cpp
1 | #include "system.h" | 1 | #include "system.h" |
2 | +#include <sys/ioctl.h> | ||
3 | +#include <unistd.h> | ||
4 | +#include <fcntl.h> | ||
5 | +#include <linux/rtc.h> | ||
2 | 6 | ||
3 | void System::setIP(System::IPData &data) | 7 | void System::setIP(System::IPData &data) |
4 | { | 8 | { |
@@ -27,3 +31,26 @@ void System::setVolume(int percentage) | @@ -27,3 +31,26 @@ void System::setVolume(int percentage) | ||
27 | QString command = QString("/usr/bin/amixer -c 0 sset 'PCM',0 %1% %1% on").arg(percentage); | 31 | QString command = QString("/usr/bin/amixer -c 0 sset 'PCM',0 %1% %1% on").arg(percentage); |
28 | system(command.toLocal8Bit().constData()); | 32 | system(command.toLocal8Bit().constData()); |
29 | } | 33 | } |
34 | + | ||
35 | + | ||
36 | + | ||
37 | + | ||
38 | +bool System::setRtcTime(QDateTime dt_tm){ | ||
39 | + int fd; | ||
40 | + rtc_time rt; | ||
41 | + rt.tm_year = dt_tm.date().year() - 1900; | ||
42 | + rt.tm_mon = dt_tm.date().month()-1; | ||
43 | + rt.tm_mday = dt_tm.date().day(); | ||
44 | + rt.tm_hour = dt_tm.time().hour(); | ||
45 | + rt.tm_min = dt_tm.time().minute(); | ||
46 | + rt.tm_sec = 0; | ||
47 | + | ||
48 | + fd = open("/dev/rtc0", O_WRONLY); | ||
49 | + if(fd <0){ | ||
50 | + return false; | ||
51 | + }{ | ||
52 | + ioctl(fd, RTC_SET_TIME, &rt); | ||
53 | + close(fd); | ||
54 | + return true; | ||
55 | + } | ||
56 | +} |
app/gui/oven_control/system.h
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | 3 | ||
4 | 4 | ||
5 | #include <QtCore> | 5 | #include <QtCore> |
6 | +#include <QDateTime> | ||
6 | 7 | ||
7 | namespace System { | 8 | namespace System { |
8 | struct IPData | 9 | struct IPData |
@@ -17,6 +18,9 @@ void setIP(IPData &data); | @@ -17,6 +18,9 @@ void setIP(IPData &data); | ||
17 | void setBacklight(int level); | 18 | void setBacklight(int level); |
18 | 19 | ||
19 | void setVolume(int percentage); | 20 | void setVolume(int percentage); |
21 | + | ||
22 | +bool setRtcTime(QDateTime dt_tm); | ||
23 | + | ||
20 | } | 24 | } |
21 | 25 | ||
22 | #endif // SYSTEM_H | 26 | #endif // SYSTEM_H |