int PROTOCOL_GetTelemetryState() { int telem_state = PROTO_TELEM_UNSUPPORTED; if(Model.protocol != PROTOCOL_NONE && PROTOCOL_LOADED) telem_state = (long)PROTO_Cmds(PROTOCMD_TELEMETRYSTATE); return telem_state; }
void PROTOCOL_DeInit() { CLOCK_StopTimer(); if(Model.protocol != PROTOCOL_NONE && PROTOCOL_LOADED) PROTO_Cmds(PROTOCMD_DEINIT); proto_state = PROTO_DEINIT; }
u32 PROTOCOL_CurrentID() { u32 id = 0; if(Model.protocol != PROTOCOL_NONE && PROTOCOL_LOADED) id = (unsigned long)PROTO_Cmds(PROTOCMD_CURRENT_ID); return id; }
int PROTOCOL_GetTelemetryType() { int telem_type = TELEM_DEVO; if(Model.protocol != PROTOCOL_NONE && PROTOCOL_LOADED) telem_type = (long)PROTO_Cmds(PROTOCMD_TELEMETRYTYPE); return telem_type; }
const u8* PROTOCOL_GetChannelMap() { const u8* channelmap = NULL; if(Model.protocol != PROTOCOL_NONE && PROTOCOL_LOADED) { int map = (int)PROTO_Cmds(PROTOCMD_CHANNELMAP); switch(map) { case (int)AETRG: channelmap = AETRG0; break; case (int)UNCHG: channelmap = NULL; break; case (int)TAERG: channelmap = TAERG0; break; case (int)EATRG: channelmap = EATRG0; break; default: printf("Unknown channemap: %d\n", map); } } return channelmap; }
void PROTOCOL_DeInit() { CLOCK_StopTimer(); if(Model.protocol != PROTOCOL_NONE && PROTOCOL_LOADED) PROTO_Cmds(PROTOCMD_DEINIT); CLOCK_StartMixer(); // run mixer on timer so channels are updated for things like calibration proto_state = PROTO_DEINIT; }
int PROTOCOL_DefaultNumChannels() { int num_channels = NUM_OUT_CHANNELS; if(Model.protocol != PROTOCOL_NONE && PROTOCOL_LOADED) num_channels = (unsigned long)PROTO_Cmds(PROTOCMD_DEFAULT_NUMCHAN); if (num_channels > NUM_OUT_CHANNELS) num_channels = NUM_OUT_CHANNELS; return num_channels; }
u8 PROTOCOL_AutoBindEnabled() { u8 binding = 0; if(Model.protocol == PROTOCOL_NONE || ! PROTOCOL_LOADED) binding = 1; else binding = (unsigned long)PROTO_Cmds(PROTOCMD_CHECK_AUTOBIND); return binding; }
void PROTOCOL_Bind() { if(! (proto_state & PROTO_INIT)) { PROTOCOL_Init(0); } if (! (proto_state & PROTO_READY)) { return; } if(Model.protocol != PROTOCOL_NONE && PROTOCOL_LOADED) PROTO_Cmds(PROTOCMD_BIND); }
void PROTOCOL_Init(u8 force) { if(! force && (proto_state & PROTO_MODULEDLG)) return; PROTOCOL_DeInit(); PROTOCOL_Load(0); proto_state = PROTO_INIT; if (! force && PROTOCOL_CheckSafe()) { return; } proto_state |= PROTO_READY; if(Model.protocol == PROTOCOL_NONE || ! PROTOCOL_LOADED) CLOCK_StopTimer(); else PROTO_Cmds(PROTOCMD_INIT); }
void PROTOCOL_InitModules() { #if HAS_MULTIMOD_SUPPORT int error = 0; const char * missing[TX_MODULE_LAST]; memset(missing, 0, sizeof(missing)); if (PROTOCOL_SetSwitch(TX_MODULE_LAST) == 0) { //No Switch found /* missing[MULTIMOD] = MODULE_NAME[MULTIMOD]; for(int i = 0; i < MULTIMOD; i++) { if(Transmitter.module_enable[i].port == SWITCH_ADDRESS) { error = 1; printf("Disabling %s because switch wasn't found\n", MODULE_NAME[i]); missing[i] = MODULE_NAME[i]; Transmitter.module_enable[i].port = 0; } } */ } int orig_proto = Model.protocol; for(int i = 0; i < MULTIMOD; i++) { if(Transmitter.module_enable[i].port) { for(int j = 1; j < PROTOCOL_COUNT; j++) { if (get_module(j) == i) { //Try this module Model.protocol = j; PROTOCOL_Load(1); if (! PROTOCOL_LOADED) continue; int res = (long)PROTO_Cmds(PROTOCMD_RESET); if (res == 0) continue; if (res < 0) { error = 1; missing[i] = MODULE_NAME[i]; if (! (Transmitter.extra_hardware & FORCE_MODULES)) Transmitter.module_enable[i].port = 0; } break; } } } } //Put this last because the switch will not respond until after it has been initialized if (Transmitter.module_enable[MULTIMOD].port && PROTOCOL_SetSwitch(TX_MODULE_LAST) == 0) { //No Switch found error = 1; missing[MULTIMOD] = MODULE_NAME[MULTIMOD]; } Model.protocol = orig_proto; if(error) { proto_state |= PROTO_MODULEDLG; PAGE_ShowModuleDialog(missing); } else #endif //HAS_MULTIMOD_SUPPORT { PROTOCOL_Init(0); } }
void PROTOCOL_SetOptions() { if(Model.protocol != PROTOCOL_NONE && PROTOCOL_LOADED) PROTO_Cmds(PROTOCMD_SETOPTIONS); }
void PROTOCOL_ResetTelemetry() { if(Model.protocol != PROTOCOL_NONE && PROTOCOL_LOADED) PROTO_Cmds(PROTOCMD_TELEMETRYRESET); }