EV5_Modcon/src/ev3/src/main.c

44 lines
1.0 KiB
C

#include <stdio.h>
#include <time.h>
#include "ev3.h"
#include "ev3_light.h"
#include "ev3_port.h"
#include "ev3_tacho.h"
int main(void)
{
int i;
char s[256];
uint8_t sn;
ev3_init();
set_light(LIT_LEFT, LIT_AMBER);
while (ev3_tacho_init() < 1)
;
printf("Found tacho motors:\n");
for (i = 0; i < DESC_LIMIT; i++)
{
if (ev3_tacho[i].type_inx != TACHO_TYPE__NONE_)
{
printf(" type = %s\n", ev3_tacho_type(ev3_tacho[i].type_inx));
printf(" port = %d, %s\n", i, ev3_tacho_port_name(i, s));
int max_speed;
get_tacho_max_speed(i, &max_speed);
printf("max speed = %d\n", max_speed);
set_tacho_stop_action_inx(i, TACHO_COAST);
set_tacho_speed_sp(i, max_speed * 2 / 3);
set_tacho_time_sp(i, 1000);
set_tacho_ramp_up_sp(i, 0);
set_tacho_ramp_down_sp(i, 0);
set_tacho_command_inx(i, TACHO_RUN_TIMED);
}
}
ev3_uninit();
return 0;
}