1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 17:25:13 +03:00

Refactoring FirmwareInterface / EepromInterface

This commit is contained in:
bsongis 2014-04-18 16:24:02 +02:00
parent 7dd9e2d1e2
commit c5ac19a054
51 changed files with 810 additions and 1143 deletions

View file

@ -66,9 +66,9 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
addEmptyLabel(gridLayout, 5 );
lock = true;
int num_fsw = GetEepromInterface()->getCapability(CustomFunctions);
int num_fsw = GetCurrentFirmware()->getCapability(CustomFunctions);
if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) {
if (!GetCurrentFirmware()->getCapability(VoicesAsNumbers)) {
for (int i=0; i<num_fsw; i++) {
if (model.funcSw[i].func==FuncPlayPrompt || model.funcSw[i].func==FuncBackgroundMusic) {
QString temp = model.funcSw[i].paramarm;
@ -87,7 +87,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
lang="en";
path.append(lang);
QDir qd(path);
int vml= GetEepromInterface()->getCapability(VoicesMaxLength)+4;
int vml= GetCurrentFirmware()->getCapability(VoicesMaxLength)+4;
if (qd.exists()) {
QStringList filters;
filters << "*.wav" << "*.WAV";
@ -227,7 +227,7 @@ void CustomFunctionsPanel::playMusic()
QDir qd(path);
QString track;
if (qd.exists()) {
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
if (GetCurrentFirmware()->getCapability(VoicesAsNumbers)) {
track = path + QString("/%1.wav").arg(int(fswtchParam[index]->value()), 4, 10, (const QChar)'0');
}
else {
@ -360,7 +360,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE;
}
else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) {
if (index != FuncBackgroundMusic && GetCurrentFirmware()->getCapability(HasFuncRepeat)) {
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
fswtchRepeat[i]->update();
}
@ -370,7 +370,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT;
}
else if (index==FuncPlayPrompt || index==FuncPlayBoth) {
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
if (GetCurrentFirmware()->getCapability(VoicesAsNumbers)) {
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(0);
@ -407,7 +407,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) {
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm));
int vml = GetEepromInterface()->getCapability(VoicesMaxLength);
int vml = GetCurrentFirmware()->getCapability(VoicesMaxLength);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(), vml); j++) {
@ -427,7 +427,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) {
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm));
int vml=GetEepromInterface()->getCapability(VoicesMaxLength);
int vml=GetCurrentFirmware()->getCapability(VoicesMaxLength);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(),vml); j++) {
@ -476,7 +476,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
void CustomFunctionsPanel::update()
{
lock = true;
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
for (int i=0; i<GetCurrentFirmware()->getCapability(CustomFunctions); i++) {
if (!initialized) {
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, generalSettings, POPULATE_ONOFF);
populateFuncCB(fswtchFunc[i], model.funcSw[i].func);
@ -562,24 +562,24 @@ void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
b->clear();
for (unsigned int i=0; i<FuncCount; i++) {
b->addItem(FuncSwData(AssignFunc(i)).funcToString());
if (!GetEepromInterface()->getCapability(HasVolume)) {
if (!GetCurrentFirmware()->getCapability(HasVolume)) {
if (i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
if ((i==FuncPlayHaptic) && !GetEepromInterface()->getCapability(Haptic)) {
if ((i==FuncPlayHaptic) && !GetCurrentFirmware()->getCapability(Haptic)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncPlayBoth) && !GetEepromInterface()->getCapability(HasBeeper)) {
if ((i==FuncPlayBoth) && !GetCurrentFirmware()->getCapability(HasBeeper)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncLogs) && !GetEepromInterface()->getCapability(HasSDLogs)) {
if ((i==FuncLogs) && !GetCurrentFirmware()->getCapability(HasSDLogs)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
@ -640,7 +640,7 @@ void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & m
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
int reCount = GetEepromInterface()->getCapability(RotaryEncoders);
int reCount = GetCurrentFirmware()->getCapability(RotaryEncoders);
if (reCount == 1) {
qs.append( QObject::tr("Rotary Encoder"));
}