![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
SEDO subject project
Dependencies: ds3231 mbed-rtos mbed DHT
motor_cnt.cpp@12:1d544cdab2cf, 2017-05-15 (annotated)
- Committer:
- ValenSalLop
- Date:
- Mon May 15 18:30:20 2017 +0000
- Revision:
- 12:1d544cdab2cf
- Parent:
- 10:f14f47225091
final;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ValenSalLop | 10:f14f47225091 | 1 | #include "mbed.h" |
ValenSalLop | 10:f14f47225091 | 2 | #include "motor_cnt.h" |
ValenSalLop | 10:f14f47225091 | 3 | |
ValenSalLop | 12:1d544cdab2cf | 4 | PwmOut m_speed(D5); |
ValenSalLop | 12:1d544cdab2cf | 5 | DigitalOut m_direction(D4); |
ValenSalLop | 12:1d544cdab2cf | 6 | uint8_t speed_current = 0; |
ValenSalLop | 12:1d544cdab2cf | 7 | uint8_t direction_current = 0; |
ValenSalLop | 10:f14f47225091 | 8 | |
ValenSalLop | 12:1d544cdab2cf | 9 | int set_motor_speed(float speed) |
ValenSalLop | 10:f14f47225091 | 10 | { |
ValenSalLop | 10:f14f47225091 | 11 | m_speed = speed; |
ValenSalLop | 10:f14f47225091 | 12 | speed_current = speed; |
ValenSalLop | 10:f14f47225091 | 13 | return 0; |
ValenSalLop | 10:f14f47225091 | 14 | } |
ValenSalLop | 10:f14f47225091 | 15 | int set_motor_direction(uint8_t direction) |
ValenSalLop | 10:f14f47225091 | 16 | { |
ValenSalLop | 10:f14f47225091 | 17 | if(direction != 0) { |
ValenSalLop | 10:f14f47225091 | 18 | m_direction=1; |
ValenSalLop | 10:f14f47225091 | 19 | direction_current=1; |
ValenSalLop | 10:f14f47225091 | 20 | } else { |
ValenSalLop | 10:f14f47225091 | 21 | m_direction=0; |
ValenSalLop | 10:f14f47225091 | 22 | direction_current=0; |
ValenSalLop | 10:f14f47225091 | 23 | } |
ValenSalLop | 10:f14f47225091 | 24 | return 0; |
ValenSalLop | 10:f14f47225091 | 25 | } |
ValenSalLop | 10:f14f47225091 | 26 | int get_motor_speed(void) |
ValenSalLop | 10:f14f47225091 | 27 | { |
ValenSalLop | 10:f14f47225091 | 28 | return speed_current; |
ValenSalLop | 10:f14f47225091 | 29 | } |
ValenSalLop | 10:f14f47225091 | 30 | int get_motor_direction(void) |
ValenSalLop | 10:f14f47225091 | 31 | { |
ValenSalLop | 10:f14f47225091 | 32 | return direction_current; |
ValenSalLop | 10:f14f47225091 | 33 | } |