firstaa

Dependents:   17robo_fuzi 17robo_tokyo_kaede

Files at this revision

API Documentation at this revision

Comitter:
echo_piyo
Date:
Wed Sep 20 07:09:56 2017 +0000
Child:
1:d4fa6f96bab5
Commit message:
1??

Changed in this revision

cylinder.cpp Show annotated file Show diff for this revision Revisions of this file
cylinder.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cylinder.cpp	Wed Sep 20 07:09:56 2017 +0000
@@ -0,0 +1,25 @@
+#include "cylinder.h"
+#include "mbed.h"
+
+Cylinder::Cylinder(PinName pin_in,PinName pin_out):cylinder_in(pin_in),cylinder_out(pin_out){
+    cylinder_in = 1;
+    cylinder_out = 0;
+}
+
+void Cylinder::cyclic(int state){
+    if(state) {
+        if(flag == false) {
+            cylinder_in = !cylinder_in;
+            cylinder_out = !cylinder_out;
+        }
+        flag = true;
+    } else flag = false;
+}
+
+int Cylinder::getInState(){
+    return (int)cylinder_in;
+}
+
+int Cylinder::getOutState(){
+    return (int)cylinder_out;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cylinder.h	Wed Sep 20 07:09:56 2017 +0000
@@ -0,0 +1,37 @@
+/*
+ * [Cylinder]
+ *      **シリンダ用クラス IOを2つ指定しサイクリックで出力を変更する
+ *      **
+ * 
+ * [Public Member Functions]
+ *  Cylinder(PinName pin_in,PinName pin_out);
+ *      **<Create> 宣言
+ *  void    cyclic(int state)
+ *      **シリンダの出力切り替え
+ *      **stateに1が入力されるたび、出力が切り替わる
+ *  int     getInState()
+ *      **シリンダ[Pin_in]の状態取得
+ *  int     getOutState()
+ *      **シリンダ[Pin_out]の状態取得
+ */
+
+#ifndef MBED_CYLINDER_H
+#define MBED_CYLINDER_H
+
+#include "mbed.h"
+
+class Cylinder
+{
+  public:
+    Cylinder(PinName pin_in,PinName pin_out);
+    void cyclic(int state);
+    int getInState();
+    int getOutState();
+    
+  private:  
+    DigitalOut cylinder_in;
+    DigitalOut cylinder_out;
+    bool flag;
+};
+
+#endif
\ No newline at end of file