-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.cpp
executable file
·60 lines (49 loc) · 1.93 KB
/
status.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "status.h"
#include "ui_status.h"
#include <QDateTime>
#include <wiringPi.h>
#include <QFile>
#include "raspiDevice/raspiTemp.h"
Status::Status(QWidget *parent) :
QWidget(parent),
ui(new Ui::Status)
{
ui->setupUi(this);
//myDataFormat = STATUS_YEAR_MONTH_DAY_24;
connect(RaspiTemp::instance(),SIGNAL(sendTemp(QString)),this,SLOT(updateTemp(QString)));
RaspiTemp::instance()->start();
connect(&myTime,SIGNAL(timeout()),this,SLOT(updateDate()));
myTime.start(1000);
}
Status::~Status()
{
delete ui;
}
void Status::updateDate()
{
switch(myDataFormat)
{
case STATUS_YEAR_MONTH_DAY_24:
ui->label_time->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")); break;
case STATUS_YEAR_MONTH_DAY_12:
ui->label_time->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd h:mm:ss AP")); break;
case STATUS_MONTH_DAY_YEAR_24:
ui->label_time->setText(QDateTime::currentDateTime().toString("MM-dd-yyyy hh:mm:ss")); break;
case STATUS_MONTH_DAY_YEAR_12:
ui->label_time->setText(QDateTime::currentDateTime().toString("MM-dd-yyyy h:mm:ss AP")); break;
case STATUS_YEAR__MONTH__DAY_24:
ui->label_time->setText(QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss")); break;
case STATUS_YEAR__MONTH__DAY_12:
ui->label_time->setText(QDateTime::currentDateTime().toString("yyyy/MM/dd h:mm:ss AP")); break;
case STATUS_MONTH__DAY__YEAR_24:
ui->label_time->setText(QDateTime::currentDateTime().toString("MM/dd/yyyy hh:mm:ss")); break;
case STATUS_MONTH__DAY__YEAR_12:
ui->label_time->setText(QDateTime::currentDateTime().toString("MM/dd/yyyy h:mm:ss AP")); break;
default:
ui->label_time->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")); break;
}
}
void Status::updateTemp(QString temp)
{
ui->label_temp->setText(temp + " °C");
}