2022_Ateam_MOTORprogramをscrp_slaveでメインマイコンからコントローラー状況を読み取れるように改良。 また、モータに0以外のpwmが送られている場合に基盤付属のledが点灯するようにした。
Dependencies: SBDBT arrc_mbed BNO055
library/function.hpp@3:6fb5c3218608, 2022-01-21 (annotated)
- Committer:
- guesta
- Date:
- Fri Jan 21 09:08:26 2022 +0000
- Revision:
- 3:6fb5c3218608
- Child:
- 5:1a850f68a06c
a
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 | 3:6fb5c3218608 | 9 | int l2_num; |
guesta | 3:6fb5c3218608 | 10 | int r2_num; |
guesta | 3:6fb5c3218608 | 11 | |
guesta | 3:6fb5c3218608 | 12 | //スティックのx成分取得 |
guesta | 3:6fb5c3218608 | 13 | bool getLstick_x(int rx_data,int &tx_data){ |
guesta | 3:6fb5c3218608 | 14 | x_component = rx_data; |
guesta | 3:6fb5c3218608 | 15 | return true; |
guesta | 3:6fb5c3218608 | 16 | } |
guesta | 3:6fb5c3218608 | 17 | |
guesta | 3:6fb5c3218608 | 18 | //スティックのy成分取得 |
guesta | 3:6fb5c3218608 | 19 | bool getLstick_y(int rx_data,int &tx_data){ |
guesta | 3:6fb5c3218608 | 20 | y_component = rx_data; |
guesta | 3:6fb5c3218608 | 21 | return true; |
guesta | 3:6fb5c3218608 | 22 | } |
guesta | 3:6fb5c3218608 | 23 | |
guesta | 3:6fb5c3218608 | 24 | //L1取得 |
guesta | 3:6fb5c3218608 | 25 | bool getL2(int rx_data,int &tx_data){ |
guesta | 3:6fb5c3218608 | 26 | l2_num = rx_data; |
guesta | 3:6fb5c3218608 | 27 | return true; |
guesta | 3:6fb5c3218608 | 28 | } |
guesta | 3:6fb5c3218608 | 29 | |
guesta | 3:6fb5c3218608 | 30 | //R2取得 |
guesta | 3:6fb5c3218608 | 31 | bool getR2(int rx_data,int &tx_data){ |
guesta | 3:6fb5c3218608 | 32 | r2_num = rx_data; |
guesta | 3:6fb5c3218608 | 33 | return true; |
guesta | 3:6fb5c3218608 | 34 | } |
guesta | 3:6fb5c3218608 | 35 | |
guesta | 3:6fb5c3218608 | 36 | |
guesta | 3:6fb5c3218608 | 37 | //自動、手動モード切り替え |
guesta | 3:6fb5c3218608 | 38 | bool change_mode(int rx_data,int &tx_data){ |
guesta | 3:6fb5c3218608 | 39 | if(rx_data == 1){ |
guesta | 3:6fb5c3218608 | 40 | auto_mode =! auto_mode; |
guesta | 3:6fb5c3218608 | 41 | while(auto_mode == 0); |
guesta | 3:6fb5c3218608 | 42 | } |
guesta | 3:6fb5c3218608 | 43 | return true; |
guesta | 3:6fb5c3218608 | 44 | } |
guesta | 3:6fb5c3218608 | 45 | |
guesta | 3:6fb5c3218608 | 46 | |
guesta | 3:6fb5c3218608 | 47 | #endif |