Hardware Reference
In-Depth Information
75 static void
76 advance(int dir) {
77 static int m0drv[] = {8, 4, 2, 1};
78 static int m1drv[] = {9, 12, 6, 3};
79 static int m2drv[] = {9, 8, 12, 4, 6, 2, 3, 1};
80
81 switch ( drive_mode ) {
82 case 0: /
Simple mode 0
/
83 step_no = (step_no + dir) & 3;
84 drive(m0drv[step_no]);
85 await(step_time/4.0);
86 break;
87 case 1: /
Mode 1 drive
/
88 step_no = (step_no + dir) & 3;
89 drive(m1drv[step_no]);
90 await(step_time/6.0);
91 break;
92 case 2: /
Mode 2 drive
/
93 step_no = (step_no + dir) & 7;
94 drive(m2drv[step_no]);
95 await(step_time/1 2.0);
96 ;
97 }
98
99 on_off = 1; /
Mark as drive enabled
/
100 }
101
102 /
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
103
Move +/- n steps, keeping track of position
104
/
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
105 static void
106 move(int steps) {
107 int movement = steps;
108 int dir = steps >= 0 ? 1 : -1;
109 int inc = steps >= 0 ? -1 : 1;
110
111 for ( ; steps != 0; steps += inc )
112 advance(dir);
113 position = (position + movement + steps_per_r) % steps_per_r;
114 }
115
116 /
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
117
Move to an hour position
118
/
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
Search WWH ::




Custom Search