git.haldean.org d / 6dc854b
pan/tilt working! haldean 2 years ago
1 changed file(s) with 32 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
4646 return true;
4747 }
4848
49 int t_lo = 800;
50 int t_hi = 2600;
51 int p_lo = 800;
52 int p_hi = 2600;
53 int period = 60000;
54
4955 int main(int argc, char *argv[])
5056 {
5157 int i2c;
5258 uint8_t buf[4];
59 int phi = p_lo;
60 int theta = t_lo;
61 bool inc = true;
5362
5463 if (rc_initialize())
5564 {
5766 return -1;
5867 }
5968
69 rc_send_servo_pulse_us(1, theta);
70 rc_send_servo_pulse_us(2, phi);
6071 rc_enable_servo_power_rail();
61 rc_send_servo_pulse_normalized(1, -1);
62 rc_send_servo_pulse_normalized(2, -1);
6372 rc_set_state(RUNNING);
6473
6574 while (rc_get_state() != EXITING)
6675 {
67 /*
76 int iters = 1;
77 phi += (inc ? 1 : -1) * 5;
78 if (phi > p_hi || phi < p_lo)
79 {
80 theta += 50;
81 iters = 100;
82 inc = !inc;
83 if (theta > t_hi)
84 {
85 rc_set_state(EXITING);
86 break;
87 }
88 }
89 for (; iters > 0; iters--)
90 {
91 printf("%d\t%d\n", theta, phi);
92 rc_send_servo_pulse_us(1, theta);
93 rc_send_servo_pulse_us(2, phi);
94 usleep(period);
95 }
96
6897 if (rc_get_state() == RUNNING)
6998 {
7099 rc_set_led(GREEN, ON);
75104 rc_set_led(GREEN, OFF);
76105 rc_set_led(RED, ON);
77106 }
78 */
79 usleep(100000);
80107 }
81108
82109 rc_disable_servo_power_rail();