Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
WiiNunchuckReader.h
00001 /* 00002 * WiiNunchuckReader. A program allowing the output of one or two 00003 * Wii Nunchucks to be read via I2C and decoded for use, using the mbed 00004 * microcontroller and its associated libraries. 00005 * 00006 * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk> 00007 * 00008 * This file is part of WiiNunchuckReader. 00009 * 00010 * WiiNunchuckReader is free software: you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation, either version 3 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * WiiNunchuckReader is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with WiiNunchuckReader. If not, see <http://www.gnu.org/licenses/>. 00022 */ 00023 00024 #ifndef SNATCH59_WIINUNCHUCKREADER_H 00025 #define SNATCH59_WIINUNCHUCKREADER_H 00026 00027 #include <mbed.h> 00028 #include "WiiNunchuckDefs.h" 00029 00030 typedef unsigned char BYTE; 00031 00032 class WiiNunchuckReader 00033 { 00034 public: 00035 // constructors 00036 WiiNunchuckReader(PinName sda, PinName scl); 00037 00038 // functions 00039 void RequestRead(); 00040 00041 // accessors 00042 int getJoyX() const { return joyX; } 00043 int getJoyY() const { return joyY; } 00044 int getAccelX() const { return accelX; } 00045 int getAccelY() const { return accelY; } 00046 int getAccelZ() const { return accelZ; } 00047 int getButtonC() const { return buttonC; } 00048 int getButtonZ() const { return buttonZ; } 00049 int getBufferSize() const { return sizeof(readBuf); } 00050 char* getReadBuf() { return readBuf; } 00051 00052 private: 00053 // nunchuck controls states 00054 int joyX; 00055 int joyY; 00056 int accelX; 00057 int accelY; 00058 int accelZ; 00059 int buttonC; 00060 int buttonZ; 00061 00062 // nunchuck init state 00063 bool nunchuckInit; 00064 00065 // nunchuck I2C port 00066 I2C nunchuckPort; 00067 00068 // read data 00069 char readBuf[NUNCHUCK_READLEN]; 00070 00071 // functions 00072 bool NunchuckInit(); 00073 bool NunchuckRead(); 00074 void NunchuckDecode(); 00075 void DecodeAdditional(); 00076 }; 00077 00078 #endif
Generated on Tue Jul 12 2022 21:00:58 by
1.7.2