CP2130 Configurator (cp2130-conf) is an application that can be used to configure CP2130 devices, including VID, PID, as well as other descriptors. Most importantly, the application allows you to configure pin functions and states.
In the present moment, inside "configuratorwindow.cpp", from lines 98 to 111, we have on_actionInformation_triggered() implemented as follows:
void ConfiguratorWindow::on_actionInformation_triggered()
{
int errcnt = 0;
QString errstr;
InformationDialog infoDialog;
CP2130::SiliconVersion siversion = cp2130_.getSiliconVersion(errcnt, errstr);
infoDialog.setSiliconVersionLabelText(siversion.maj, siversion.min);
opCheck(tr("device-information-retrieval-op"), errcnt, errstr); // The string "device-information-retrieval-op" should be translated to "Device information retrieval"
if (err_) { // Fix implemented in version 1.2
handleError();
} else { // If error check passes
infoDialog.exec();
}
}
However, in this particular case, we can declare and assign infoDialog if and only if opCheck() passes. Thus, it is possible to refactor the above function, like this:
void ConfiguratorWindow::on_actionInformation_triggered()
{
int errcnt = 0;
QString errstr;
CP2130::SiliconVersion siversion = cp2130_.getSiliconVersion(errcnt, errstr);
opCheck(tr("device-information-retrieval-op"), errcnt, errstr); // The string "device-information-retrieval-op" should be translated to "Device information retrieval"
if (err_) { // Fix implemented in version 1.2
handleError();
} else { // If error check passes
InformationDialog infoDialog;
infoDialog.setSiliconVersionLabelText(siversion.maj, siversion.min);
infoDialog.exec();
}
}
In the present moment, inside "configuratorwindow.cpp", from lines 98 to 111, we have on_actionInformation_triggered() implemented as follows:
However, in this particular case, we can declare and assign infoDialog if and only if opCheck() passes. Thus, it is possible to refactor the above function, like this: