static int _adjust_src_for_telemetry(int src, int dir) { if (src > NUM_RTC + NUM_TIMERS && src <= NUM_RTC + NUM_TIMERS + NUM_TELEM) { if (PROTOCOL_GetTelemetryState() != PROTO_TELEM_ON) { //We chose a telemetry item, but there is no telemetry src = (dir > 0) ? NUM_RTC + NUM_TIMERS + NUM_TELEM + 1 : NUM_RTC + NUM_TIMERS; } else { int max = TELEMETRY_GetNumTelemSrc(); if (src > NUM_RTC + NUM_TIMERS + max) { src = (dir > 0) ? NUM_RTC + NUM_TIMERS + NUM_TELEM + 1 : NUM_RTC + NUM_TIMERS + max; } } } return src; }
u8 PAGE_TelemStateCheck(char *str, int strlen) { (void)strlen; s8 state = PROTOCOL_GetTelemetryState(); if (state == -1) { sprintf(str, "%s%s%s", _tr("Telemetry"), LCD_DEPTH == 1?"\n":" ", // no translate for this string _tr("is not supported")); return 0; } else if (state == 0) { sprintf(str, "%s%s%s", _tr("Telemetry"), LCD_DEPTH == 1?"\n":" ", // no translate for this string _tr("is turned off")); return 0; } return 1; }
void PROTOCOL_Load(int no_dlg) { (void)no_dlg; #ifdef ENABLE_MODULAR FATFS ModuleFAT; FILE *fh; if(! PROTOCOL_HasModule(Model.protocol)) { *loaded_protocol = 0; return; } if(*loaded_protocol == Model.protocol) return; char file[25]; strcpy(file, "protocol/"); if (Model.protocol > PROTOCOL_COUNT) { *loaded_protocol = 0; return; } else { strcat(file, Protocols[Model.protocol].name); } file[17] = '\0'; //truncate filename to 8 characters strcat(file, ".mod"); memset(&ModuleFAT, 0, sizeof(ModuleFAT)); finit(&ModuleFAT, "protocol"); fh = fopen2(&ModuleFAT, file, "r"); //printf("Loading %s: %08lx\n", file, fh); if(! fh) { if(! no_dlg) { sprintf(tempstring, "Misisng protocol:\n%s", file); PAGE_ShowWarning(NULL, tempstring); } return; } setbuf(fh, 0); fread(loaded_protocol, 1, 4 * 1024, fh); fclose(fh); if ((unsigned long)&_data_loadaddr != *loaded_protocol) { if(! no_dlg) { sprintf(tempstring, "Protocol Mismatch:\n%08x\n%08x", (unsigned long)&_data_loadaddr, *loaded_protocol); PAGE_ShowWarning(NULL, tempstring); } *loaded_protocol = 0; return; } //printf("Updated %d (%d) bytes: Data: %08lx %08lx %08lx\n", size, len, *loaded_protocol, *(loaded_protocol+1), *(loaded_protocol+2)); //We use the same file for multiple protocols, so we need to manually set this here *loaded_protocol = Model.protocol; #else if(! PROTOCOL_HasModule(Model.protocol)) { PROTO_Cmds = NULL; printf("Module is not defined!\n"); return; } PROTO_Cmds = Protocols[Model.protocol].cmd; #endif PROTOCOL_SetSwitch(get_module(Model.protocol)); if (PROTOCOL_GetTelemetryState() != PROTO_TELEM_UNSUPPORTED) { memset(&Telemetry, 0, sizeof(Telemetry)); TELEMETRY_SetType(PROTOCOL_GetTelemetryType()); } CurrentProtocolChannelMap = PROTOCOL_GetChannelMap(); }