2017_Bteam_alpha_master_ashi
Dependencies: Alpha_Movements BoolProcess DataCaller MD_PID mbed angle
Fork of 2017_Bteam_alpha_master by
main.cpp@0:7318c0dde997, 2017-09-08 (annotated)
- Committer:
- Komazawa_sun
- Date:
- Fri Sep 08 03:58:36 2017 +0000
- Revision:
- 0:7318c0dde997
- Child:
- 1:12e4c91a3b04
????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Komazawa_sun | 0:7318c0dde997 | 1 | #include "mbed.h" |
Komazawa_sun | 0:7318c0dde997 | 2 | |
Komazawa_sun | 0:7318c0dde997 | 3 | #include "DataPool.h" |
Komazawa_sun | 0:7318c0dde997 | 4 | #include "AlphaTransporter.h" |
Komazawa_sun | 0:7318c0dde997 | 5 | #include "BoolProcess.h" |
Komazawa_sun | 0:7318c0dde997 | 6 | |
Komazawa_sun | 0:7318c0dde997 | 7 | #include "ArrowShooter.h" |
Komazawa_sun | 0:7318c0dde997 | 8 | |
Komazawa_sun | 0:7318c0dde997 | 9 | |
Komazawa_sun | 0:7318c0dde997 | 10 | #define SDA PB_7 |
Komazawa_sun | 0:7318c0dde997 | 11 | #define SCL PB_6 |
Komazawa_sun | 0:7318c0dde997 | 12 | |
Komazawa_sun | 0:7318c0dde997 | 13 | I2C *master; |
Komazawa_sun | 0:7318c0dde997 | 14 | DataPool *alpha; |
Komazawa_sun | 0:7318c0dde997 | 15 | |
Komazawa_sun | 0:7318c0dde997 | 16 | Serial pc(USBTX, USBRX); |
Komazawa_sun | 0:7318c0dde997 | 17 | |
Komazawa_sun | 0:7318c0dde997 | 18 | double fire_work_time; |
Komazawa_sun | 0:7318c0dde997 | 19 | int fire_work_allow = 0; |
Komazawa_sun | 0:7318c0dde997 | 20 | |
Komazawa_sun | 0:7318c0dde997 | 21 | int main() |
Komazawa_sun | 0:7318c0dde997 | 22 | { |
Komazawa_sun | 0:7318c0dde997 | 23 | master = new I2C(SDA, SCL); |
Komazawa_sun | 0:7318c0dde997 | 24 | alpha = new AlphaTransporter(master); |
Komazawa_sun | 0:7318c0dde997 | 25 | ArrowShooter shooter(master); |
Komazawa_sun | 0:7318c0dde997 | 26 | while(1) |
Komazawa_sun | 0:7318c0dde997 | 27 | { |
Komazawa_sun | 0:7318c0dde997 | 28 | alpha->set(); |
Komazawa_sun | 0:7318c0dde997 | 29 | if(alpha->read(3) == 1) |
Komazawa_sun | 0:7318c0dde997 | 30 | { |
Komazawa_sun | 0:7318c0dde997 | 31 | fire_work_allow = 1; |
Komazawa_sun | 0:7318c0dde997 | 32 | } |
Komazawa_sun | 0:7318c0dde997 | 33 | |
Komazawa_sun | 0:7318c0dde997 | 34 | if(fire_work_allow == 1) |
Komazawa_sun | 0:7318c0dde997 | 35 | { |
Komazawa_sun | 0:7318c0dde997 | 36 | fire_work_time = shooter.fire(); |
Komazawa_sun | 0:7318c0dde997 | 37 | fire_work_allow = 1; |
Komazawa_sun | 0:7318c0dde997 | 38 | } |
Komazawa_sun | 0:7318c0dde997 | 39 | if(fire_work_time >= 3.7) |
Komazawa_sun | 0:7318c0dde997 | 40 | fire_work_allow = 0; |
Komazawa_sun | 0:7318c0dde997 | 41 | |
Komazawa_sun | 0:7318c0dde997 | 42 | //printf("%f\r\n", fire_work_time); |
Komazawa_sun | 0:7318c0dde997 | 43 | } |
Komazawa_sun | 0:7318c0dde997 | 44 | } |