Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (1.386 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
  protected:
37
    virtual msg_t main(void);
38
39
  private:
40
    msg_t wiimoteReceive();
41
42
    BluetoothConnector wiimoteConn;
43
    uint8_t rx_tx;
44
45
    chibios_rt::Mailbox mailbox;
46
    msg_t mailboxBuffer[BLUETOOTH_WIIMOTE_MAILBOX_SIZE];
47
48
    BluetoothIwrap *iwrap;
49
    uint8_t linkId;
50
    uint8_t stopflag;
51
52
    Accelerometer accelerometer;
53
  };
54
}
55
56
#endif /* _BLUETOOTH_WIIMOTE_H_ */