2017_Bteam_alpha_master_ashi

Dependencies:   Alpha_Movements BoolProcess DataCaller MD_PID mbed angle

Fork of 2017_Bteam_alpha_master by taiyou komazawa

Committer:
hirotayamato
Date:
Fri Sep 08 06:26:22 2017 +0000
Revision:
1:12e4c91a3b04
Parent:
0:7318c0dde997
Child:
3:8d143b23df2a
2017_Bteam_alpha_master_ashi

Who changed what in which revision?

UserRevisionLine numberNew 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
hirotayamato 1:12e4c91a3b04 9 #include "2017_4.h"
Komazawa_sun 0:7318c0dde997 10
Komazawa_sun 0:7318c0dde997 11 #define SDA PB_7
Komazawa_sun 0:7318c0dde997 12 #define SCL PB_6
Komazawa_sun 0:7318c0dde997 13
Komazawa_sun 0:7318c0dde997 14 I2C *master;
Komazawa_sun 0:7318c0dde997 15 DataPool *alpha;
Komazawa_sun 0:7318c0dde997 16
hirotayamato 1:12e4c91a3b04 17 Mekanamu_4 Mekanamu(PA_8, PB_0, PA_2, PA_7, PA_11, PB_1, PA_6, PA_5, PB_5, PF_0, PA_4, PA_3, PB_4, PF_1, PA_1, PA_0, 1);
Komazawa_sun 0:7318c0dde997 18 Serial pc(USBTX, USBRX);
Komazawa_sun 0:7318c0dde997 19
Komazawa_sun 0:7318c0dde997 20 double fire_work_time;
Komazawa_sun 0:7318c0dde997 21 int fire_work_allow = 0;
Komazawa_sun 0:7318c0dde997 22
Komazawa_sun 0:7318c0dde997 23 int main()
Komazawa_sun 0:7318c0dde997 24 {
Komazawa_sun 0:7318c0dde997 25 master = new I2C(SDA, SCL);
Komazawa_sun 0:7318c0dde997 26 alpha = new AlphaTransporter(master);
Komazawa_sun 0:7318c0dde997 27 ArrowShooter shooter(master);
hirotayamato 1:12e4c91a3b04 28
hirotayamato 1:12e4c91a3b04 29 Mekanamu.Drive(0, 0, 0);
hirotayamato 1:12e4c91a3b04 30 float x, y, t;
Komazawa_sun 0:7318c0dde997 31 while(1)
Komazawa_sun 0:7318c0dde997 32 {
Komazawa_sun 0:7318c0dde997 33 alpha->set();
Komazawa_sun 0:7318c0dde997 34 if(alpha->read(3) == 1)
Komazawa_sun 0:7318c0dde997 35 {
Komazawa_sun 0:7318c0dde997 36 fire_work_allow = 1;
Komazawa_sun 0:7318c0dde997 37 }
Komazawa_sun 0:7318c0dde997 38
Komazawa_sun 0:7318c0dde997 39 if(fire_work_allow == 1)
Komazawa_sun 0:7318c0dde997 40 {
Komazawa_sun 0:7318c0dde997 41 fire_work_time = shooter.fire();
Komazawa_sun 0:7318c0dde997 42 fire_work_allow = 1;
Komazawa_sun 0:7318c0dde997 43 }
Komazawa_sun 0:7318c0dde997 44 if(fire_work_time >= 3.7)
Komazawa_sun 0:7318c0dde997 45 fire_work_allow = 0;
hirotayamato 1:12e4c91a3b04 46
hirotayamato 1:12e4c91a3b04 47 x = alpha->read(0) / 128;
hirotayamato 1:12e4c91a3b04 48 y = alpha->read(1) / 128;
hirotayamato 1:12e4c91a3b04 49 t = alpha->read(2) / 128;
hirotayamato 1:12e4c91a3b04 50 Mekanamu.Drive(x, y, t);
Komazawa_sun 0:7318c0dde997 51
Komazawa_sun 0:7318c0dde997 52 //printf("%f\r\n", fire_work_time);
Komazawa_sun 0:7318c0dde997 53 }
Komazawa_sun 0:7318c0dde997 54 }