a

Fork of kbtakira by 100% akira

kbt.h

Committer:
AK1412
Date:
15 months ago
Revision:
3:34697e4082fc
Parent:
0:6d5cb677f22b

File content as of revision 3:34697e4082fc:


#ifndef KBT_H
#define KBT_H

#include "mbed.h"

#define BITNUM 8
#define DATANUM 7

#define rect 0
#define L1 1
#define L2 2
#define R1 3
#define R2 4
#define up 5
#define down 6
#define right 7
#define left 8
#define triangle 9
#define cross 10
#define circle 11
#define Start 12
#define Select 13
#define L_around 0
#define L_updown 1
#define R_around 2
#define R_updown 3

class KBT{
public  :
    bool Button[14];
    int Stick[4];
    int open_data[8];
    
    KBT(PinName TX, PinName RX);
    void init(long baudrate);
    bool button(int num);
    int stick(int num);

private :
    Serial bt;
    bool start;
    int stopcheck;
    int val;  
    int count;
    int bitbox[8];
    int data[8];
    int check[9];

    long map(long x, long in_min, long in_max, long out_min, long out_max);
    void bitcheck();
    void intSerial();
    void numinit();

};

#endif