Statistics
| Branch: | Tag: | Revision:

amiro-os / include / amiro / bluetooth / bluetooth-wiimote.hpp @ f3972840

History | View | Annotate | Download (1.722 KB)

1 58fe0e0b Thomas Schöpping
#ifndef _BLUETOOTH_WIIMOTE_H_
2
#define _BLUETOOTH_WIIMOTE_H_
3
4
#include <amiro/bluetooth/bluetooth-connector.hpp>
5
6
#define BLUETOOTH_WIIMOTE_MAILBOX_SIZE 5
7
8
#define WIIMOTE_START_EVENT  1
9
#define WIIMOTE_STOP_EVENT   2
10
11
namespace amiro {
12
  class BluetoothWiimote : public chibios_rt::BaseStaticThread<128> {
13
  public:
14
    BluetoothWiimote(BLUETOOTH *bluetooth, uint8_t rxtx);
15
16
    void bluetoothWiimoteStart(uint8_t linkid);
17
    void bluetoothWiimoteStop();
18
    bool bluetoothWiimoteIsConnected();
19
20
    void bluetoothWiimoteListen(const char *addr);
21
    void bluetoothWiimoteConnect(const char *addr);
22
    void bluetoothWiimoteDisconnect(const char *addr);
23
24
    msg_t wiimoteTransmit(const uint8_t* wiimotecmd, size_t length);
25
    void bluetoothWiimoteLedVibrate(uint8_t ledid_flag, uint8_t vibrate_flag);
26
    void bluetoothWiimoteStatusInfo();
27
    void bluetoothWiimoteDataBtn();
28
    void bluetoothWiimoteDataBtnAcc();
29
30
    class Accelerometer {
31
    public:
32
      int16_t x_axis, y_axis, z_axis;
33
    };
34
    Accelerometer *getAccelerometer();
35
36 61b0791a Thomas Schöpping
    struct Buttons {
37
      uint16_t left : 1;
38
      uint16_t right : 1;
39
      uint16_t down : 1;
40
      uint16_t up : 1;
41
      uint16_t plus : 1;
42
      uint16_t two : 1;
43
      uint16_t one : 1;
44
      uint16_t B : 1;
45
      uint16_t A : 1;
46
      uint16_t minus : 1;
47
      uint16_t home : 1;
48
    };
49
    Buttons* getButtons();
50
51 58fe0e0b Thomas Schöpping
  protected:
52
    virtual msg_t main(void);
53
54
  private:
55
    msg_t wiimoteReceive();
56
57
    BluetoothConnector wiimoteConn;
58
    uint8_t rx_tx;
59
60
    chibios_rt::Mailbox mailbox;
61
    msg_t mailboxBuffer[BLUETOOTH_WIIMOTE_MAILBOX_SIZE];
62
63
    BluetoothIwrap *iwrap;
64
    uint8_t linkId;
65
    uint8_t stopflag;
66
67
    Accelerometer accelerometer;
68 61b0791a Thomas Schöpping
    Buttons buttons;
69 58fe0e0b Thomas Schöpping
  };
70
}
71
72
#endif /* _BLUETOOTH_WIIMOTE_H_ */