mylib

Dependents:   robocon2017mbed_control_R

Fork of MyLib by gaku takasawa

Nunchuck/Nunchuck.h

Committer:
gaku_sigu
Date:
2017-05-11
Revision:
6:d5b128533dfe
Parent:
5:69e9c81e9490
Child:
7:15e3890a6782

File content as of revision 6:d5b128533dfe:

#ifndef NUNCHUCK_H
#define NUNCHUCK_H


#include "mbed.h"

#define NUNCHUCK_ANALOGDATA 1  //1 : analog   0 : degital
#define NUNCHUCK_DEADZONE 6    //analog stick's deadzone
#define NUNCHUCK_ADDR    0xA4  // 0x52 << 1

#define PI 3.14159265358979

class Nunchuck : I2C
{
    public:

        Nunchuck(PinName SDA, PinName SCL);
        int8_t analogx();
        int8_t analogy();
        double analograd();
        double analogdeg();
        int accx();
        int accy();
        int accz ();
        bool buttonc();
        bool buttonz();
    
    private:
        Timer timer;
        bool flag;
        bool init();
        char data[6];
        void getdata();
};

#endif