added cyclic update
This commit is contained in:
@@ -20,13 +20,14 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
ui->txt_address->setText(DEFAULT_ADDRESS);
|
||||
mAddress = ui->txt_address->text();
|
||||
|
||||
connect(&mTimer, &QTimer::timeout, this, &MainWindow::sendVolume);
|
||||
mTimer.setSingleShot(true);
|
||||
// setup volume value collection
|
||||
connect(&mTimerValCollect, &QTimer::timeout, this, &MainWindow::sendVolume);
|
||||
mTimerValCollect.setSingleShot(true);
|
||||
|
||||
// load initial data
|
||||
sendCommand("<YAMAHA_AV cmd=\"GET\"><System><Power_Control><Power>GetParam</Power></Power_Control></System></YAMAHA_AV>");
|
||||
sendCommand("<YAMAHA_AV cmd=\"GET\"><Main_Zone><Volume><Lvl>GetParam</Lvl></Volume></Main_Zone></YAMAHA_AV>");
|
||||
sendCommand("<YAMAHA_AV cmd=\"GET\"><Main_Zone><Input><Input_Sel>GetParam</Input_Sel></Input></Main_Zone></YAMAHA_AV>");
|
||||
// load initial data and set update rate
|
||||
updateAVState();
|
||||
connect(&mTimerUpdate, &QTimer::timeout, this, &MainWindow::updateAVState);
|
||||
mTimerUpdate.start(UPDATETIME);
|
||||
|
||||
QFile css(":style.css");
|
||||
if (css.open(QFile::ReadOnly | QFile::Text))
|
||||
@@ -130,10 +131,8 @@ void MainWindow::setPowerState()
|
||||
ui->dial->setStyleSheet("");
|
||||
setActiveButton("");
|
||||
}
|
||||
qDebug() << ui->btn_onoff->isEnabled(); // rogo: delete
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_txt_address_textEdited(const QString &arg1)
|
||||
{
|
||||
mAddress = arg1;
|
||||
@@ -164,7 +163,7 @@ void MainWindow::on_dial_valueChanged(int value)
|
||||
|
||||
ui->lbl_volume->setText(QString::number(value));
|
||||
mVolume = value;
|
||||
mTimer.start(WAITTIME);
|
||||
mTimerValCollect.start(COLLECTTIME);
|
||||
}
|
||||
|
||||
void MainWindow::sendVolume()
|
||||
@@ -174,6 +173,13 @@ void MainWindow::sendVolume()
|
||||
+ "</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>");
|
||||
}
|
||||
|
||||
void MainWindow::updateAVState()
|
||||
{
|
||||
sendCommand("<YAMAHA_AV cmd=\"GET\"><System><Power_Control><Power>GetParam</Power></Power_Control></System></YAMAHA_AV>");
|
||||
sendCommand("<YAMAHA_AV cmd=\"GET\"><Main_Zone><Volume><Lvl>GetParam</Lvl></Volume></Main_Zone></YAMAHA_AV>");
|
||||
sendCommand("<YAMAHA_AV cmd=\"GET\"><Main_Zone><Input><Input_Sel>GetParam</Input_Sel></Input></Main_Zone></YAMAHA_AV>");
|
||||
}
|
||||
|
||||
void MainWindow::on_btn_hdmi1_clicked()
|
||||
{
|
||||
sendCommand("<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Input><Input_Sel>HDMI1</Input_Sel></Input></Main_Zone></YAMAHA_AV>");
|
||||
|
||||
Reference in New Issue
Block a user