void sio_fp_checksum(uint8_t inchar) { int8_t hexVal = hex_char_val(inchar); if (hexVal == -1) { sio_parse = &sio_newMsg; } else if (fp_high_byte == -1) { fp_high_byte = hexVal * 16; } else { uint8_t v = fp_high_byte + hexVal; if (v == fp_checksum) { flightplan_live_commit(); } sio_parse = &sio_newMsg; } }
void sio_fp_checksum( unsigned char inchar ) { char hexVal = hex_char_val(inchar) ; if (hexVal == -1) { sio_parse = &sio_newMsg ; } else if (fp_high_byte == -1) { fp_high_byte = hexVal * 16 ; } else { unsigned char v = fp_high_byte + hexVal ; if (v == fp_checksum) { flightplan_live_commit() ; } sio_parse = &sio_newMsg ; } return ; }
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; }
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; } } }