ETrobocon2017 - 片山研究所モデルベース開発推進事業部
str
apps
src
Lifter.cpp
[詳解]
1
#include "
Lifter.h
"
2
3
Lifter::Lifter
():
4
liftHand(
PORT_A
) {
5
liftHand.
reset
();
6
}
7
8
void
Lifter::init
() {
9
init_f
(
"Lifter"
);
10
}
11
12
void
Lifter::terminate
() {
13
msg_f
(
"Stopped."
, 1);
14
liftHand.
stop
();
15
}
16
17
void
Lifter::reset
() {
18
liftHand.
reset
();
19
liftHand.
setBrake
(
true
);
20
liftHand.
setBrake
(
false
);
21
}
22
23
void
Lifter::liftUp
() {
24
liftHand.
setPWM
(20);
25
clock.
sleep
(1000);
26
liftHand.
setBrake
(
true
);
27
}
28
29
void
Lifter::liftDown
() {
30
liftHand.
setPWM
(-20);
31
clock.
sleep
(1000);
32
liftHand.
setBrake
(
true
);
33
}
34
35
void
Lifter::changeDefault
(
int
angle) {
36
Lifter::defaultSet
(angle);
37
Lifter::reset
();
38
}
39
40
void
Lifter::defaultSet
(
int
angle) {
41
int
i = 0;
42
for
(i = 0; i < 300; i++) {
43
liftHand.
setPWM
(-((liftHand.
getCount
() - angle) % 360));
44
clock.
sleep
(1);
45
}
46
liftHand.
setPWM
(0);
47
liftHand.
setBrake
(
true
);
48
}
ev3api::Motor::setPWM
void setPWM(int pwm)
Definition:
Motor.cpp:31
Lifter::liftUp
void liftUp()
Definition:
Lifter.cpp:23
Lifter::terminate
void terminate()
Definition:
Lifter.cpp:12
ev3api::Motor::setBrake
void setBrake(bool brake)
Definition:
Motor.cpp:47
ev3api::Motor::reset
void reset(void)
Definition:
Motor.h:55
Lifter::defaultSet
void defaultSet(int angle)
Definition:
Lifter.cpp:40
Lifter::liftDown
void liftDown()
Definition:
Lifter.cpp:29
Lifter::reset
void reset()
Definition:
Lifter.cpp:17
init_f
void init_f(const char *str)
Definition:
util.cpp:6
ev3api::Clock::sleep
void sleep(uint32_t duration)
Definition:
Clock.h:58
msg_f
void msg_f(const char *str, int32_t line)
Definition:
util.cpp:17
Lifter::init
void init()
Definition:
Lifter.cpp:8
ev3api::Motor::getCount
int32_t getCount(void) const
Definition:
Motor.h:67
ev3api::Motor::stop
void stop()
Definition:
Motor.h:97
Lifter::Lifter
Lifter()
Definition:
Lifter.cpp:3
Lifter::changeDefault
void changeDefault(int angle)
Definition:
Lifter.cpp:35
Lifter.h
PORT_A
Definition:
Port.h:31
構築:
1.8.13