First draft of Wii Robot Racing, a simple example of using Wii Remote connected via bluetooth to control an m3pi robot, plus RFID \"powerups\" to modify behaviour
Dependencies: mbed m3pi ID12RFIDIRQ
Wiimote.h@0:e2ef12467862, 2011-04-11 (annotated)
- Committer:
- simon
- Date:
- Mon Apr 11 23:03:22 2011 +0000
- Revision:
- 0:e2ef12467862
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:e2ef12467862 | 1 | /* Copyright (c) 2011, mbed |
simon | 0:e2ef12467862 | 2 | * |
simon | 0:e2ef12467862 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
simon | 0:e2ef12467862 | 4 | * of this software and associated documentation files (the "Software"), to deal |
simon | 0:e2ef12467862 | 5 | * in the Software without restriction, including without limitation the rights |
simon | 0:e2ef12467862 | 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
simon | 0:e2ef12467862 | 7 | * copies of the Software, and to permit persons to whom the Software is |
simon | 0:e2ef12467862 | 8 | * furnished to do so, subject to the following conditions: |
simon | 0:e2ef12467862 | 9 | * |
simon | 0:e2ef12467862 | 10 | * The above copyright notice and this permission notice shall be included in |
simon | 0:e2ef12467862 | 11 | * all copies or substantial portions of the Software. |
simon | 0:e2ef12467862 | 12 | * |
simon | 0:e2ef12467862 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
simon | 0:e2ef12467862 | 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
simon | 0:e2ef12467862 | 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
simon | 0:e2ef12467862 | 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
simon | 0:e2ef12467862 | 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
simon | 0:e2ef12467862 | 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
simon | 0:e2ef12467862 | 19 | * THE SOFTWARE. |
simon | 0:e2ef12467862 | 20 | */ |
simon | 0:e2ef12467862 | 21 | |
simon | 0:e2ef12467862 | 22 | // Simple decoder class for Wii Remote data |
simon | 0:e2ef12467862 | 23 | |
simon | 0:e2ef12467862 | 24 | #ifndef WIIMOTE_H |
simon | 0:e2ef12467862 | 25 | #define WIIMOTE_H |
simon | 0:e2ef12467862 | 26 | |
simon | 0:e2ef12467862 | 27 | #include <stdint.h> |
simon | 0:e2ef12467862 | 28 | |
simon | 0:e2ef12467862 | 29 | class Wiimote { |
simon | 0:e2ef12467862 | 30 | |
simon | 0:e2ef12467862 | 31 | public: |
simon | 0:e2ef12467862 | 32 | |
simon | 0:e2ef12467862 | 33 | void decode(char *data); |
simon | 0:e2ef12467862 | 34 | void dump(); |
simon | 0:e2ef12467862 | 35 | |
simon | 0:e2ef12467862 | 36 | // buttons |
simon | 0:e2ef12467862 | 37 | uint32_t left:1; |
simon | 0:e2ef12467862 | 38 | uint32_t right:1; |
simon | 0:e2ef12467862 | 39 | uint32_t down:1; |
simon | 0:e2ef12467862 | 40 | uint32_t up:1; |
simon | 0:e2ef12467862 | 41 | uint32_t plus:1; |
simon | 0:e2ef12467862 | 42 | uint32_t two:1; |
simon | 0:e2ef12467862 | 43 | uint32_t one:1; |
simon | 0:e2ef12467862 | 44 | uint32_t a:1; |
simon | 0:e2ef12467862 | 45 | uint32_t b:1; |
simon | 0:e2ef12467862 | 46 | uint32_t minus:1; |
simon | 0:e2ef12467862 | 47 | uint32_t home:1; |
simon | 0:e2ef12467862 | 48 | |
simon | 0:e2ef12467862 | 49 | // accelerometers |
simon | 0:e2ef12467862 | 50 | uint16_t rawx; |
simon | 0:e2ef12467862 | 51 | uint16_t rawy; |
simon | 0:e2ef12467862 | 52 | uint16_t rawz; |
simon | 0:e2ef12467862 | 53 | |
simon | 0:e2ef12467862 | 54 | float x; |
simon | 0:e2ef12467862 | 55 | float y; |
simon | 0:e2ef12467862 | 56 | float z; |
simon | 0:e2ef12467862 | 57 | float wheel; |
simon | 0:e2ef12467862 | 58 | }; |
simon | 0:e2ef12467862 | 59 | |
simon | 0:e2ef12467862 | 60 | #endif |
simon | 0:e2ef12467862 | 61 |