Bayley Wang
/
priustroller_3
temp repo
Fork of priustroller_2 by
core/motor.cpp@11:dccbaa9274c5, 2015-03-08 (annotated)
- Committer:
- bwang
- Date:
- Sun Mar 08 08:37:38 2015 +0000
- Revision:
- 11:dccbaa9274c5
- Parent:
- motor.cpp@6:99ee0ce47fb2
- Child:
- 29:cb03760ba9ea
--Initial Commit: 03-08-2015 new context-based code; no more timers (=easier debugging)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 0:54cf32d35f4d | 1 | #include "includes.h" |
bwang | 1:1f58bdcf2956 | 2 | #include "core.h" |
bwang | 1:1f58bdcf2956 | 3 | #include "sensors.h" |
bwang | 0:54cf32d35f4d | 4 | |
nki | 6:99ee0ce47fb2 | 5 | Motor::Motor(CurrentSensor *sense_c, CurrentSensor *sense_b, PositionSensor *sense_p, TempSensor *sense_t) { |
nki | 6:99ee0ce47fb2 | 6 | _sense_c = sense_c; |
bwang | 0:54cf32d35f4d | 7 | _sense_b = sense_b; |
bwang | 0:54cf32d35f4d | 8 | _sense_p = sense_p; |
bwang | 0:54cf32d35f4d | 9 | _sense_t = sense_t; |
bwang | 0:54cf32d35f4d | 10 | } |
bwang | 0:54cf32d35f4d | 11 | |
bwang | 11:dccbaa9274c5 | 12 | float Motor::GetCurrentC() { |
bwang | 11:dccbaa9274c5 | 13 | return _sense_c->GetCurrent(); |
bwang | 0:54cf32d35f4d | 14 | } |
bwang | 0:54cf32d35f4d | 15 | |
bwang | 11:dccbaa9274c5 | 16 | float Motor::GetCurrentB() { |
bwang | 11:dccbaa9274c5 | 17 | return _sense_b->GetCurrent(); |
bwang | 0:54cf32d35f4d | 18 | } |
bwang | 0:54cf32d35f4d | 19 | |
bwang | 11:dccbaa9274c5 | 20 | float Motor::GetPosition() { |
bwang | 11:dccbaa9274c5 | 21 | return _sense_p->GetPosition(); |
bwang | 0:54cf32d35f4d | 22 | } |
bwang | 0:54cf32d35f4d | 23 | |
bwang | 11:dccbaa9274c5 | 24 | float Motor::GetTemp() { |
bwang | 11:dccbaa9274c5 | 25 | return _sense_t->GetTemp(); |
bwang | 0:54cf32d35f4d | 26 | } |
bwang | 0:54cf32d35f4d | 27 | |
bwang | 0:54cf32d35f4d | 28 | void Motor::Config(int num_poles, float kv) { |
bwang | 0:54cf32d35f4d | 29 | _num_poles = num_poles; |
bwang | 0:54cf32d35f4d | 30 | _kv = kv; |
bwang | 0:54cf32d35f4d | 31 | } |