void printDialog::printSwitches() { QString str = tr("<h2>Custom Switches</h2>"); str.append("<table border=1 cellspacing=0 cellpadding=3>"); // str.append("<tr>"); // str.append(doTC(" ")); // str.append(doTC(tr("Source"), "", true)); // str.append(doTC(tr("Offset"), "", true)); // str.append(doTC(tr("Function"), "", true)); // str.append("</tr>"); for(int i=0; i<NUM_SKYCSW; i++) { str.append("<tr>"); str.append(doTC(tr("SW%1").arg(i+1),"",true)); QString tstr; if(g_model->customSw[i].func) { switch (CS_STATE(g_model->customSw[i].func, g_model->modelVersion)) { case CS_VOFS: tstr = g_model->customSw[i].v1 ? getSourceStr(g_eeGeneral->stickMode,g_model->customSw[i].v1, 0, 0) : "0"; tstr.remove(" "); if(g_model->customSw[i].func==CS_APOS || g_model->customSw[i].func==CS_ANEG) tstr = "|" + tstr + "|"; if(g_model->customSw[i].func==CS_APOS || g_model->customSw[i].func==CS_VPOS) tstr += " > "; if(g_model->customSw[i].func==CS_ANEG || g_model->customSw[i].func==CS_VNEG) tstr += " < "; tstr += QString::number(g_model->customSw[i].v2); break; case CS_VBOOL: tstr = getSWName(g_model->customSw[i].v1,0); switch (g_model->customSw[i].func) { case CS_AND: tstr += " AND "; break; case CS_OR: tstr += " OR "; break; case CS_XOR: tstr += " XOR "; break; default: break; } tstr += getSWName(g_model->customSw[i].v2,0); break; case CS_VCOMP: tstr = g_model->customSw[i].v1 ? getSourceStr(g_eeGeneral->stickMode,g_model->customSw[i].v1, 0, 0) : "0"; switch (g_model->customSw[i].func) { case CS_EQUAL: tstr += " = "; break; case CS_NEQUAL: tstr += " != "; break; case CS_GREATER: tstr += " > "; break; case CS_LESS: tstr += " < "; break; case CS_EGREATER: tstr += " >= "; break; case CS_ELESS: tstr += " <= "; break; default: break; } tstr += g_model->customSw[i].v2 ? getSourceStr(g_eeGeneral->stickMode,g_model->customSw[i].v2, 0, 0) : "0"; break; default: break; } } str.append(doTC(tstr,"green")); str.append("</tr>"); } str.append("</table>"); str.append("<br><br>"); te->append(str); }
void eeLoadModel(uint8_t id) { if(id<MAX_MODELS) { theFile.openRd(FILE_MODEL(id)); memset(&g_model, 0, sizeof(ModelData)); uint16_t sz = theFile.readRlc((uint8_t*)&g_model, sizeof(g_model)); if(sz<256) // if not loaded a fair amount { modelDefaultWrite(id); } validateName( g_model.name, sizeof(g_model.name) ) ; // for(uint8_t i=0; i<sizeof(g_model.name);i++) // makes sure name is valid // { // uint8_t idx = char2idx(g_model.name[i]); // g_model.name[i] = idx2char(idx); // } if ( g_model.numBlades == 0 ) { g_model.numBlades = g_model.xnumBlades + 2 ; } #ifdef FRSKY FrskyAlarmSendState |= 0x40 ; // Get RSSI Alarms FRSKY_setModelAlarms(); #endif #ifdef FIX_MODE // check for updating mix sources if ( g_model.modelVersion < 2 ) { for(uint8_t i=0;i<MAX_MIXERS;i++) { MixData *md = mixaddress( i ) ; if (md->srcRaw) { if (md->srcRaw <= 4) // Stick { md->srcRaw = modeFixValue( md->srcRaw-1 ) ; } } } for (uint8_t i = 0 ; i < NUM_CSW ; i += 1 ) { CSwData *cs = &g_model.customSw[i]; uint8_t cstate = CS_STATE(cs->func); uint8_t t = 0 ; if(cstate == CS_VOFS) { t = 1 ; } else if(cstate == CS_VCOMP) { t = 1 ; if (cs->v2) { if (cs->v2 <= 4) // Stick { cs->v2 = modeFixValue( cs->v2-1 ) ; } } } if ( t ) { if (cs->v1) { if (cs->v1 <= 4) // Stick { cs->v1 = modeFixValue( cs->v1-1 ) ; } } } } #if defined(CPUM128) || defined(CPUM2561) for (uint8_t i = NUM_CSW ; i < NUM_CSW+EXTRA_CSW ; i += 1 ) { CxSwData *cs = &g_model.xcustomSw[i-NUM_CSW]; uint8_t cstate = CS_STATE(cs->func); uint8_t t = 0 ; if(cstate == CS_VOFS) { t = 1 ; } else if(cstate == CS_VCOMP) { t = 1 ; if (cs->v2) { if (cs->v2 <= 4) // Stick { cs->v2 = modeFixValue( cs->v2-1 ) ; } } } if ( t ) { if (cs->v1) { if (cs->v1 <= 4) // Stick { cs->v1 = modeFixValue( cs->v1-1 ) ; } } } } #endif // CPUs memmove( &Xmem.texpoData, &g_model.expoData, sizeof(Xmem.texpoData) ) ; for (uint8_t i = 0 ; i < 4 ; i += 1 ) { uint8_t dest = modeFixValue( i ) - 1 ; memmove( &g_model.expoData[dest], &Xmem.texpoData[i], sizeof(Xmem.texpoData[0]) ) ; } // sort expo/dr here alert(PSTR("CHECK MIX/DR SOURCES")); g_model.modelVersion = 2 ; eeDirty( EE_MODEL ) ; eeWaitComplete() ; } #endif // FIX_MODE #ifdef VERSION3 if ( g_model.modelVersion < 3 ) { for (uint8_t i = 0 ; i < NUM_CSW ; i += 1 ) { CSwData *cs = &g_model.customSw[i]; if ( cs->func == CS_LATCH ) { cs->func = CS_GREATER ; } if ( cs->func == CS_FLIP ) { cs->func = CS_LESS ; } } #if defined(CPUM128) || defined(CPUM2561) for (uint8_t i = NUM_CSW ; i < NUM_CSW+EXTRA_CSW ; i += 1 ) { CxSwData *cs = &g_model.xcustomSw[i-NUM_CSW]; if ( cs->func == CS_LATCH ) { cs->func = CS_GREATER ; } if ( cs->func == CS_FLIP ) { cs->func = CS_LESS ; } } #endif // CPUs g_model.modelVersion = 3 ; eeDirty( EE_MODEL ) ; eeWaitComplete() ; } #endif #ifdef VERSION4 if ( g_model.modelVersion < 4 ) { g_model.switchWarningStates = g_eeGeneral.switchWarningStates ; alert(PSTR("CHECK MODEL TIMERS")); g_model.modelVersion = 4 ; eeDirty( EE_MODEL ) ; eeWaitComplete() ; } #endif // VERSION4 } TimerMode *ptConfig = TimerConfig ; FORCE_INDIRECT(ptConfig) ; ptConfig->tmrModeA = g_model.tmrMode ; ptConfig->tmrModeB = g_model.tmrModeB ; ptConfig->tmrVal = g_model.tmrVal ; ptConfig->tmrDir = g_model.tmrDir ; ptConfig += 1 ; ptConfig->tmrModeA = g_model.tmr2Mode ; ptConfig->tmrModeB = g_model.tmr2ModeB ; ptConfig->tmrVal = g_model.tmr2Val ; ptConfig->tmrDir = g_model.tmr2Dir ; resetTimer1() ; resetTimer2() ; asm("") ; }