Hardware Reference
In-Depth Information
119 static void
120 move_oclock(int hour) {
121 int new_pos = floor((float)hour
steps_per_r/12.0);
122 int diff;
123
124 printf("Moving to %d o'clock.\n",hour);
125
126 if ( new_pos >= position ) {
127 diff = new_pos − position;
128 if ( diff <= steps_per_r/2 )
129 move(diff);
130 else move(−(position + steps_per_r − new_pos));
131 } else {
132 diff = position − new_pos;
133 if ( diff <= steps_per_r/2 )
134 move(-diff);
135 else move (new_pos + steps_per_r - position);
136 }
137 }
138
139 /
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
140
Provide usage info :
141
/
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
142 static void
143 help(void) {
144 puts("Enter 0-9,A,B for 0_9,10,11 o'clock.\n"
145 " '<' to slow motor speed, \n"
146 " '>' to increase motor speed, \n"
147 " 'J ', 'K' or 'L' for modes 0−2,\n"
148 " '+'/ '−' to step 1 step,\n"
149 " 'O' to toggle drive on/off, \n"
150 " 'P' to show position, \n"
151 " 'Q' to quit.\n");
152 }
153
154 /
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
155
Main program
156
/
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
157 int
158 main(int argc,char
argv) {
159 int tty = 0; /
∗∗
Use stdin
/
160 struct termios sv_ios, ios;
161 int x, rc;
162 char ch;
163
164 if ( argc >= 2 )
165 drive_mode = atoi(argv[1]); /
Drive mode 0_2
/
166
Search WWH ::




Custom Search