Beispiel #1
0
int main( void ) {
	init_servos();
	init_dcmotors( 1 );
	

	/* 
	 * In this case, i is not quite an iterator.
	 * It counts up from 0 to 255 and then back down.
	 * The incrementor is used to make this happen.
	 */
	int8_t i = 0;
	int8_t inc = 1;
	uint8_t scaled = i;

	while( 1 ) {
		scaled = i + 128;
		update_servos( scaled, scaled, i );
		run_dcmotors( i, i );

		_delay_ms( 10 );

		switch( i ) {
			case 127:
				inc = -1;
				break;
			case -127:
				inc = 1;
				break;
			default:
				break;
		}
		i += inc;
	}
	return 0;
}
Beispiel #2
0
void pwm_servo_init(void)
{
    // init timer1
   TCNT1 = (uint16_t) 0 - 16000;
   TCCR1A = 0x00;  
   TCCR1B = 0x00; // init
   TCCR1B |= (1<<CS10);   // prescale no ->50hz
   TIMSK1 |= _BV(TOIE1);

   init_servos();
}
Beispiel #3
0
void init() {
	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	Serial.systemDebugOutput(false); // Debug output to serial
	
	// mount spiffs
	int slot = rboot_get_current_rom();

	if (slot == 0) {
#ifdef RBOOT_SPIFFS_0
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_0 + 0x40200000, SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_0 + 0x40200000, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", 0x40300000, SPIFF_SIZE);
		spiffs_mount_manual(0x40300000, SPIFF_SIZE);
#endif
	} else {
#ifdef RBOOT_SPIFFS_1
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_1 + 0x40200000, SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_1 + 0x40200000, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", 0x40500000, SPIFF_SIZE);
		spiffs_mount_manual(0x40500000, SPIFF_SIZE);
#endif
	}

	WifiAccessPoint.enable(false);
	WifiStation.config(WIFI_SSID, WIFI_PWD);
    WifiStation.enable(true);
	
    Serial.printf("\r\nCurrently running rom %d.\r\n", slot);
	Serial.println("Type 'help' and press enter for instructions.");
	Serial.println();
	Serial.commandProcessing(true);
    
    commandHandler.registerCommand(CommandDelegate("ip","show current ip address","user", cmdIP));
    commandHandler.registerCommand(CommandDelegate("ota","perform ota update, switch rom and reboot","user", cmdOTA));
    commandHandler.registerCommand(CommandDelegate("heap","display free heap","user", cmdAppHeap));
    commandHandler.registerCommand(CommandDelegate("ls","list files in spiffs","user", cmdLs));
    commandHandler.registerCommand(CommandDelegate("connect","connect to wifi","user", cmdConnect));
    commandHandler.registerCommand(CommandDelegate("disconnect","disconnect from wifi","user", cmdConnect));
    commandHandler.registerCommand(CommandDelegate("ap","create access point","user", cmdAP));
    
	//Serial.setCallback(serialCallBack);
    init_servos(); 
    WifiStation.waitConnection(startWebServer, 30, startAP);    
    
}
Beispiel #4
0
int main(void) {
	configure_ports(); 
    a2dInit();  
	a2dSetPrescaler(ADC_PRESCALE_DIV32);  
	a2dSetReference(ADC_REFERENCE_AVCC); 
    
    init_servos();
	LED_on();
    
    neutral();
    hold_pos();
    
    while (1) {
        move_forward();
    //    sustain_pos();
    }
    
	return 0;
}
Beispiel #5
0
int
main(int argc, char **argv)
{
    pi_usb_init();
    wb_init();

    wb_set(LIGHTS, 0);

    if ((m = maestro_new()) == NULL) {
	fprintf(stderr, "Failed to initialize servo controller\n");
	exit(1);
    }

    song = track_new(SONG_WAV);
    if (! song) {
	perror(SONG_WAV);
	exit(1);
    }

    init_servos();

    while (1) {
	wb_set(LIGHTS, 0);
	rest_servos();

        ween2018_wait_until_valid();

	ms_sleep(BETWEEN_SONG_MS);

	nano_gettime(&start);
	wb_set(LIGHTS, 1);
	talking_skull_actor_play(lead);
	talking_skull_actor_play(backup);
	talking_skull_actor_play(bass);
	talking_skull_actor_play(triangle);
	track_play(song);
    }

    return 0;
}
Beispiel #6
0
void application_main(void) 
{
    unsigned char toto[2][4]={{0x05,0x01,0x00,0xf0}, // 00000101, 00000001, 00000000, 11110000
                              {0x0A,0x02,0x00,0xf0}};// 00001010, 00000010, 00000000, 11110000

    // Reset the Timer0 value
    TMR0H = 0;
    TMR0L = 1;

    setalim();

    init_motors();
    setup_adconversion();
    init_servos();
    init_digitals_in();
    init_debug();
    init_fdc();

    set_fdc((unsigned char *)toto,2);

    SET_DEVICE_STATUS(REMOTE_WAKEUP_DIS);
    
    // Interruptions
    PIE2bits.USBIE = 0; // Interrupt USB off : on ne touche pas a la gestion de l'USB !!

    INTCONbits.PEIE = 1; // Interrupts peripheriques (usb, timer 1...)
    INTCONbits.GIE = 1; // Interrupts global

    while(usb_active_cfg > 2)
    {
        usb_sleep();
        dispatch_usb_event();
    }
    cutalim();
    PINDEBUG = 0;
    verif_fdc(0);
//    clear_device_remote_wakeup();
}
Beispiel #7
0
void Tracker::init_tracker()
{
    // initialise console serial port
    serial_manager.init_console();

    hal.console->printf("\n\nInit " THISFIRMWARE
                               "\n\nFree RAM: %u\n",
                          hal.util->available_memory());

    // Check the EEPROM format version before loading any parameters from EEPROM
    load_parameters();

    BoardConfig.init();

    // initialise serial ports
    serial_manager.init();

    // init baro before we start the GCS, so that the CLI baro test works
    barometer.init();

    // we start by assuming USB connected, as we initialed the serial
    // port with SERIAL0_BAUD. check_usb_mux() fixes this if need be.    
    usb_connected = true;
    check_usb_mux();

    // setup telem slots with serial ports
    for (uint8_t i = 0; i < MAVLINK_COMM_NUM_BUFFERS; i++) {
        gcs[i].setup_uart(serial_manager, AP_SerialManager::SerialProtocol_MAVLink, i);
        gcs[i].set_snoop(mavlink_snoop_static);
    }

    // Register mavlink_delay_cb, which will run anytime you have
    // more than 5ms remaining in your call to hal.scheduler->delay
    hal.scheduler->register_delay_callback(mavlink_delay_cb_static, 5);
    
    mavlink_system.sysid = g.sysid_this_mav;

#if LOGGING_ENABLED == ENABLED
    log_init();
#endif

    GCS_MAVLINK::set_dataflash(&DataFlash);

    if (g.compass_enabled==true) {
        if (!compass.init() || !compass.read()) {
            hal.console->println("Compass initialisation failed!");
            g.compass_enabled = false;
        } else {
            ahrs.set_compass(&compass);
        }
    }

    // GPS Initialization
    gps.init(NULL, serial_manager);

    ahrs.init();
    ahrs.set_fly_forward(false);

    ins.init(scheduler.get_loop_rate_hz());
    ahrs.reset();

    init_barometer(true);

    // set serial ports non-blocking
    serial_manager.set_blocking_writes_all(false);

    // initialise servos
    init_servos();

    // use given start positions - useful for indoor testing, and
    // while waiting for GPS lock
    // sanity check location
    if (fabsf(g.start_latitude) <= 90.0f && fabsf(g.start_longitude) <= 180.0f) {
        current_loc.lat = g.start_latitude * 1.0e7f;
        current_loc.lng = g.start_longitude * 1.0e7f;
        gcs_send_text(MAV_SEVERITY_NOTICE, "Ignoring invalid START_LATITUDE or START_LONGITUDE parameter");
    }

    // see if EEPROM has a default location as well
    if (current_loc.lat == 0 && current_loc.lng == 0) {
        get_home_eeprom(current_loc);
    }

    init_capabilities();

    gcs_send_text(MAV_SEVERITY_INFO,"Ready to track");
    hal.scheduler->delay(1000); // Why????

    set_mode(AUTO); // tracking

    if (g.startup_delay > 0) {
        // arm servos with trim value to allow them to start up (required
        // for some servos)
        prepare_servos();
    }

}
void Tracker::init_tracker()
{
    // initialise console serial port
    serial_manager.init_console();

    hal.console->printf_P(PSTR("\n\nInit " THISFIRMWARE
                               "\n\nFree RAM: %u\n"),
                          hal.util->available_memory());

    // Check the EEPROM format version before loading any parameters from EEPROM
    load_parameters();

    BoardConfig.init();

    // initialise serial ports
    serial_manager.init();

    // init baro before we start the GCS, so that the CLI baro test works
    barometer.init();

    // init the GCS and start snooping for vehicle data
    gcs[0].setup_uart(serial_manager, AP_SerialManager::SerialProtocol_Console, 0);
    gcs[0].set_snoop(mavlink_snoop_static);

    // Register mavlink_delay_cb, which will run anytime you have
    // more than 5ms remaining in your call to hal.scheduler->delay
    hal.scheduler->register_delay_callback(mavlink_delay_cb_static, 5);

    // we start by assuming USB connected, as we initialed the serial
    // port with SERIAL0_BAUD. check_usb_mux() fixes this if need be.    
    usb_connected = true;
    check_usb_mux();

    // setup serial port for telem1 and start snooping for vehicle data
    gcs[1].setup_uart(serial_manager, AP_SerialManager::SerialProtocol_MAVLink, 0);
    gcs[1].set_snoop(mavlink_snoop_static);

#if MAVLINK_COMM_NUM_BUFFERS > 2
    // setup serial port for telem2 and start snooping for vehicle data
    gcs[2].setup_uart(serial_manager, AP_SerialManager::SerialProtocol_MAVLink, 1);
    gcs[2].set_snoop(mavlink_snoop_static);
#endif

#if MAVLINK_COMM_NUM_BUFFERS > 3
    // setup serial port for fourth telemetry port (not used by default) and start snooping for vehicle data
    gcs[3].setup_uart(serial_manager, AP_SerialManager::SerialProtocol_MAVLink, 2);
    gcs[3].set_snoop(mavlink_snoop_static);
#endif

    mavlink_system.sysid = g.sysid_this_mav;

    if (g.compass_enabled==true) {
        if (!compass.init() || !compass.read()) {
            hal.console->println_P(PSTR("Compass initialisation failed!"));
            g.compass_enabled = false;
        } else {
            ahrs.set_compass(&compass);
        }
    }

    // GPS Initialization
    gps.init(NULL, serial_manager);

    ahrs.init();
    ahrs.set_fly_forward(false);

    ins.init(AP_InertialSensor::WARM_START, ins_sample_rate);
    ahrs.reset();

    init_barometer();

    // set serial ports non-blocking
    serial_manager.set_blocking_writes_all(false);

    // initialise servos
    init_servos();

    // use given start positions - useful for indoor testing, and
    // while waiting for GPS lock
    current_loc.lat = g.start_latitude * 1.0e7f;
    current_loc.lng = g.start_longitude * 1.0e7f;

    // see if EEPROM has a default location as well
    if (current_loc.lat == 0 && current_loc.lng == 0) {
        get_home_eeprom(current_loc);
    }

    gcs_send_text_P(SEVERITY_LOW,PSTR("\nReady to track."));
    hal.scheduler->delay(1000); // Why????

    set_mode(AUTO); // tracking

    if (g.startup_delay > 0) {
        // arm servos with trim value to allow them to start up (required
        // for some servos)
        prepare_servos();
    }

    // calibrate pressure on startup by default
    nav_status.need_altitude_calibration = true;
}