gyo
SBDBT.h@13:3fcee1ce2f8e, 2019-04-30 (annotated)
- Committer:
- nanjo
- Date:
- Tue Apr 30 06:52:56 2019 +0000
- Revision:
- 13:3fcee1ce2f8e
- Parent:
- 12:f7eb7dfa1356
- Child:
- 14:8a6c8ae74691
add
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gotto0 | 1:8810976be033 | 1 | #ifndef INCLDUED_SBDBT_h_ |
gotto0 | 1:8810976be033 | 2 | #define INCLDUED_SBDBT_h_ |
gotto0 | 0:afe58893bfe7 | 3 | #include "mbed.h" |
gotto0 | 0:afe58893bfe7 | 4 | |
gotto0 | 7:30e05998769b | 5 | //data[1] |
gotto0 | 8:f3e2b37e206f | 6 | #define SHIKAKU_ 0x01 |
gotto0 | 8:f3e2b37e206f | 7 | #define L1_ 0x02 |
gotto0 | 8:f3e2b37e206f | 8 | #define L2_ 0x04 |
nanjo | 9:8538fc8f6259 | 9 | #define L3_ 0x08 |
nanjo | 9:8538fc8f6259 | 10 | #define R1_ 0x10 |
nanjo | 9:8538fc8f6259 | 11 | #define R2_ 0x20 |
nanjo | 9:8538fc8f6259 | 12 | #define R3_ 0x40 |
gotto0 | 7:30e05998769b | 13 | |
gotto0 | 7:30e05998769b | 14 | //data[2] |
gotto0 | 8:f3e2b37e206f | 15 | #define UE_ 0x01 |
gotto0 | 8:f3e2b37e206f | 16 | #define SITA_ 0x02 |
gotto0 | 8:f3e2b37e206f | 17 | #define MIGI_ 0x04 |
gotto0 | 8:f3e2b37e206f | 18 | #define HIDARI_ 0x08 |
gotto0 | 8:f3e2b37e206f | 19 | #define SANKAKU_ 0x10 |
gotto0 | 8:f3e2b37e206f | 20 | #define BATU_ 0x20 |
gotto0 | 8:f3e2b37e206f | 21 | #define MARU_ 0x40 |
gotto0 | 8:f3e2b37e206f | 22 | #define START_ 3 |
gotto0 | 8:f3e2b37e206f | 23 | #define SELECT_ 12 |
gotto0 | 6:da71294502ee | 24 | |
nanjo | 12:f7eb7dfa1356 | 25 | /** |
nanjo | 12:f7eb7dfa1356 | 26 | * |
nanjo | 12:f7eb7dfa1356 | 27 | * Example: |
nanjo | 12:f7eb7dfa1356 | 28 | * @code |
nanjo | 12:f7eb7dfa1356 | 29 | * #include "mbed.h" |
nanjo | 12:f7eb7dfa1356 | 30 | * #include "SBDBT.h" |
nanjo | 12:f7eb7dfa1356 | 31 | * |
nanjo | 12:f7eb7dfa1356 | 32 | * // sbdbt pins: PA_0 = Tx, PA_1 = Rx,9600 = baud |
nanjo | 12:f7eb7dfa1356 | 33 | * SBDBT sbdbt(PA_0,PA_1,9600); |
nanjo | 12:f7eb7dfa1356 | 34 | * DigitalOut LED(LED1);//LED |
nanjo | 12:f7eb7dfa1356 | 35 | * |
nanjo | 12:f7eb7dfa1356 | 36 | * int main() { |
nanjo | 13:3fcee1ce2f8e | 37 | * sbdbt.printf(); |
nanjo | 12:f7eb7dfa1356 | 38 | * if(sbdbt.CIRCLE)LED = 1; |
nanjo | 12:f7eb7dfa1356 | 39 | * } |
nanjo | 12:f7eb7dfa1356 | 40 | * @endcode |
nanjo | 12:f7eb7dfa1356 | 41 | */ |
nanjo | 12:f7eb7dfa1356 | 42 | |
nanjo | 12:f7eb7dfa1356 | 43 | class SBDBT |
nanjo | 12:f7eb7dfa1356 | 44 | { |
nanjo | 12:f7eb7dfa1356 | 45 | private: |
nanjo | 12:f7eb7dfa1356 | 46 | char i; |
nanjo | 12:f7eb7dfa1356 | 47 | char length; |
nanjo | 12:f7eb7dfa1356 | 48 | char value; |
nanjo | 12:f7eb7dfa1356 | 49 | char position; |
nanjo | 12:f7eb7dfa1356 | 50 | char *tmp; |
nanjo | 12:f7eb7dfa1356 | 51 | Serial *sr; |
nanjo | 9:8538fc8f6259 | 52 | |
nanjo | 12:f7eb7dfa1356 | 53 | public: |
nanjo | 12:f7eb7dfa1356 | 54 | char readable; |
nanjo | 12:f7eb7dfa1356 | 55 | char *data; |
nanjo | 12:f7eb7dfa1356 | 56 | char *data_p; |
nanjo | 12:f7eb7dfa1356 | 57 | /** Create an SBDBT object connected to the specified UART pins. |
nanjo | 12:f7eb7dfa1356 | 58 | * |
nanjo | 12:f7eb7dfa1356 | 59 | * @param Tx |
nanjo | 12:f7eb7dfa1356 | 60 | * @param Rx |
nanjo | 12:f7eb7dfa1356 | 61 | */ |
nanjo | 12:f7eb7dfa1356 | 62 | SBDBT(PinName, PinName); |
nanjo | 12:f7eb7dfa1356 | 63 | /** Create an SBDBT object connected to the specified UART pins. |
nanjo | 12:f7eb7dfa1356 | 64 | * |
nanjo | 12:f7eb7dfa1356 | 65 | * @param Tx |
nanjo | 12:f7eb7dfa1356 | 66 | * @param Rx |
nanjo | 12:f7eb7dfa1356 | 67 | * @param baud Set serial port baud rate |
nanjo | 12:f7eb7dfa1356 | 68 | */ |
nanjo | 12:f7eb7dfa1356 | 69 | SBDBT(PinName, PinName, int baud); |
nanjo | 12:f7eb7dfa1356 | 70 | void getf(); |
nanjo | 12:f7eb7dfa1356 | 71 | void print(); |
nanjo | 12:f7eb7dfa1356 | 72 | int8_t State_check(); |
nanjo | 12:f7eb7dfa1356 | 73 | void check(); |
nanjo | 12:f7eb7dfa1356 | 74 | char CIRCLE; |
nanjo | 12:f7eb7dfa1356 | 75 | char CROSS; |
nanjo | 12:f7eb7dfa1356 | 76 | char SQUARE; |
nanjo | 12:f7eb7dfa1356 | 77 | char TRIANGLE; |
nanjo | 12:f7eb7dfa1356 | 78 | char L1; |
nanjo | 12:f7eb7dfa1356 | 79 | char L2; |
nanjo | 12:f7eb7dfa1356 | 80 | char L3; |
nanjo | 12:f7eb7dfa1356 | 81 | char R1; |
nanjo | 12:f7eb7dfa1356 | 82 | char R2; |
nanjo | 12:f7eb7dfa1356 | 83 | char R3; |
nanjo | 12:f7eb7dfa1356 | 84 | char UPkey; |
nanjo | 12:f7eb7dfa1356 | 85 | char DOWNkey; |
nanjo | 12:f7eb7dfa1356 | 86 | char RIGHTkey; |
nanjo | 12:f7eb7dfa1356 | 87 | char LEFTkey; |
nanjo | 12:f7eb7dfa1356 | 88 | signed char RX; |
nanjo | 12:f7eb7dfa1356 | 89 | signed char RY; |
nanjo | 12:f7eb7dfa1356 | 90 | signed char LX; |
nanjo | 12:f7eb7dfa1356 | 91 | signed char LY; |
nanjo | 12:f7eb7dfa1356 | 92 | char rs_x_check(); |
nanjo | 12:f7eb7dfa1356 | 93 | char rs_y_check(); |
nanjo | 12:f7eb7dfa1356 | 94 | char ls_x_check(); |
nanjo | 12:f7eb7dfa1356 | 95 | char ls_y_check(); |
nanjo | 12:f7eb7dfa1356 | 96 | ~SBDBT(); |
nanjo | 12:f7eb7dfa1356 | 97 | }; |
nanjo | 12:f7eb7dfa1356 | 98 | |
nanjo | 9:8538fc8f6259 | 99 | |
gotto0 | 0:afe58893bfe7 | 100 | #endif |