summaryrefslogtreecommitdiffstats
path: root/qfixSoccerBoard.h
blob: 9278504537151ac937e7015641980181c3806b28 (plain)
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
#include <qfix/qfix.h>


#ifndef qfixSoccerBoard_h
#define qfixSoccerBoard_h


/**
* \class SoccerBoard
* \brief Represents the controller board "SoccerBoard".
* \author Stefan Enderle
*
* The class SoccerBoard represents the
* physical SoccerBoard with all its inputs and outputs.
* With this class it is possible to drive the motors,
* put on LEDs, check the buttons and get data from the
* analog and digital inputs.
*/

class SoccerBoard
{

public:
  /** Constructor for the SoccerBoard class.
  */
  SoccerBoard(); 

  /** Puts on LED i. i must be 0 or 1.
  */
  void ledOn(int i);

  /** Puts off LED i. i must be 0 or 1.
  */
  void ledOff(int i);

  /** Puts off all LEDs.
  */
  void ledsOff();

  /** Puts LED i on if state is true, else off.  i must be 0 or 1.
  */
  void led(int i, bool state);

  /** Puts the power output i on
  */
  void powerOn(int i);

  /** Puts the power output i off
  */
  void powerOff(int i);

  /** Puts the power output i on if state is true, else off.
  */
  void power(int i, bool state);

  /** Checks the state of button i. If it is pressed, true is returned,
   *  else false.
  */
  bool button(int i);

  /** Uses the four LEDs on the board to display the value i
   *  with 0 <= i <= 255
  */
  void ledMeter(int i,int maxvalue);

  /** Sets motor i to the given speed. -255 <= speed <= 255.
  */
  void motor(int i, int speed);
  
  void stop(int i);

  /** Puts off all motors.
  */
  void motorsOff();

  /** returns the value of the analog port i. 0 <= value <= 255.
  */
  int analog(int i);

  /** returns true if the digital port is logical high, else false.
  */
  bool digital(int i);

  /** Waits until button i is pressed and released again.
  */
  void waitForButton(int i);

  void beep(int freq);
  void beep(int freq, long msecs);
  void beepOff();

  void setTimer(unsigned long msecs);
  bool timer();

  void sleep(unsigned long msecs);
};


void initTimer();

#endif