![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ライブラリ化を行った後
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
headerfile_unuse/cylinder_.h@77:17469192b53a, 2017-09-28 (annotated)
- Committer:
- echo_piyo
- Date:
- Thu Sep 28 02:25:00 2017 +0000
- Revision:
- 77:17469192b53a
- Parent:
- 66:1664ee92539d
(?)????(?????)????????????????????????????????????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
echo_piyo | 15:0fdf483769bf | 1 | /* |
echo_piyo | 15:0fdf483769bf | 2 | ★サイクリック★ |
echo_piyo | 15:0fdf483769bf | 3 | サイクリックでピンをHigh/Lowするクラスです。 |
echo_piyo | 15:0fdf483769bf | 4 | ①定義方法 |
echo_piyo | 15:0fdf483769bf | 5 | Cyclic_IO [name]( pin ); |
echo_piyo | 15:0fdf483769bf | 6 | | |
echo_piyo | 15:0fdf483769bf | 7 | +--サイクリックでHigh/LowさせたいDigitalOutピン |
echo_piyo | 15:0fdf483769bf | 8 | |
echo_piyo | 15:0fdf483769bf | 9 | ②関数 |
echo_piyo | 15:0fdf483769bf | 10 | その1 |
echo_piyo | 15:0fdf483769bf | 11 | void cyclic(int state) : ピンをサイクリックでHigh/Lowさせる関数。 |
echo_piyo | 15:0fdf483769bf | 12 | | |
echo_piyo | 15:0fdf483769bf | 13 | +-- ボタンの入力状況を1 or 0で入れてください。 |
echo_piyo | 15:0fdf483769bf | 14 | DigitalInのRead()を入れると一発で動きます。 |
echo_piyo | 15:0fdf483769bf | 15 | |
echo_piyo | 15:0fdf483769bf | 16 | その2 |
echo_piyo | 15:0fdf483769bf | 17 | int getState() : ピンの出力状況を1 or 0で返す関数。 |
echo_piyo | 15:0fdf483769bf | 18 | 出力されてたら1、されてなかったら0を返します |
echo_piyo | 15:0fdf483769bf | 19 | */ |
echo_piyo | 15:0fdf483769bf | 20 | |
echo_piyo | 15:0fdf483769bf | 21 | #ifndef CYLINDER_H |
echo_piyo | 15:0fdf483769bf | 22 | #define CYLINDER_H |
echo_piyo | 15:0fdf483769bf | 23 | |
echo_piyo | 15:0fdf483769bf | 24 | #include "mbed.h" |
echo_piyo | 15:0fdf483769bf | 25 | |
echo_piyo | 15:0fdf483769bf | 26 | class Cylinder |
echo_piyo | 15:0fdf483769bf | 27 | { |
echo_piyo | 15:0fdf483769bf | 28 | public: |
echo_piyo | 15:0fdf483769bf | 29 | Cylinder(PinName pin_in,PinName pin_out):cylinder_in(pin_in),cylinder_out(pin_out){ |
echo_piyo | 15:0fdf483769bf | 30 | cylinder_in = 1; |
echo_piyo | 15:0fdf483769bf | 31 | cylinder_out = 0; |
echo_piyo | 15:0fdf483769bf | 32 | } |
echo_piyo | 15:0fdf483769bf | 33 | |
echo_piyo | 15:0fdf483769bf | 34 | void cyclic(int state) |
echo_piyo | 15:0fdf483769bf | 35 | { |
echo_piyo | 15:0fdf483769bf | 36 | if(state) |
echo_piyo | 15:0fdf483769bf | 37 | { |
echo_piyo | 15:0fdf483769bf | 38 | if(flag == false) |
echo_piyo | 15:0fdf483769bf | 39 | { |
echo_piyo | 15:0fdf483769bf | 40 | cylinder_in = !cylinder_in; |
echo_piyo | 15:0fdf483769bf | 41 | cylinder_out = !cylinder_out; |
echo_piyo | 15:0fdf483769bf | 42 | } |
echo_piyo | 15:0fdf483769bf | 43 | flag = true; |
echo_piyo | 15:0fdf483769bf | 44 | } |
echo_piyo | 15:0fdf483769bf | 45 | else flag = false; |
echo_piyo | 15:0fdf483769bf | 46 | } |
echo_piyo | 15:0fdf483769bf | 47 | |
echo_piyo | 15:0fdf483769bf | 48 | int getInState() |
echo_piyo | 15:0fdf483769bf | 49 | { |
echo_piyo | 15:0fdf483769bf | 50 | return (int)cylinder_in; |
echo_piyo | 15:0fdf483769bf | 51 | } |
echo_piyo | 15:0fdf483769bf | 52 | |
echo_piyo | 15:0fdf483769bf | 53 | int getOutState() |
echo_piyo | 15:0fdf483769bf | 54 | { |
echo_piyo | 15:0fdf483769bf | 55 | return (int)cylinder_out; |
echo_piyo | 15:0fdf483769bf | 56 | } |
echo_piyo | 15:0fdf483769bf | 57 | |
echo_piyo | 15:0fdf483769bf | 58 | private: |
echo_piyo | 15:0fdf483769bf | 59 | DigitalOut cylinder_in; |
echo_piyo | 15:0fdf483769bf | 60 | DigitalOut cylinder_out; |
echo_piyo | 15:0fdf483769bf | 61 | bool flag; |
echo_piyo | 15:0fdf483769bf | 62 | }; |
echo_piyo | 15:0fdf483769bf | 63 | |
echo_piyo | 15:0fdf483769bf | 64 | #endif |