gyo
SBDBT.h@14:8a6c8ae74691, 2019-04-30 (annotated)
- Committer:
- nanjo
- Date:
- Tue Apr 30 07:19:13 2019 +0000
- Revision:
- 14:8a6c8ae74691
- Parent:
- 13:3fcee1ce2f8e
- Child:
- 15:8c49a263e344
a
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 | 14:8a6c8ae74691 | 37 | while(1){ |
nanjo | 14:8a6c8ae74691 | 38 | * sbdbt.print(); |
nanjo | 12:f7eb7dfa1356 | 39 | * if(sbdbt.CIRCLE)LED = 1; |
nanjo | 14:8a6c8ae74691 | 40 | * } |
nanjo | 12:f7eb7dfa1356 | 41 | * } |
nanjo | 12:f7eb7dfa1356 | 42 | * @endcode |
nanjo | 12:f7eb7dfa1356 | 43 | */ |
nanjo | 12:f7eb7dfa1356 | 44 | |
nanjo | 12:f7eb7dfa1356 | 45 | class SBDBT |
nanjo | 12:f7eb7dfa1356 | 46 | { |
nanjo | 12:f7eb7dfa1356 | 47 | private: |
nanjo | 12:f7eb7dfa1356 | 48 | char i; |
nanjo | 12:f7eb7dfa1356 | 49 | char length; |
nanjo | 12:f7eb7dfa1356 | 50 | char value; |
nanjo | 12:f7eb7dfa1356 | 51 | char position; |
nanjo | 12:f7eb7dfa1356 | 52 | char *tmp; |
nanjo | 12:f7eb7dfa1356 | 53 | Serial *sr; |
nanjo | 9:8538fc8f6259 | 54 | |
nanjo | 12:f7eb7dfa1356 | 55 | public: |
nanjo | 12:f7eb7dfa1356 | 56 | char readable; |
nanjo | 12:f7eb7dfa1356 | 57 | char *data; |
nanjo | 12:f7eb7dfa1356 | 58 | char *data_p; |
nanjo | 12:f7eb7dfa1356 | 59 | /** Create an SBDBT object connected to the specified UART pins. |
nanjo | 12:f7eb7dfa1356 | 60 | * |
nanjo | 12:f7eb7dfa1356 | 61 | * @param Tx |
nanjo | 12:f7eb7dfa1356 | 62 | * @param Rx |
nanjo | 12:f7eb7dfa1356 | 63 | */ |
nanjo | 12:f7eb7dfa1356 | 64 | SBDBT(PinName, PinName); |
nanjo | 12:f7eb7dfa1356 | 65 | /** Create an SBDBT object connected to the specified UART pins. |
nanjo | 12:f7eb7dfa1356 | 66 | * |
nanjo | 12:f7eb7dfa1356 | 67 | * @param Tx |
nanjo | 12:f7eb7dfa1356 | 68 | * @param Rx |
nanjo | 12:f7eb7dfa1356 | 69 | * @param baud Set serial port baud rate |
nanjo | 12:f7eb7dfa1356 | 70 | */ |
nanjo | 12:f7eb7dfa1356 | 71 | SBDBT(PinName, PinName, int baud); |
nanjo | 12:f7eb7dfa1356 | 72 | void getf(); |
nanjo | 12:f7eb7dfa1356 | 73 | void print(); |
nanjo | 12:f7eb7dfa1356 | 74 | int8_t State_check(); |
nanjo | 12:f7eb7dfa1356 | 75 | void check(); |
nanjo | 12:f7eb7dfa1356 | 76 | char CIRCLE; |
nanjo | 12:f7eb7dfa1356 | 77 | char CROSS; |
nanjo | 12:f7eb7dfa1356 | 78 | char SQUARE; |
nanjo | 12:f7eb7dfa1356 | 79 | char TRIANGLE; |
nanjo | 12:f7eb7dfa1356 | 80 | char L1; |
nanjo | 12:f7eb7dfa1356 | 81 | char L2; |
nanjo | 12:f7eb7dfa1356 | 82 | char L3; |
nanjo | 12:f7eb7dfa1356 | 83 | char R1; |
nanjo | 12:f7eb7dfa1356 | 84 | char R2; |
nanjo | 12:f7eb7dfa1356 | 85 | char R3; |
nanjo | 12:f7eb7dfa1356 | 86 | char UPkey; |
nanjo | 12:f7eb7dfa1356 | 87 | char DOWNkey; |
nanjo | 12:f7eb7dfa1356 | 88 | char RIGHTkey; |
nanjo | 12:f7eb7dfa1356 | 89 | char LEFTkey; |
nanjo | 12:f7eb7dfa1356 | 90 | signed char RX; |
nanjo | 12:f7eb7dfa1356 | 91 | signed char RY; |
nanjo | 12:f7eb7dfa1356 | 92 | signed char LX; |
nanjo | 12:f7eb7dfa1356 | 93 | signed char LY; |
nanjo | 12:f7eb7dfa1356 | 94 | char rs_x_check(); |
nanjo | 12:f7eb7dfa1356 | 95 | char rs_y_check(); |
nanjo | 12:f7eb7dfa1356 | 96 | char ls_x_check(); |
nanjo | 12:f7eb7dfa1356 | 97 | char ls_y_check(); |
nanjo | 12:f7eb7dfa1356 | 98 | ~SBDBT(); |
nanjo | 12:f7eb7dfa1356 | 99 | }; |
nanjo | 12:f7eb7dfa1356 | 100 | |
nanjo | 9:8538fc8f6259 | 101 | |
gotto0 | 0:afe58893bfe7 | 102 | #endif |