Octopus!!
Dependencies: 2017NHKpin_config FEP HMC6352 PID QEI R1307 ikarashiMDC omni_wheel
Fork of KANIv3 by
bot/limitSwitch/limitSwitch.cpp@49:69a7235d837a, 2017-11-11 (annotated)
- Committer:
- number_key
- Date:
- Sat Nov 11 17:40:10 2017 +0900
- Revision:
- 49:69a7235d837a
save
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
number_key |
49:69a7235d837a | 1 | #include "limitSwitch.h" |
number_key |
49:69a7235d837a | 2 | |
number_key |
49:69a7235d837a | 3 | Limit::Limit(PinName limitSwitch1, PinName limitSwitch2) : frontSwitch(limitSwitch1), backSwitch(limitSwitch2) |
number_key |
49:69a7235d837a | 4 | { |
number_key |
49:69a7235d837a | 5 | |
number_key |
49:69a7235d837a | 6 | frontSwitch.rise(callback(this, &Limit::frontLimit)); |
number_key |
49:69a7235d837a | 7 | backSwitch.rise(callback(this, &Limit::backLimit)); |
number_key |
49:69a7235d837a | 8 | |
number_key |
49:69a7235d837a | 9 | } |
number_key |
49:69a7235d837a | 10 | |
number_key |
49:69a7235d837a | 11 | void Limit::frontLimit() |
number_key |
49:69a7235d837a | 12 | { |
number_key |
49:69a7235d837a | 13 | position = -1; |
number_key |
49:69a7235d837a | 14 | } |
number_key |
49:69a7235d837a | 15 | |
number_key |
49:69a7235d837a | 16 | void Limit::backLimit() |
number_key |
49:69a7235d837a | 17 | { |
number_key |
49:69a7235d837a | 18 | position = 1; |
number_key |
49:69a7235d837a | 19 | } |
number_key |
49:69a7235d837a | 20 | |
number_key |
49:69a7235d837a | 21 | void Limit::resetPosition() |
number_key |
49:69a7235d837a | 22 | { |
number_key |
49:69a7235d837a | 23 | position = 0; |
number_key |
49:69a7235d837a | 24 | } |
number_key |
49:69a7235d837a | 25 | |
number_key |
49:69a7235d837a | 26 | int Limit::getPosition() |
number_key |
49:69a7235d837a | 27 | { |
number_key |
49:69a7235d837a | 28 | return position; |
number_key |
49:69a7235d837a | 29 | } |