2017 hongo b team

Dependencies:   Alpha_Movements BoolProcess DataCaller mbed

Files at this revision

API Documentation at this revision

Comitter:
Komazawa_sun
Date:
Fri Sep 08 03:58:36 2017 +0000
Commit message:
????

Changed in this revision

Alpha_Movements.lib Show annotated file Show diff for this revision Revisions of this file
ArrowShooter.cpp Show annotated file Show diff for this revision Revisions of this file
ArrowShooter.h Show annotated file Show diff for this revision Revisions of this file
BoolProcess.lib Show annotated file Show diff for this revision Revisions of this file
DataCaller.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 7318c0dde997 Alpha_Movements.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Alpha_Movements.lib	Fri Sep 08 03:58:36 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/Komazawa_sun/code/Alpha_Movements/#bfcf3d8939d7
diff -r 000000000000 -r 7318c0dde997 ArrowShooter.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ArrowShooter.cpp	Fri Sep 08 03:58:36 2017 +0000
@@ -0,0 +1,41 @@
+#include "ArrowShooter.h"
+
+ArrowShooter::ArrowShooter(I2C *_master, double _strt_inval)
+:   to_slave(alpha_a::sht_pwr, alpha_a::unsig, alpha_a::s2_addr, _master),
+    _MD(&i2c_md),
+    motor(_MD, _strt_inval)
+{
+    time.reset();
+    time.start();
+}
+
+double ArrowShooter::fire()
+{
+    
+    if(2.5 > time.read())
+    {
+        //printf("ypaaa!!");
+        set_pwm(1.0);
+    }
+    else if(3.8 > time.read())
+    {
+        set_pwm(0.0);
+    }
+    else 
+    {
+        time.reset();
+    }        
+
+    
+    printf("%d\r\n",i2c_md.get_output());
+    
+    return time.read(); 
+       
+}
+
+void ArrowShooter::set_pwm(double pwm, double inval)
+{
+    motor.reform_inval(inval);
+    motor.drive(pwm);
+    to_slave.write((uint8_t)i2c_md.get_output());  
+}
\ No newline at end of file
diff -r 000000000000 -r 7318c0dde997 ArrowShooter.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ArrowShooter.h	Fri Sep 08 03:58:36 2017 +0000
@@ -0,0 +1,33 @@
+#ifndef ARROW_SHOOTER_H
+#define ARROW_SHOOTER_H
+
+#include "mbed.h"
+
+#include "Alpha_ApprI2C_ID.h"
+#include "ApprI2CMaster.h"
+
+#include "MotorDriver.h"
+#include "ThrowData_MD.h"
+#include "CtrlMD.h"
+
+
+class ArrowShooter
+{
+    public:
+        ArrowShooter(I2C *_master, double _strt_inval = 0.01);
+        
+        double fire();
+        void set_pwm(double pwm, double inval = 0.01);
+        
+    private:
+        ApprI2CMaster to_slave;
+        ThrowData i2c_md;
+        MotorDriver *_MD;
+        CtrlMD motor;
+        
+        Timer time;
+        
+};
+
+#endif
+
diff -r 000000000000 -r 7318c0dde997 BoolProcess.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BoolProcess.lib	Fri Sep 08 03:58:36 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/Komazawa_sun/code/BoolProcess/#69948f240c2d
diff -r 000000000000 -r 7318c0dde997 DataCaller.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DataCaller.lib	Fri Sep 08 03:58:36 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/Komazawa_sun/code/DataCaller/#1805ed23b37b
diff -r 000000000000 -r 7318c0dde997 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Sep 08 03:58:36 2017 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+
+#include "DataPool.h"
+#include "AlphaTransporter.h"
+#include "BoolProcess.h"
+
+#include "ArrowShooter.h"
+
+
+#define SDA PB_7
+#define SCL PB_6
+
+I2C *master;
+DataPool *alpha;
+
+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);
+    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;
+            
+        //printf("%f\r\n", fire_work_time);
+    }
+}
diff -r 000000000000 -r 7318c0dde997 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Sep 08 03:58:36 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a330f0fddbec
\ No newline at end of file