2017_Bteam_alpha_master_ashi

Dependencies:   Alpha_Movements BoolProcess DataCaller MD_PID mbed angle

Fork of 2017_Bteam_alpha_master by taiyou komazawa

main.cpp

Committer:
hirotayamato
Date:
2017-09-21
Revision:
8:701a9c23b517
Parent:
6:2317b3e22cb5
Child:
10:94527f9ac652

File content as of revision 8:701a9c23b517:

#include "mbed.h"

#include "DataPool.h"
#include "AlphaTransporter.h"
#include "BoolProcess.h"

#include "ArrowShooter.h"

#include "2017_4.h"

#define SDA PB_7
#define SCL PB_6

I2C *master;
DataPool *alpha;

Mecanamu_4 Mecanamu(PA_8, PB_0, PA_12, 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);
Serial pc(USBTX, USBRX);

double fire_work_time;
int fire_work_allow = 0;

int main()
{
    master = new I2C(SDA, SCL);
    alpha = new AlphaTransporter(master);
    ArrowShooter shooter(master);
    
    Mecanamu.Drive(0, 0, 0);
    float x, y, t;
    while(1)
    {
        alpha->set();
        if(alpha->read(3) == 1)
        {
            fire_work_allow = 1;
        }
        
        if(fire_work_allow == 1)
        {
            fire_work_time = shooter.fire(); 
            fire_work_allow = 1;
        }
        if(fire_work_time >= 3.7)
            fire_work_allow = 0;
        
        x = alpha->read(0) / 128.00;
        y = alpha->read(1) / 128.00;
        t = alpha->read(2) / 128.00;
        Mecanamu.Drive(x, y, t);
        wait(0.01);
        
        //printf("%lf, %lf, %lf\r\n", x, y, t);
    }
}