direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
head.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) Markus Knapp *
3  * www.direcs.de *
4  * *
5  * This file is part of direcs. *
6  * *
7  * direcs is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU General Public License as published *
9  * by the Free Software Foundation, version 3 of the License. *
10  * *
11  * direcs is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  *************************************************************************/
20 
21 #include "head.h"
22 
24 {
25  //------------------------------------------------------------------
26  // copy the pointer from the original usb object
27  //------------------------------------------------------------------
28  servos = s;
29 
30  // Initialize something
31 }
32 
33 
35 {
36  /*
37  park();
38  */
39 }
40 
41 
42 void Head::look(QString direction)
43 {
44  if (direction == "UP")
45  {
46 
47  eye(LEFTEYE, direction);
48  eye(RIGHTEYE, direction);
49  return;
50  }
51 
52  if (direction == "UPLEFT")
53  {
54  eye(LEFTEYE, direction);
55  eye(RIGHTEYE, direction);
56  return;
57  }
58 
59  if (direction == "UPRIGHT")
60  {
61  eye(LEFTEYE, direction);
62  eye(RIGHTEYE, direction);
63  return;
64  }
65 
66  if (direction == "DOWN")
67  {
68  eye(LEFTEYE, direction);
69  eye(RIGHTEYE, direction);
70  return;
71  }
72 
73  if (direction == "DOWNLEFT")
74  {
75  eye(LEFTEYE, direction);
76  eye(RIGHTEYE, direction);
77  return;
78  }
79 
80  if (direction == "DOWNRIGHT")
81  {
82  eye(LEFTEYE, direction);
83  eye(RIGHTEYE, direction);
84  return;
85  }
86 
87  if (direction == "LEFT")
88  {
89  eye(LEFTEYE, direction);
90  eye(RIGHTEYE, direction);
91  return;
92  }
93 
94  if (direction == "RIGHT")
95  {
96  eye(LEFTEYE, direction);
97  eye(RIGHTEYE, direction);
98  return;
99  }
100 
101  if (direction == "FORWARD")
102  {
103  eye(LEFTEYE, direction);
104  eye(RIGHTEYE, direction);
105  return;
106  }
107 
108  if (direction == "NORMAL")
109  {
110  eyebrow(LEFTBROW, direction);
111  eyebrow(RIGHTBROW, direction);
112  return;
113  }
114 
115  if (direction == "CURIOUS")
116  {
117  eyebrow(LEFTBROW, "UP");
118  eyebrow(RIGHTBROW, "UP");
119  return;
120  }
121 
122  if (direction == "ANGRY")
123  {
124  eyebrow(LEFTBROW, "DOWN");
125  eyebrow(RIGHTBROW, "DOWN");
126  return;
127  }
128 }
129 
130 
131 void Head::eye(unsigned char whichEye, QString direction)
132 {
133  // move servo to the start or end position (*not* to the min or max posisiotns!)
134  if (direction == "UP")
135  {
136  if (whichEye==LEFTEYE)
137  {
138  // up
140  // default
142  return;
143  }
144 
145  if (whichEye==RIGHTEYE)
146  {
147  // up
149  // default
151  return;
152  }
153  return;
154  }
155 
156  if (direction == "UPLEFT")
157  {
158  if (whichEye==LEFTEYE)
159  {
160  // up
162  //left
164  return;
165  }
166 
167  if (whichEye==RIGHTEYE)
168  {
169  // up
171  // left
173  return;
174  }
175  return;
176  }
177 
178  if (direction == "UPRIGHT")
179  {
180  if (whichEye==LEFTEYE)
181  {
182  // right
184  // up
186  return;
187  }
188 
189  if (whichEye==RIGHTEYE)
190  {
191  // up
193  // right
195  return;
196  }
197  return;
198  }
199 
200  // move servo to the start or end position (*not* to the min or max posisiotns!)
201  if (direction == "DOWN")
202  {
203  if (whichEye==LEFTEYE)
204  {
205  // down
207  // default
209  return;
210  }
211 
212  if (whichEye==RIGHTEYE)
213  {
214  // down
216  // default
218  return;
219  }
220  return;
221  }
222 
223  if (direction == "DOWNLEFT")
224  {
225  if (whichEye==LEFTEYE)
226  {
227  // down
229  // left
231  return;
232  }
233 
234  if (whichEye==RIGHTEYE)
235  {
236  // down
238  // left
240  return;
241  }
242  return;
243  }
244 
245  if (direction == "DOWNRIGHT")
246  {
247  if (whichEye==LEFTEYE)
248  {
249  // down
251  // right
253  return;
254  }
255 
256  if (whichEye==RIGHTEYE)
257  {
258  // right
260  // down
262  return;
263  }
264  return;
265  }
266 
267  // move servo to the start or end position (*not* to the min or max posisiotns!)
268  if (direction == "LEFT")
269  {
270  if (whichEye==LEFTEYE)
271  {
272  // left
274  // default
276  return;
277  }
278 
279  if (whichEye==RIGHTEYE)
280  {
281  // left
283  // default
285  return;
286  }
287  return;
288  }
289 
290  // move servo to its maximum end position
291  if (direction == "LEFTMAX")
292  {
293  if (whichEye==LEFTEYE)
294  {
295  //
297  return;
298  }
299 
300  if (whichEye==RIGHTEYE)
301  {
302  //
304  return;
305  }
306  return;
307  }
308 
309  // move servo to the start or end position (*not* to the min or max posisiotns!)
310  if (direction == "RIGHT")
311  {
312  //qDebug("right");
313  if (whichEye==LEFTEYE)
314  {
315  // right
317  // default
319  return;
320  }
321 
322  if (whichEye==RIGHTEYE)
323  {
324  // right
326  // default
328  return;
329  }
330  return;
331  }
332 
333  // move servo to its maximum end position
334  if (direction == "RIGHTMAX")
335  {
336  if (whichEye==LEFTEYE)
337  {
339  return;
340  }
341 
342  if (whichEye==RIGHTEYE)
343  {
345  return;
346  }
347  return;
348  }
349 
350  if (direction == "FORWARD")
351  {
356  return;
357  }
358 }
359 
360 
361 void Head::eyebrow(unsigned char whichBrow, QString direction)
362 {
363  if (direction == "NORMAL")
364  {
365  if (whichBrow==LEFTBROW)
366  {
367  // default pos
369  return;
370  }
371 
372  if (whichBrow==RIGHTBROW)
373  {
374  // default pos
376  return;
377  }
378  return;
379  }
380 
381  if (direction == "UP")
382  {
383  if (whichBrow==LEFTBROW)
384  {
385  // inside up
387  return;
388  }
389 
390  if (whichBrow==RIGHTBROW)
391  {
392  // inside up
394  return;
395  }
396  return;
397  }
398 
399  if (direction == "DOWN")
400  {
401  if (whichBrow==LEFTBROW)
402  {
403  // inside down
405  return;
406  }
407 
408  if (whichBrow==RIGHTBROW)
409  {
410  // inside down
412  return;
413  }
414  return;
415  }
416 }