Collections of BERTL libraries

Committer:
DongExpander
Date:
Mon Apr 18 09:19:10 2016 +0000
Revision:
0:46115ad78747
Child:
2:4a9ed5ca8a9a
Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DongExpander 0:46115ad78747 1 #ifndef class_hardware
DongExpander 0:46115ad78747 2 #define class_hardware
DongExpander 0:46115ad78747 3
DongExpander 0:46115ad78747 4 class Motor {
DongExpander 0:46115ad78747 5 //functions
DongExpander 0:46115ad78747 6 public:
DongExpander 0:46115ad78747 7 Motor(PinName pin_pwm, PinName pin_fwd, PinName pin_rev);
DongExpander 0:46115ad78747 8 void stop();
DongExpander 0:46115ad78747 9 void stop(bool powered);
DongExpander 0:46115ad78747 10 void set(int speed);
DongExpander 0:46115ad78747 11 //variables
DongExpander 0:46115ad78747 12 private:
DongExpander 0:46115ad78747 13 PwmOut pwm;
DongExpander 0:46115ad78747 14 DigitalOut fwd;
DongExpander 0:46115ad78747 15 DigitalOut rev;
DongExpander 0:46115ad78747 16 };
DongExpander 0:46115ad78747 17
DongExpander 0:46115ad78747 18 class IRSensor {
DongExpander 0:46115ad78747 19 //functions
DongExpander 0:46115ad78747 20 public:
DongExpander 0:46115ad78747 21 IRSensor(PinName pin_ir);
DongExpander 0:46115ad78747 22 IRSensor(PinName pin_ir, int threshold_black);
DongExpander 0:46115ad78747 23 bool is_black();
DongExpander 0:46115ad78747 24 int get_data();
DongExpander 0:46115ad78747 25 //variables
DongExpander 0:46115ad78747 26 private:
DongExpander 0:46115ad78747 27 AnalogIn ir;
DongExpander 0:46115ad78747 28 int threshold;
DongExpander 0:46115ad78747 29 };
DongExpander 0:46115ad78747 30
DongExpander 0:46115ad78747 31 class USSensor {
DongExpander 0:46115ad78747 32 //functions
DongExpander 0:46115ad78747 33 public:
DongExpander 0:46115ad78747 34 USSensor(PinName pin_trigger, PinName pin_echo);
DongExpander 0:46115ad78747 35 USSensor(PinName pin_trigger, PinName pin_echo, int distance_set_bool);
DongExpander 0:46115ad78747 36 void initialize();
DongExpander 0:46115ad78747 37 private:
DongExpander 0:46115ad78747 38 void on_rise();
DongExpander 0:46115ad78747 39 void on_fall();
DongExpander 0:46115ad78747 40 void measure();
DongExpander 0:46115ad78747 41 //variables
DongExpander 0:46115ad78747 42 public:
DongExpander 0:46115ad78747 43 bool in_distance;
DongExpander 0:46115ad78747 44 int distance_mm;
DongExpander 0:46115ad78747 45 private:
DongExpander 0:46115ad78747 46 DigitalOut trigger;
DongExpander 0:46115ad78747 47 InterruptIn echo;
DongExpander 0:46115ad78747 48 Timer timer;
DongExpander 0:46115ad78747 49 Ticker ticker;
DongExpander 0:46115ad78747 50 int distance;
DongExpander 0:46115ad78747 51 };
DongExpander 0:46115ad78747 52
DongExpander 0:46115ad78747 53 #endif