2022_Ateam_MOTORprogramをscrp_slaveでメインマイコンからコントローラー状況を読み取れるように改良。 また、モータに0以外のpwmが送られている場合に基盤付属のledが点灯するようにした。
Dependencies: SBDBT arrc_mbed BNO055
library/function.hpp@11:264f992664b0, 2022-03-22 (annotated)
- Committer:
- guesta
- Date:
- Tue Mar 22 00:35:37 2022 +0000
- Revision:
- 11:264f992664b0
- Parent:
- 10:ad8fced7d6b6
- Child:
- 12:894e5ac49810
new
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
guesta | 3:6fb5c3218608 | 1 | #ifndef function_hpp |
guesta | 3:6fb5c3218608 | 2 | #define function_hpp |
guesta | 3:6fb5c3218608 | 3 | #include "mbed.h" |
guesta | 3:6fb5c3218608 | 4 | |
guesta | 3:6fb5c3218608 | 5 | //変数 |
guesta | 3:6fb5c3218608 | 6 | bool auto_mode = false; |
guesta | 3:6fb5c3218608 | 7 | int x_component; |
guesta | 3:6fb5c3218608 | 8 | int y_component; |
guesta | 11:264f992664b0 | 9 | int l_x_component; |
guesta | 11:264f992664b0 | 10 | int l_y_component; |
guesta | 3:6fb5c3218608 | 11 | int l2_num; |
guesta | 3:6fb5c3218608 | 12 | int r2_num; |
guesta | 5:1a850f68a06c | 13 | bool up; |
guesta | 5:1a850f68a06c | 14 | bool down; |
guesta | 9:569c0f55dd9b | 15 | bool l1; |
guesta | 11:264f992664b0 | 16 | bool r1; |
guesta | 10:ad8fced7d6b6 | 17 | bool auto_start; |
guesta | 11:264f992664b0 | 18 | bool stop; |
guesta | 11:264f992664b0 | 19 | bool auto_move; |
guesta | 11:264f992664b0 | 20 | bool redZone = 0; |
guesta | 3:6fb5c3218608 | 21 | |
guesta | 11:264f992664b0 | 22 | //Rスティックのx成分取得 |
guesta | 3:6fb5c3218608 | 23 | bool getLstick_x(int rx_data,int &tx_data){ |
guesta | 3:6fb5c3218608 | 24 | x_component = rx_data; |
guesta | 3:6fb5c3218608 | 25 | return true; |
guesta | 3:6fb5c3218608 | 26 | } |
guesta | 3:6fb5c3218608 | 27 | |
guesta | 11:264f992664b0 | 28 | //Rスティックのy成分取得 |
guesta | 3:6fb5c3218608 | 29 | bool getLstick_y(int rx_data,int &tx_data){ |
guesta | 3:6fb5c3218608 | 30 | y_component = rx_data; |
guesta | 3:6fb5c3218608 | 31 | return true; |
guesta | 3:6fb5c3218608 | 32 | } |
guesta | 3:6fb5c3218608 | 33 | |
guesta | 11:264f992664b0 | 34 | //Lスティックのx成分取得 |
guesta | 11:264f992664b0 | 35 | bool getRstick_x(int rx_data,int &tx_data){ |
guesta | 11:264f992664b0 | 36 | l_x_component = rx_data; |
guesta | 11:264f992664b0 | 37 | return true; |
guesta | 11:264f992664b0 | 38 | } |
guesta | 11:264f992664b0 | 39 | |
guesta | 11:264f992664b0 | 40 | bool getRstick_y(int rx_data,int &tx_data){ |
guesta | 11:264f992664b0 | 41 | l_y_component = rx_data; |
guesta | 11:264f992664b0 | 42 | return true; |
guesta | 11:264f992664b0 | 43 | } |
guesta | 11:264f992664b0 | 44 | |
guesta | 3:6fb5c3218608 | 45 | //L1取得 |
guesta | 3:6fb5c3218608 | 46 | bool getL2(int rx_data,int &tx_data){ |
guesta | 3:6fb5c3218608 | 47 | l2_num = rx_data; |
guesta | 3:6fb5c3218608 | 48 | return true; |
guesta | 3:6fb5c3218608 | 49 | } |
guesta | 3:6fb5c3218608 | 50 | |
guesta | 3:6fb5c3218608 | 51 | //R2取得 |
guesta | 3:6fb5c3218608 | 52 | bool getR2(int rx_data,int &tx_data){ |
guesta | 3:6fb5c3218608 | 53 | r2_num = rx_data; |
guesta | 3:6fb5c3218608 | 54 | return true; |
guesta | 3:6fb5c3218608 | 55 | } |
guesta | 3:6fb5c3218608 | 56 | |
guesta | 3:6fb5c3218608 | 57 | |
guesta | 3:6fb5c3218608 | 58 | //自動、手動モード切り替え |
guesta | 3:6fb5c3218608 | 59 | bool change_mode(int rx_data,int &tx_data){ |
guesta | 9:569c0f55dd9b | 60 | auto_mode = rx_data; |
guesta | 3:6fb5c3218608 | 61 | return true; |
guesta | 3:6fb5c3218608 | 62 | } |
guesta | 3:6fb5c3218608 | 63 | |
guesta | 5:1a850f68a06c | 64 | //上キー取得 |
guesta | 5:1a850f68a06c | 65 | bool getUp(int rx_data,int &tx_data){ |
guesta | 5:1a850f68a06c | 66 | up = rx_data; |
guesta | 5:1a850f68a06c | 67 | return true; |
guesta | 5:1a850f68a06c | 68 | } |
guesta | 3:6fb5c3218608 | 69 | |
guesta | 5:1a850f68a06c | 70 | //下キー取得 |
guesta | 5:1a850f68a06c | 71 | bool getDown(int rx_data,int &tx_data){ |
guesta | 5:1a850f68a06c | 72 | down = rx_data; |
guesta | 5:1a850f68a06c | 73 | return true; |
guesta | 5:1a850f68a06c | 74 | } |
guesta | 5:1a850f68a06c | 75 | |
guesta | 9:569c0f55dd9b | 76 | //L1取得 |
guesta | 9:569c0f55dd9b | 77 | bool getL1(int rx_data,int &tx_data){ |
guesta | 9:569c0f55dd9b | 78 | l1 = rx_data; |
guesta | 9:569c0f55dd9b | 79 | return true; |
guesta | 9:569c0f55dd9b | 80 | } |
guesta | 10:ad8fced7d6b6 | 81 | |
guesta | 11:264f992664b0 | 82 | //R1取得 |
guesta | 11:264f992664b0 | 83 | bool getR1(int rx_data,int &tx_data){ |
guesta | 11:264f992664b0 | 84 | r1 = rx_data; |
guesta | 11:264f992664b0 | 85 | return true; |
guesta | 11:264f992664b0 | 86 | } |
guesta | 11:264f992664b0 | 87 | |
guesta | 10:ad8fced7d6b6 | 88 | //auto_start取得 |
guesta | 10:ad8fced7d6b6 | 89 | bool getStart(int rx_data,int &tx_data){ |
guesta | 10:ad8fced7d6b6 | 90 | auto_start = rx_data; |
guesta | 10:ad8fced7d6b6 | 91 | return true; |
guesta | 10:ad8fced7d6b6 | 92 | } |
guesta | 11:264f992664b0 | 93 | |
guesta | 11:264f992664b0 | 94 | //自動移動開始読み取り |
guesta | 11:264f992664b0 | 95 | bool getCircle(int rx_data,int &tx_data){ |
guesta | 11:264f992664b0 | 96 | auto_move = rx_data; |
guesta | 11:264f992664b0 | 97 | return true; |
guesta | 11:264f992664b0 | 98 | } |
guesta | 11:264f992664b0 | 99 | |
guesta | 11:264f992664b0 | 100 | //フィールド読み取り |
guesta | 11:264f992664b0 | 101 | bool getZone(int rx_data,int &tx_data){ |
guesta | 11:264f992664b0 | 102 | redZone = rx_data; |
guesta | 11:264f992664b0 | 103 | return true; |
guesta | 11:264f992664b0 | 104 | } |
guesta | 11:264f992664b0 | 105 | |
guesta | 11:264f992664b0 | 106 | //非常停止 |
guesta | 11:264f992664b0 | 107 | bool getStop(int rx_data,int &tx_data){ |
guesta | 11:264f992664b0 | 108 | stop = rx_data; |
guesta | 11:264f992664b0 | 109 | return true; |
guesta | 11:264f992664b0 | 110 | } |
guesta | 11:264f992664b0 | 111 | |
guesta | 3:6fb5c3218608 | 112 | #endif |