kusano kiyoshige / Mbed 2 deprecated 17robo_tokyo_kaede

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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cyclic_IO_.h Source File

cyclic_IO_.h

00001 /*
00002     ★サイクリック★
00003 サイクリックでピンをHigh/Lowするクラスです。
00004 ①定義方法
00005     Cyclic_IO [name]( pin );
00006                     |
00007                     +--サイクリックでHigh/LowさせたいDigitalOutピン 
00008                     
00009 ②関数
00010     その1
00011       void cyclic(int state)  :  ピンをサイクリックでHigh/Lowさせる関数。
00012                         |
00013                         +-- ボタンの入力状況を1 or 0で入れてください。
00014                             DigitalInのRead()を入れると一発で動きます。
00015      
00016      その2               
00017      int getState() :   ピンの出力状況を1 or 0で返す関数。
00018                         出力されてたら1、されてなかったら0を返します
00019 */
00020 
00021 #ifndef CYCLIC_H
00022 #define CYCLIC_H
00023 
00024 #include "mbed.h"
00025 
00026 class Cyclic_IO 
00027 {
00028   public:
00029     Cyclic_IO(PinName pin) : gpio(pin){}
00030     
00031     void cyclic(int state)
00032     {
00033         if(state)
00034         {
00035             if(flag == false)
00036             {
00037                 gpio = !gpio; 
00038             }
00039             flag = true;
00040         }
00041         else flag = false;
00042     }
00043     
00044     int getState()
00045     {
00046         return (int)gpio; 
00047     }
00048     
00049   private:  
00050     DigitalOut gpio;
00051     bool flag;
00052 };
00053 
00054 #endif