-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
124 lines (120 loc) · 2.27 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <stdio.h>
int main()
{
int m1=0,m2=3,pageno=0;
double createDriveTime;
printf("Start!\n");
extra_buttons_show();
while (1)
{
while (pageno == 0)
{
set_a_button_text("Forward");
set_b_button_text("Backward");
set_c_button_text("All Off");
set_x_button_text("OpenHand");
set_y_button_text("CloseHand");
set_z_button_text("Create Page");
if (a_button_clicked())
{
printf("Moving forward...\n");
motor(m1,100);
motor(m2,100);
while (!c_button_clicked())
{
msleep(1);
}
ao();
}
if (b_button_clicked())
{
printf("Moving backward...\n");
motor(m1,-100);
motor(m2,-100);
while (!c_button_clicked())
{
msleep(1);
}
ao();
}
if (x_button_clicked())
{
enable_servo(3);
set_servo_position(3,0);
msleep(300);
disable_servo(3);
}
if (y_button_clicked())
{
enable_servo(3);
set_servo_position(3,1300);
msleep(300);
disable_servo(3);
}
if (z_button_clicked())
{
pageno=1;
create_connect();
}
}
while (pageno == 1)
{
set_a_button_text("Create Fwd");
set_b_button_text("Create Bwd");
set_c_button_text("Stop");
set_x_button_text("Turn R");
set_y_button_text("Turn L");
set_z_button_text("M S Page");
if (a_button_clicked())
{
createDriveTime = 0;
printf("Create Moving forward w/ spd 100...\n");
create_drive_straight(100);
createDriveTime = seconds();
while (!c_button_clicked())
{
msleep(1);
}
create_stop();
printf("Time: %f seconds\n",seconds() - createDriveTime );
}
if (b_button_clicked())
{
createDriveTime = 0;
printf("Create Moving backward w/ spd 100...\n");
create_drive_straight(-100);
createDriveTime = seconds();
while (!c_button_clicked())
{
msleep(1);
}
create_stop();
printf("Time: %f seconds\n",seconds() - createDriveTime );
}
if (x_button_clicked())
{
create_drive(-50,0);
while (!c_button_clicked())
{
msleep(1);
}
create_stop();
}
if (y_button_clicked())
{
create_drive(50,0);
while (!c_button_clicked())
{
msleep(1);
}
create_stop();
}
if (z_button_clicked())
{
pageno=0;
create_disconnect();
}
}
}
return 0;
}