Collections of BERTL libraries
class_hardware.h@3:1708f20fd55b, 2016-04-18 (annotated)
- Committer:
- DongExpander
- Date:
- Mon Apr 18 12:48:42 2016 +0000
- Revision:
- 3:1708f20fd55b
- Parent:
- 2:4a9ed5ca8a9a
Feature; Added initialize()
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DongExpander | 2:4a9ed5ca8a9a | 1 | #ifndef class_hardware |
DongExpander | 2:4a9ed5ca8a9a | 2 | #define class_hardware |
DongExpander | 2:4a9ed5ca8a9a | 3 | |
DongExpander | 2:4a9ed5ca8a9a | 4 | class Motor { |
DongExpander | 2:4a9ed5ca8a9a | 5 | //functions |
DongExpander | 2:4a9ed5ca8a9a | 6 | public: |
DongExpander | 2:4a9ed5ca8a9a | 7 | Motor(PinName pin_pwm, PinName pin_fwd, PinName pin_rev); |
DongExpander | 2:4a9ed5ca8a9a | 8 | void stop(); |
DongExpander | 2:4a9ed5ca8a9a | 9 | void stop(bool powered); |
DongExpander | 2:4a9ed5ca8a9a | 10 | void set(int speed); |
DongExpander | 2:4a9ed5ca8a9a | 11 | //variables |
DongExpander | 2:4a9ed5ca8a9a | 12 | private: |
DongExpander | 2:4a9ed5ca8a9a | 13 | PwmOut pwm; |
DongExpander | 2:4a9ed5ca8a9a | 14 | DigitalOut fwd; |
DongExpander | 2:4a9ed5ca8a9a | 15 | DigitalOut rev; |
DongExpander | 2:4a9ed5ca8a9a | 16 | }; |
DongExpander | 2:4a9ed5ca8a9a | 17 | |
DongExpander | 2:4a9ed5ca8a9a | 18 | class IRSensor { |
DongExpander | 2:4a9ed5ca8a9a | 19 | //functions |
DongExpander | 2:4a9ed5ca8a9a | 20 | public: |
DongExpander | 2:4a9ed5ca8a9a | 21 | IRSensor(PinName pin_ir); |
DongExpander | 2:4a9ed5ca8a9a | 22 | IRSensor(PinName pin_ir, int threshold_black); |
DongExpander | 2:4a9ed5ca8a9a | 23 | bool is_black(); |
DongExpander | 2:4a9ed5ca8a9a | 24 | int get_data(); |
DongExpander | 2:4a9ed5ca8a9a | 25 | //variables |
DongExpander | 2:4a9ed5ca8a9a | 26 | private: |
DongExpander | 2:4a9ed5ca8a9a | 27 | AnalogIn ir; |
DongExpander | 2:4a9ed5ca8a9a | 28 | int threshold; |
DongExpander | 2:4a9ed5ca8a9a | 29 | }; |
DongExpander | 2:4a9ed5ca8a9a | 30 | |
DongExpander | 2:4a9ed5ca8a9a | 31 | class USSensor { |
DongExpander | 2:4a9ed5ca8a9a | 32 | //functions |
DongExpander | 2:4a9ed5ca8a9a | 33 | public: |
DongExpander | 2:4a9ed5ca8a9a | 34 | USSensor(PinName pin_trigger, PinName pin_echo); |
DongExpander | 2:4a9ed5ca8a9a | 35 | USSensor(PinName pin_trigger, PinName pin_echo, int distance_set_bool); |
DongExpander | 2:4a9ed5ca8a9a | 36 | void initialize(); |
DongExpander | 2:4a9ed5ca8a9a | 37 | private: |
DongExpander | 2:4a9ed5ca8a9a | 38 | void on_rise(); |
DongExpander | 2:4a9ed5ca8a9a | 39 | void on_fall(); |
DongExpander | 2:4a9ed5ca8a9a | 40 | void measure(); |
DongExpander | 2:4a9ed5ca8a9a | 41 | //variables |
DongExpander | 2:4a9ed5ca8a9a | 42 | public: |
DongExpander | 2:4a9ed5ca8a9a | 43 | bool in_distance; |
DongExpander | 2:4a9ed5ca8a9a | 44 | int distance_mm; |
DongExpander | 2:4a9ed5ca8a9a | 45 | private: |
DongExpander | 2:4a9ed5ca8a9a | 46 | DigitalOut trigger; |
DongExpander | 2:4a9ed5ca8a9a | 47 | InterruptIn echo; |
DongExpander | 2:4a9ed5ca8a9a | 48 | Timer timer; |
DongExpander | 2:4a9ed5ca8a9a | 49 | Ticker ticker; |
DongExpander | 2:4a9ed5ca8a9a | 50 | int distance; |
DongExpander | 2:4a9ed5ca8a9a | 51 | }; |
DongExpander | 2:4a9ed5ca8a9a | 52 | |
DongExpander | 2:4a9ed5ca8a9a | 53 | #endif |
DongExpander | 0:46115ad78747 | 54 |