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.
WiiChuck.h
00001 /* mbed audio player 00002 * Copyright (c) 2010, 2011 Frank Weissenborn 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 * THE SOFTWARE. 00021 * 00022 /* This code based on: 00023 * Wii Nunchuck 00024 * http://mbed.org/users/knaka/libraries/WiiNunchuck/ljkynp 00025 * 2010-12-18 00026 */ 00027 00028 #ifndef __WIICHUCK_H 00029 #define __WIICHUCK_H 00030 00031 #include "mbed.h" 00032 00033 #define NUNCHUCK_ADDR 0xA4 // 0x52 << 1 00034 #define NUNCHUCK_REGADDR 0x40 // 00035 #define NUNCHUCK_READLEN 0x06 // 00036 #define I2C_ACK 0 00037 #define I2C_READ_DELAY 0.01 00038 00039 #define Joy_X 0 00040 #define Joy_Y 1 00041 #define Acc_X 2 00042 #define Acc_Y 3 00043 #define Acc_Z 4 00044 #define Button 5 00045 00046 // ---------------------------------------------------------------------------- 00047 // Control values 00048 // ---------------------------------------------------------------------------- 00049 #define BUTTON_PREV_VALUE '1' 00050 #define BUTTON_NEXT_VALUE '2' 00051 #define BUTTON_OK_VALUE '3' 00052 #define BUTTON_CANCEL_VALUE '4' 00053 #define BUTTON_RESET_VALUE 'r' 00054 #define BUTTON_VOLUME_PLUS '+' 00055 #define BUTTON_VOLUME_MINUS '-' 00056 00057 typedef void(*pt2Func)(int); 00058 00059 class WiiChuck { 00060 public: 00061 bool Error; 00062 WiiChuck(PinName data, PinName clk); 00063 bool Read(int* joyX,int* joyY,int* accX,int* accY,int* accZ,int* buttonC,int* buttonZ); 00064 void start(); 00065 void stop(); 00066 void attach(pt2Func function); 00067 private: 00068 I2C _i2c; 00069 pt2Func _callback_input; 00070 Ticker _getValues; 00071 void getValues(); 00072 int _oldC; 00073 int _oldZ; 00074 00075 00076 }; 00077 00078 #endif
Generated on Wed Jul 13 2022 23:38:32 by
1.7.2