Example #1
0
int main(void) {
    init();
    int thrust = 0; // Holds thrust %age
    int old_thrust = 0; // Holds old thrust value.  Used to limit the number of bytes sent
    int checksum = 0; // checksum for outgoing serial data.  Integrity is important!

    while(1) {
        if (unlock) { // If the safety switch is active
            LATBbits.LATB5 = 1; // Green LED
            thrust = get_thrust(old_thrust);
            clear_bt_buf();
            __delay_ms(5);
        } else { // System is locked!
            LATBbits.LATB5 = 0; // Red LED
            clear_bt_buf();
            thrust = 0;
        }
        if (thrust != old_thrust) {
            old_thrust = thrust;
            uart_putChar('t', 2); // t for thrust, same as amarino
            uart_putChar(thrust, 2);

            checksum = ('t' ^ thrust); // Checksum is pretty simple for two bytes!
            
            uart_putChar(checksum, 2);
        }
    }

    return 0;
}
Example #2
0
std::string spacecraft::human_readable() const {
	std::ostringstream s;
	s << "NEP spacecraft:" << std::endl << std::endl;
	s << "mass: " << get_mass() << std::endl;
	s << "thrust: " << get_thrust() << std::endl;
	s << "isp: " << get_isp() << std::endl;
	return s.str();
};
Example #3
0
Thrust Engine::get_thrust_changed() const {
  return (get_health()/get_max_health())*get_thrust();
}