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