sampleProgram

Dependencies:   QEI accelerator bit_test cyclic_io cyclic_var cylinder event_var limit mbed mecanum motor_drive pid pid_encoder rs422_put sbdbt servo

Fork of 17robo_fuzi by kusano kiyoshige

Revision:
51:70d45b959d6b
Parent:
50:e4e1f38d1bd5
Child:
52:f5ae47e683fa
diff -r e4e1f38d1bd5 -r 70d45b959d6b main.cpp
--- a/main.cpp	Wed Sep 13 02:17:38 2017 +0000
+++ b/main.cpp	Wed Sep 13 02:58:53 2017 +0000
@@ -85,6 +85,7 @@
 PwmOut servo(pin_servo);
 DigitalOut sbdbt_indigator(pin_sbdbt_indicator);
 varEvent event;
+varEvent cylinder_event;
 
 void setup();
 void output();
@@ -107,18 +108,6 @@
 int cylinder_pos_num = 0;
 float cylinder_pos[3] = {0.0,90.0,325.0};
 
-//riseEventそのうちClassにしたい
-short state;
-int riseEvent(int input)
-{
-    state = ((state<<1)|input)&3;
-    if(state == 1) {
-        return 1;
-    } else {
-        return 0;
-    }
-}
-
 int main()
 {
     setup();
@@ -129,7 +118,7 @@
         led4 = interrupt_sholderright_min;
         
         event.input(sbdbt.left);
-        pc.printf("riseState %d  :  fallState %d\r\n",event.getRiseState(),event.getFallState());
+        pc.printf("riseState %d  :  fallState %d\r\n",event.getRise(),event.getFall());
     }
 }
 
@@ -208,8 +197,9 @@
 void cylinder_cal()
 {
     cylinder.cyclic(sbdbt.shikaku);     //cylinder ON/OFF
-
-    if(riseEvent(sbdbt.right)) {        //cylinder degset
+    
+    cylinder_event.input(sbdbt.right);
+    if(cylinder_event.getRise()) {        //cylinder degset
         cylinder_pos_num++;
         if(cylinder_pos_num >= 3) {
             //cylinder_pos_num = 0;