a
Fork of kbt by
Diff: kbt.h
- Revision:
- 0:6d5cb677f22b
- Child:
- 3:2e1d8ef6e6a2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kbt.h Tue Jan 16 03:44:40 2018 +0000 @@ -0,0 +1,58 @@ + +#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 14 +#define L_updown 15 +#define R_around 16 +#define R_updown 17 + +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 +