ライブラリ化を行った後
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_Practice1 by
cyclick.h@13:dfae731e239f, 2017-07-17 (annotated)
- Committer:
- echo_piyo
- Date:
- Mon Jul 17 04:55:49 2017 +0000
- Revision:
- 13:dfae731e239f
cyclick.h?????????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
echo_piyo | 13:dfae731e239f | 1 | /* |
echo_piyo | 13:dfae731e239f | 2 | ★サイクリック★ |
echo_piyo | 13:dfae731e239f | 3 | サイクリックでピンをHigh/Lowするクラスです。 |
echo_piyo | 13:dfae731e239f | 4 | ①定義方法 |
echo_piyo | 13:dfae731e239f | 5 | Cyclic_IO [name]( pin ); |
echo_piyo | 13:dfae731e239f | 6 | | |
echo_piyo | 13:dfae731e239f | 7 | +--サイクリックでHigh/LowさせたいDigitalOutピン |
echo_piyo | 13:dfae731e239f | 8 | |
echo_piyo | 13:dfae731e239f | 9 | ②関数 |
echo_piyo | 13:dfae731e239f | 10 | その1 |
echo_piyo | 13:dfae731e239f | 11 | void cyclic(int state) : ピンをサイクリックでHigh/Lowさせる関数。 |
echo_piyo | 13:dfae731e239f | 12 | | |
echo_piyo | 13:dfae731e239f | 13 | +-- ボタンの入力状況を1 or 0で入れてください。 |
echo_piyo | 13:dfae731e239f | 14 | DigitalInのRead()を入れると一発で動きます。 |
echo_piyo | 13:dfae731e239f | 15 | |
echo_piyo | 13:dfae731e239f | 16 | その2 |
echo_piyo | 13:dfae731e239f | 17 | int getState() : ピンの出力状況を1 or 0で返す関数。 |
echo_piyo | 13:dfae731e239f | 18 | 出力されてたら1、されてなかったら0を返します |
echo_piyo | 13:dfae731e239f | 19 | */ |
echo_piyo | 13:dfae731e239f | 20 | |
echo_piyo | 13:dfae731e239f | 21 | #ifndef CYCLIC_H |
echo_piyo | 13:dfae731e239f | 22 | #define CYCLIC_H |
echo_piyo | 13:dfae731e239f | 23 | |
echo_piyo | 13:dfae731e239f | 24 | #include "mbed.h" |
echo_piyo | 13:dfae731e239f | 25 | |
echo_piyo | 13:dfae731e239f | 26 | class Cyclic_IO |
echo_piyo | 13:dfae731e239f | 27 | { |
echo_piyo | 13:dfae731e239f | 28 | public: |
echo_piyo | 13:dfae731e239f | 29 | Cyclic_IO(PinName pin) : gpio(pin){} |
echo_piyo | 13:dfae731e239f | 30 | |
echo_piyo | 13:dfae731e239f | 31 | void cyclic(int state) |
echo_piyo | 13:dfae731e239f | 32 | { |
echo_piyo | 13:dfae731e239f | 33 | if(state) |
echo_piyo | 13:dfae731e239f | 34 | { |
echo_piyo | 13:dfae731e239f | 35 | if(flag == false) |
echo_piyo | 13:dfae731e239f | 36 | { |
echo_piyo | 13:dfae731e239f | 37 | gpio = !gpio; |
echo_piyo | 13:dfae731e239f | 38 | } |
echo_piyo | 13:dfae731e239f | 39 | flag = true; |
echo_piyo | 13:dfae731e239f | 40 | } |
echo_piyo | 13:dfae731e239f | 41 | else flag = false; |
echo_piyo | 13:dfae731e239f | 42 | } |
echo_piyo | 13:dfae731e239f | 43 | |
echo_piyo | 13:dfae731e239f | 44 | int getState() |
echo_piyo | 13:dfae731e239f | 45 | { |
echo_piyo | 13:dfae731e239f | 46 | return (int)gpio; |
echo_piyo | 13:dfae731e239f | 47 | } |
echo_piyo | 13:dfae731e239f | 48 | |
echo_piyo | 13:dfae731e239f | 49 | private: |
echo_piyo | 13:dfae731e239f | 50 | DigitalOut gpio; |
echo_piyo | 13:dfae731e239f | 51 | bool flag; |
echo_piyo | 13:dfae731e239f | 52 | }; |
echo_piyo | 13:dfae731e239f | 53 | |
echo_piyo | 13:dfae731e239f | 54 | #endif |