Beispiel #1
0
void sio_newMsg( unsigned char inchar )
{
	if ( inchar == 'V' )
	{
		sio_parse = &sio_voltage_high ;
	}
	
#if ( FLIGHT_PLAN_TYPE == FP_LOGO )
	else if ( inchar == 'L' )
#else
	else if ( inchar == 'W' )
#endif
	{
		fp_high_byte = -1 ; // -1 means we don't have the high byte yet (0-15 means we do)
		fp_checksum = 0 ;
		sio_parse = &sio_fp_data ;
		flightplan_live_begin() ;
	}
#if (CAM_USE_EXTERNAL_TARGET_DATA == 1)
	else if ( inchar == 'T' )
	{
		fp_high_byte = -1 ; // -1 means we don't have the high byte yet (0-15 means we do)
		fp_checksum = 0 ;
		sio_parse = &sio_cam_data ;
		camera_live_begin() ;
	}
#endif
	else
	{
		// error ?
	}
	return ;
}
Beispiel #2
0
void sio_newMsg(uint8_t inchar)
{
	switch (inchar)
	{
	case 'V':
		sio_parse = &sio_voltage_high;
		break;
	
#if (FLIGHT_PLAN_TYPE == FP_LOGO)
	case 'L':
#else
	case 'W':
#endif
		fp_high_byte = -1; // -1 means we don't have the high byte yet (0-15 means we do)
		fp_checksum = 0;
		sio_parse = &sio_fp_data;
		flightplan_live_begin();
		break;

#if (CAM_USE_EXTERNAL_TARGET_DATA == 1)
	case 'T':
		fp_high_byte = -1; // -1 means we don't have the high byte yet (0-15 means we do)
		fp_checksum = 0;
		sio_parse = &sio_cam_data;
		camera_live_begin();
		break;
#endif

#if (FLY_BY_DATALINK_ENABLED == 1)
	case 'F':
		fp_checksum = 'F';
		sio_parse = &sio_fbdl_data;
		fbdl_live_begin();
		break;
#endif

	default:
		// error ?
		break;
	} // switch
}
Beispiel #3
0
static int sil_handle_key_input(char c)
{
	switch (inputState) {
		case 0:
		{
			switch (c) {
				case '?':
					printf("\n");
					print_help();
					break;
				case 'w':
					hilsim_input_adjust("throttle", KEYPRESS_INPUT_DELTA*2);
					break;
				case 's':
					hilsim_input_adjust("throttle", -KEYPRESS_INPUT_DELTA*2);
					break;
				case 'a':
					hilsim_input_adjust("rudder", KEYPRESS_INPUT_DELTA);
					break;
				case 'd':
					hilsim_input_adjust("rudder", -KEYPRESS_INPUT_DELTA);
					break;
				case 'i':
					hilsim_input_adjust("elevator", KEYPRESS_INPUT_DELTA);
					break;
				case 'k':
					hilsim_input_adjust("elevator", -KEYPRESS_INPUT_DELTA);
					break;
				case 'j':
					hilsim_input_adjust("aileron", KEYPRESS_INPUT_DELTA);
					break;
				case 'l':
					hilsim_input_adjust("aileron", -KEYPRESS_INPUT_DELTA);
					break;
				case 'z':
					hilsim_input_adjust("stick", 0);
					break;
				case '1': // switch mode to manual
					hilsim_input_adjust("mode", 1);
					break;
				case '2': // switch mode to stabilised
					hilsim_input_adjust("mode", 2);
					break;
				case '3': // switch mode to guided
					hilsim_input_adjust("mode", 3);
					break;
				case '4': // switch mode to failsafe
					hilsim_input_adjust("mode", 4);
					break;
				case '0':
					sil_radio_on = !sil_radio_on;
					printf("\nRadio %s\n", (sil_radio_on) ? "On" : "Off");
					break;
				case ';':
					showLEDs = !showLEDs;
					if (showLEDs) {
						printf("\n");
						print_LED_status();
					}
					break;
#if (FLIGHT_PLAN_TYPE == FP_LOGO)
				case 'x':
					inputState = 1;
					break;
#endif
				case 'r':
					printf("\nReally reset? (y/N)");
					fflush(stdout);
					inputState = 2;
					break;
				case '9':
					printf("Saving Params to ini file\r\n");
					config_save();
					break;
				default:
					return 0;
			}
			break;
		}
		case 1:
		{
			if (c >= '0' && c <= '9') {
				printf("\nExecuting LOGO subroutine #%c\n", c);
				flightplan_live_begin() ;
				flightplan_live_received_byte(10) ; // Exec command
				flightplan_live_received_byte(c-'0') ; // Subroutine #
				flightplan_live_received_byte(0) ; // Don't use param or set fly bit
				flightplan_live_received_byte(0) ; // Exec command
				flightplan_live_received_byte(0) ; // Exec command
				flightplan_live_commit() ;
			}
			inputState = 0;
			break;
		}
		case 2:
		{
			if (c == 'y') {
				printf("\nReset MatrixPilot...\n\n\n");
				sil_reset();
			}
			inputState = 0;
			break;
		}
	}
	return 1;
}
Beispiel #4
0
void sil_handle_key_input(char c)
{
	switch (inputState) {
		case 0:
		{
			switch (c) {
				case '?':
					printf("\n");
					print_help();
					break;
					
				case 'w':
					sil_rc_input_adjust("throttle", THROTTLE_INPUT_CHANNEL, KEYPRESS_INPUT_DELTA*2);
					break;
					
				case 's':
					sil_rc_input_adjust("throttle", THROTTLE_INPUT_CHANNEL, -KEYPRESS_INPUT_DELTA*2);
					break;
					
				case 'a':
					sil_rc_input_adjust("rudder", RUDDER_INPUT_CHANNEL, KEYPRESS_INPUT_DELTA);
					break;
					
				case 'd':
					sil_rc_input_adjust("rudder", RUDDER_INPUT_CHANNEL, -KEYPRESS_INPUT_DELTA);
					break;
					
				case 'i':
					sil_rc_input_adjust("elevator", ELEVATOR_INPUT_CHANNEL, KEYPRESS_INPUT_DELTA);
					break;
					
				case 'k':
					sil_rc_input_adjust("elevator", ELEVATOR_INPUT_CHANNEL, -KEYPRESS_INPUT_DELTA);
					break;
					
				case 'j':
					sil_rc_input_adjust("aileron", AILERON_INPUT_CHANNEL, KEYPRESS_INPUT_DELTA);
					break;
					
				case 'l':
					sil_rc_input_adjust("aileron", AILERON_INPUT_CHANNEL, -KEYPRESS_INPUT_DELTA);
					break;
					
				case 'z':
					printf("\naileron, elevator, rudder = 0%%\n");
					udb_pwIn[AILERON_INPUT_CHANNEL] = udb_pwTrim[AILERON_INPUT_CHANNEL];
					udb_pwIn[ELEVATOR_INPUT_CHANNEL] = udb_pwTrim[ELEVATOR_INPUT_CHANNEL];
					udb_pwIn[RUDDER_INPUT_CHANNEL] = udb_pwTrim[RUDDER_INPUT_CHANNEL];
					break;
					
				case '1':
					udb_pwIn[MODE_SWITCH_INPUT_CHANNEL] = MODE_SWITCH_THRESHOLD_LOW - 1;
					break;
					
				case '2':
					udb_pwIn[MODE_SWITCH_INPUT_CHANNEL] = MODE_SWITCH_THRESHOLD_LOW + 1;
					break;
					
				case '3':
					udb_pwIn[MODE_SWITCH_INPUT_CHANNEL] = MODE_SWITCH_THRESHOLD_HIGH + 1;
					break;
					
				case '0':
					sil_radio_on = !sil_radio_on;
					printf("\nRadio %s\n", (sil_radio_on) ? "On" : "Off");
					break;
					
				case 'L':
					showLEDs = !showLEDs;
					if (showLEDs) {
						printf("\n");
						print_LED_status();
					}
					break;
					
#if (FLIGHT_PLAN_TYPE == FP_LOGO)
				case 'x':
					inputState = 1;
					break;
#endif
					
				case 'r':
					printf("\nReally reset? (y/N)");
					fflush(stdout);
					inputState = 2;
					break;
					
				default:
					break;
			}
			break;
		}
			
		case 1:
		{
			if (c >= '0' && c <= '9') {
				printf("\nExecuting LOGO subroutine #%c\n", c);
				flightplan_live_begin() ;
				flightplan_live_received_byte(10) ; // Exec command
				flightplan_live_received_byte(c-'0') ; // Subroutine #
				flightplan_live_received_byte(0) ; // Don't use param or set fly bit
				flightplan_live_received_byte(0) ; // Exec command
				flightplan_live_received_byte(0) ; // Exec command
				flightplan_live_commit() ;
			}
			inputState = 0;
			break;
		}
			
		case 2:
		{
			if (c == 'y') {
				printf("\nReset MatrixPilot...\n\n\n");
				sil_reset();
			}
			inputState = 0;
		}
	}
}