Example #1
0
void remote_init(remote_t* remote, const remote_conf_t* config, const mavlink_stream_t* mavlink_stream, mavlink_message_handler_t *mavlink_handler)
{
    // Init dependencies
    remote->mavlink_stream = mavlink_stream;
    remote->sat = spektrum_satellite_get_pointer();

    // Init mode from remote
    remote_mode_init( &remote->mode, &config->mode_config );

    // Init parameters according to remote type
    remote->type = config->type;
    switch ( remote->type )
    {
    case REMOTE_TURNIGY:
        remote->scale = 1.0f / 880.0f;
        remote->deadzone = 30;

        remote->channel_inv[CHANNEL_THROTTLE] = NORMAL;
        remote->channel_inv[CHANNEL_ROLL]     = NORMAL;
        remote->channel_inv[CHANNEL_PITCH]    = INVERTED;
        remote->channel_inv[CHANNEL_YAW]      = NORMAL;
        remote->channel_inv[CHANNEL_GEAR]     = INVERTED;
        remote->channel_inv[CHANNEL_FLAPS]    = INVERTED;
        remote->channel_inv[CHANNEL_AUX1]     = NORMAL;
        remote->channel_inv[CHANNEL_AUX2]     = NORMAL;
        break;

    case REMOTE_SPEKTRUM:
        remote->scale = 1.0f / 700.0f;
        remote->deadzone = 30;

        remote->channel_inv[CHANNEL_THROTTLE] = NORMAL;
        remote->channel_inv[CHANNEL_ROLL]     = INVERTED;
        remote->channel_inv[CHANNEL_PITCH]    = NORMAL;
        remote->channel_inv[CHANNEL_YAW]      = NORMAL;
        remote->channel_inv[CHANNEL_GEAR]     = NORMAL;
        remote->channel_inv[CHANNEL_FLAPS]    = NORMAL;
        remote->channel_inv[CHANNEL_AUX1]     = NORMAL;
        remote->channel_inv[CHANNEL_AUX2]     = NORMAL;
        break;
    }

    // Init
    remote->signal_quality = SIGNAL_GOOD;
    for ( uint8_t i = 0; i < REMOTE_CHANNEL_COUNT; i++)
    {
        remote->channels[i] = 0.0f;
        remote->trims[i] = 0.0f;
    }

    mavlink_message_handler_cmd_callback_t callbackcmd;

    callbackcmd.command_id    = MAV_CMD_START_RX_PAIR; // 500
    callbackcmd.sysid_filter  = MAV_SYS_ID_ALL;
    callbackcmd.compid_filter = MAV_COMP_ID_ALL;
    callbackcmd.compid_target = MAV_COMP_ID_ALL;
    callbackcmd.function      = (mavlink_cmd_callback_function_t)	&spektrum_satellite_bind;
    callbackcmd.module_struct =										remote->sat;
    mavlink_message_handler_add_cmd_callback(mavlink_handler, &callbackcmd);
}
Example #2
0
void remote_init(remote_t* remote, const remote_conf_t* config)
{
	// Init mode from remote
	remote_mode_init( &remote->mode, &config->mode_config );

	// Init parameters according to remote type
	remote->type = config->type;
	switch ( remote->type )
	{
		case REMOTE_TURNIGY:
			remote->scale = 1.0f / 880.0f;
			remote->deadzone = 30;

			remote->channel_inv[CHANNEL_THROTTLE] = NORMAL;
			remote->channel_inv[CHANNEL_ROLL]     = NORMAL;
			remote->channel_inv[CHANNEL_PITCH]    = INVERTED;
			remote->channel_inv[CHANNEL_YAW]      = NORMAL;
			remote->channel_inv[CHANNEL_GEAR]     = INVERTED;
			remote->channel_inv[CHANNEL_FLAPS]    = INVERTED;
			remote->channel_inv[CHANNEL_AUX1]     = NORMAL;
			remote->channel_inv[CHANNEL_AUX2]     = NORMAL;
			break;

		case REMOTE_SPEKTRUM:
			remote->scale = 1.0f / 700.0f;
			remote->deadzone = 30;

			remote->channel_inv[CHANNEL_THROTTLE] = NORMAL;
			remote->channel_inv[CHANNEL_ROLL]     = INVERTED;
			remote->channel_inv[CHANNEL_PITCH]    = NORMAL;
			remote->channel_inv[CHANNEL_YAW]      = NORMAL;
			remote->channel_inv[CHANNEL_GEAR]     = NORMAL;
			remote->channel_inv[CHANNEL_FLAPS]    = NORMAL;
			remote->channel_inv[CHANNEL_AUX1]     = NORMAL;
			remote->channel_inv[CHANNEL_AUX2]     = NORMAL;
			break;
	}

	// Init 
	remote->signal_quality = SIGNAL_GOOD;
	for ( uint8_t i = 0; i < REMOTE_CHANNEL_COUNT; i++)
	{
		remote->channels[i] = 0.0f;
		remote->trims[i] = 0.0f;
	}
}