jvalerio
17th December 2014, 22:45
Hello,
I have a program that communicates with an Arduino board and have made a simple protocol. Now I'm trying to automate things and want some advice on how to accomplish my current task.
So Basically I have the below function which when called sends data over to the Aurdino telling it which pin to turn on. So the idea is to update the QLabel with a stat_sBy button. This is a yellow .png image and there are other states I will work with later. But I'm getting a error as I'm not sure what to use to Automate the process for replacing the QLabel Objecname in the loop.
void MainWindow::TestIOPCB()
{
QPixmap stat_OFF (":/res/images/stat_OFF.png");
QPixmap stat_noGO (":/res/images/stat_noGO.png");
QPixmap stat_GO (":/res/images/stat_GO.png");
QPixmap stat_sBy (":/res/images/stat_sBy.png");
QByteArray testOuts;
testOuts.resize(4);
testOuts[0] = 24v_ena;
testOuts[1] = spare_cmd;
testOuts[2] = shut_cmd;
testOuts[3] = mux_cmd;
QStringList testLabels;
testLabels << "Label25" << "Laberl45";
char db0 = 0x53;
char db1 = 0x50;
//Initiate I/O Tests
for (int x = 0; x < 4; x++)
{
setOutput(db0, 0x48, db1, testOuts[x]);
ui->testLabels[x]->setPixmap(stat_sBy);
//The below works fine, but I have too many ports and want to simplify a little.//
/*
setOutput(db0, 0x48, db1, shutter_cmd);
ui->label_27->setPixmap(stat_sBy);
setOutput(db0, 0x48, db1, mux_1064_cmd);
ui->label_28->setPixmap(stat_sBy);
setOutput(db0, 0x48, db1, mux_532_cmd);
ui->label_29->setPixmap(stat_sBy);
setOutput(db0, 0x48, db1, amp_atten_cmd);
ui->label_30->setPixmap(stat_sBy);
*/
}
}
I have a program that communicates with an Arduino board and have made a simple protocol. Now I'm trying to automate things and want some advice on how to accomplish my current task.
So Basically I have the below function which when called sends data over to the Aurdino telling it which pin to turn on. So the idea is to update the QLabel with a stat_sBy button. This is a yellow .png image and there are other states I will work with later. But I'm getting a error as I'm not sure what to use to Automate the process for replacing the QLabel Objecname in the loop.
void MainWindow::TestIOPCB()
{
QPixmap stat_OFF (":/res/images/stat_OFF.png");
QPixmap stat_noGO (":/res/images/stat_noGO.png");
QPixmap stat_GO (":/res/images/stat_GO.png");
QPixmap stat_sBy (":/res/images/stat_sBy.png");
QByteArray testOuts;
testOuts.resize(4);
testOuts[0] = 24v_ena;
testOuts[1] = spare_cmd;
testOuts[2] = shut_cmd;
testOuts[3] = mux_cmd;
QStringList testLabels;
testLabels << "Label25" << "Laberl45";
char db0 = 0x53;
char db1 = 0x50;
//Initiate I/O Tests
for (int x = 0; x < 4; x++)
{
setOutput(db0, 0x48, db1, testOuts[x]);
ui->testLabels[x]->setPixmap(stat_sBy);
//The below works fine, but I have too many ports and want to simplify a little.//
/*
setOutput(db0, 0x48, db1, shutter_cmd);
ui->label_27->setPixmap(stat_sBy);
setOutput(db0, 0x48, db1, mux_1064_cmd);
ui->label_28->setPixmap(stat_sBy);
setOutput(db0, 0x48, db1, mux_532_cmd);
ui->label_29->setPixmap(stat_sBy);
setOutput(db0, 0x48, db1, amp_atten_cmd);
ui->label_30->setPixmap(stat_sBy);
*/
}
}