replace Arecord with Qtmultimedia (requiers pulse?)

This commit is contained in:
IMback
2017-11-19 22:08:59 +01:00
parent a82a9459bc
commit 1dd7aca03b
16 changed files with 329 additions and 167 deletions

View File

@ -19,7 +19,7 @@ MainWindow::MainWindow(QSettings *settings, Microcontroller *micro , bool isRemo
//RGB Leds
connect(ui->presettApply, SIGNAL(clicked()), this, SLOT(slotApplyPreset()));
connect(&colorChooser, SIGNAL(currentColorChanged(const QColor)), this, SLOT(slotChangedRgb(const QColor)));
connect(&colorChooser, SIGNAL(colorSelected(const QColor)), this, SLOT(slotChangedRgb(const QColor)));
connect(ui->button_lightsOn, SIGNAL(clicked()), _micro, SLOT(rgbOn()));
connect(ui->button_lightsOff, SIGNAL(clicked()), _micro, SLOT(rgbOff()));
connect(ui->button_quit, SIGNAL(clicked()), this, SLOT(close()));
@ -32,24 +32,25 @@ MainWindow::MainWindow(QSettings *settings, Microcontroller *micro , bool isRemo
new QListWidgetItem(tr("Pattern 4 Sunrise"), ui->listWidget_patern);
//Relays
_relayCheckBoxes.push_back(ui->checkBox_amp);
_relayCheckBoxes.push_back(ui->checkBox_bspeaker);
_relayCheckBoxes.push_back(ui->checkBox_inf);
_relayCheckBoxes.push_back(ui->checkBox_aircon);
for(unsigned int i = 0; i < _relayCheckBoxes.size(); i++) connect(_relayCheckBoxes[i], SIGNAL(stateChanged(int)), this, SLOT(relayCheckBoxToggeled(int)));
//Amp
if(!isRemoteMode)connect(ui->checkBox_ampAuto, SIGNAL(stateChanged(int)), this, SLOT(slotAmpChkbtn(int)));
connect(ui->checkBox_amp, SIGNAL(stateChanged(int)), this, SLOT(slotAmpToggle(int)));
if(!isRemoteMode)connect(ui->checkBox_ampAuto, SIGNAL(stateChanged(int)), this, SLOT(slotAmpAutoToggle(int)));
//Bedroom Speakers
connect(ui->checkBox_bspeaker, SIGNAL(stateChanged(int)), this, SLOT(slotBSpeakerToggle(int)));
if(!isRemoteMode)connect(ui->checkBox_bspeakerAuto, SIGNAL(stateChanged(int)), this, SLOT(slotBSpeakerAutoToggle(int)));
//Infinity Mirror
connect(ui->checkBox_inf, SIGNAL(stateChanged(int)), this, SLOT(slotInfMirrorToggle(int)));
if(!isRemoteMode)connect(ui->checkBox_infAuto, SIGNAL(stateChanged(int)), this, SLOT(slotInfMirrorAutoToggle(int)));
//Airconditioner
connect(ui->checkBox_aircon, SIGNAL(stateChanged(int)), this, SLOT(slotAirconToggle(int)));
if(!isRemoteMode)
{
//Alarm
@ -72,18 +73,21 @@ void MainWindow::remoteMode()
{
ui->alarmTime->setEnabled(false);
ui->checkBox_alarm->setEnabled(false);
ui->label_alarm->setEnabled(false);
ui->pushButton_alarm->setEnabled(false);
ui->nightTime->setEnabled(false);
ui->checkBox_nightTime->setEnabled(false);
ui->label_nightTime->setEnabled(false);
ui->checkBox_ampAuto->setEnabled(false);
ui->checkBox_ampAuto->setChecked(false);
ui->checkBox_bspeakerAuto->setEnabled(false);
ui->checkBox_amp->setEnabled(true);
ui->checkBox_bspeaker->setEnabled(true);
ui->checkBox_inf->setEnabled(true);
ui->checkBox_inf->setChecked(false);
ui->checkBox_infAuto->setEnabled(false);
ui->checkBox_infAuto->setChecked(false);
}
void MainWindow::postActivate()
@ -106,9 +110,9 @@ void MainWindow::slotChangedRgb(const QColor color)
if( color.redF() < 0.2 && color.greenF() < 0.2 && color.blueF() > 0.8 )
{
qDebug()<<"Auto turn on inf mirror\n";
slotInfMirrorToggle(true);
_micro->relayOn(2);
}
else slotInfMirrorToggle(false);
else _micro->relayOff(2);
}
}
@ -118,14 +122,20 @@ void MainWindow::slotApplyPreset()
if(ui->listWidget_patern->selectedItems().count() == 1) _micro->setPattern(ui->listWidget_patern->currentRow());
}
void MainWindow::slotAmpToggle(int state)
void MainWindow::relayCheckBoxToggeled(int state)
{
_micro->relayToggle(state, 0);
for(unsigned int i = 0; i < _relayCheckBoxes.size(); i++)
if(_relayCheckBoxes[i] == sender()) _micro->relayToggle(state, i);
}
void MainWindow::slotBSpeakerToggle(int state)
void MainWindow::relayStateChanged(std::vector<bool> relayStates)
{
_micro->relayToggle(state, 1);
if(relayStates.size() >= 4) for(unsigned int i = 0; i < _relayCheckBoxes.size(); i++)
{
_relayCheckBoxes[i]->blockSignals(true);
_relayCheckBoxes[i]->setChecked(relayStates[i]);
_relayCheckBoxes[i]->blockSignals(false);
}
}
void MainWindow::slotBSpeakerAutoToggle(int state)
@ -133,26 +143,15 @@ void MainWindow::slotBSpeakerAutoToggle(int state)
ui->checkBox_bspeaker->setEnabled(!state);
}
void MainWindow::slotInfMirrorToggle(int state)
{
_micro->relayToggle(state, 2);
}
void MainWindow::slotInfMirrorAutoToggle(int state)
{
ui->checkBox_inf->setEnabled(!state);
if(!state)
{
slotInfMirrorToggle(ui->checkBox_inf->isChecked());
_micro->relayToggle(ui->checkBox_inf->isChecked(), 2);
}
}
void MainWindow::slotAirconToggle(int state)
{
_micro->relayToggle(state, 3);
}
void MainWindow::slotChangedAlarmTime(const QTime time)
{
_settings->setValue("alarmTime", time);
@ -170,7 +169,7 @@ void MainWindow::slotChangedNightTime(const QTime time)
signalAlmNightChanged(time);
}
void MainWindow::slotAmpChkbtn(int state)
void MainWindow::slotAmpAutoToggle(int state)
{
ui->checkBox_amp->setEnabled(!state);
if(state)
@ -180,7 +179,7 @@ void MainWindow::slotAmpChkbtn(int state)
else
{
signalAmpOff();
slotAmpToggle(ui->checkBox_amp->checkState());
_micro->relayToggle(ui->checkBox_amp->checkState(), 0);
}
}
@ -188,15 +187,3 @@ void MainWindow::changeHeaderLableText(const QString string)
{
ui->label_serialRecive->setText(string);
}
void MainWindow::slotSyncoff()
{
qDebug()<<"Power Off on alarm\n";
_settings->sync();
slotAmpToggle(false);
slotBSpeakerToggle(false);
slotInfMirrorToggle(false);
slotAirconToggle(false);
QProcess::execute ( "syncoff" );
}