The original snake game for the mbedgc

Dependencies:   mbed EthernetNetIf HTTPClient

Fork of SimpleLib_03272011 by J.P. Armstrong

Committer:
jp
Date:
Thu Aug 22 00:28:15 2013 +0000
Revision:
2:da81fd97aa86
Parent:
0:011be8250218
getting it working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jp 0:011be8250218 1 /*
jp 0:011be8250218 2 * WiiClassicControllerReader. A program allowing the output of one or two
jp 0:011be8250218 3 * Wii Classic Controllers to be read via I2C and decoded for use, using the mbed
jp 0:011be8250218 4 * microcontroller and its associated libraries.
jp 0:011be8250218 5 *
jp 0:011be8250218 6 * Written by Alfredo Guerrero <alfredog83@gmail.com> for the mbedGC open-source
jp 0:011be8250218 7 * game console <http://www.mbedgc.com>. Based on the original code for
jp 0:011be8250218 8 * the WiiNunchuckReader written by Petras Saduikis <petras@petras.co.uk>.
jp 0:011be8250218 9 *
jp 0:011be8250218 10 * This file is part of WiiClassicControllerReader.
jp 0:011be8250218 11 *
jp 0:011be8250218 12 * WiiClassicControllerReader is free software: you can redistribute it and/or modify
jp 0:011be8250218 13 * it under the terms of the GNU General Public License as published by
jp 0:011be8250218 14 * the Free Software Foundation, either version 3 of the License, or
jp 0:011be8250218 15 * (at your option) any later version.
jp 0:011be8250218 16 *
jp 0:011be8250218 17 * WiiClassicControllerReader is distributed in the hope that it will be useful,
jp 0:011be8250218 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jp 0:011be8250218 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
jp 0:011be8250218 20 * GNU General Public License for more details.
jp 0:011be8250218 21 *
jp 0:011be8250218 22 * You can find a copy of the GNU General Public License at <http://www.gnu.org/licenses/>.
jp 0:011be8250218 23 */
jp 0:011be8250218 24
jp 0:011be8250218 25 #ifndef ALFREDOG83_WIICLASSICCONTROLLERDEFS_H
jp 0:011be8250218 26 #define ALFREDOG83_WIICLASSICCONTROLLERDEFS_H
jp 0:011be8250218 27
jp 0:011be8250218 28 // I2C
jp 0:011be8250218 29 #define CONTROLLER_ADDR 0xA4 // I2C library doesn't right shift the address, so provided shifted
jp 0:011be8250218 30 #define CONTROLLER_REGADDR 0x40 // relevant register address
jp 0:011be8250218 31 #define CONTROLLER_READLEN 0x06 // always read this many bytes back
jp 0:011be8250218 32
jp 0:011be8250218 33 // bitmasks for individual buttons
jp 0:011be8250218 34 // LX, LY: left analog stick X, Y (0-63)
jp 0:011be8250218 35 // RX, RY: right analog stick X, Y (0-31) [RX separated among bytes 0-2]
jp 0:011be8250218 36 // RT, LT: right, left trigger (0-31) [LT separated among bytes 2-3]
jp 0:011be8250218 37 // B{ZR,ZL,A,B,X,Y,START,HOME,SELECT}: discrete buttons
jp 0:011be8250218 38 // BD{L,R,U,D}: D-pad direction buttons
jp 0:011be8250218 39 // LC,RC: digital button click of LT, RT when pressed down all the way
jp 0:011be8250218 40 #define MASK_LX 0x3F // LX<5:0>
jp 0:011be8250218 41 #define MASK_RX34 0xC0 // RX<4:3>
jp 0:011be8250218 42 #define MASK_LY 0x3F // LY<5:0>
jp 0:011be8250218 43 #define MASK_RY 0x1F // RY<4:0>
jp 0:011be8250218 44 #define MASK_LT34 0x60 // LT<4:3>
jp 0:011be8250218 45 #define MASK_RT 0x1F // RT<4:0>
jp 0:011be8250218 46 #define MASK_BDU 0x01 // DU
jp 0:011be8250218 47 #define MASK_RC_DL 0x02 // DL, RC
jp 0:011be8250218 48 #define MASK_BSTART_ZR 0x04 // ZR, START
jp 0:011be8250218 49 #define MASK_BHOME_X 0x08 // X, HOME
jp 0:011be8250218 50 #define MASK_BSELECT_A 0x10 // A, SELECT
jp 0:011be8250218 51 #define MASK_LC_Y 0x20 // LC, Y, LT<0>
jp 0:011be8250218 52 #define MASK_BDD_B 0x40 // B, DD, LT<1>, RX<1>
jp 0:011be8250218 53 #define MASK_BDR_ZL 0x80 // ZL, DR, LT<2>, RX<0>, RX<2>
jp 0:011be8250218 54
jp 0:011be8250218 55 // timing
jp 0:011be8250218 56 #define I2C_READ_DELAY 0.01
jp 0:011be8250218 57
jp 0:011be8250218 58 // I2C status
jp 0:011be8250218 59 #define I2C_OK 0 // zero on success (ACK), non-zero on fail (NACK) for read or write
jp 0:011be8250218 60
jp 0:011be8250218 61 #endif