-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
64 lines (52 loc) · 1.21 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Simple example of working with Daisy-like robot (Daisy, Fatima, Ferda, ...)
*
* Author: jiri.isa -at- matfyz.cz
* Created: 16.10.2005
* Modified: 15.11.2005
*
*/
#include "Logger.h"
#include "RealHardware.h"
#ifdef __unix__
#include <termios.h> //for B9600 baudrate
#endif
/* Flush output, wait for next input.
*/
void sync(AHardware *hw)
{
//schedule next execution
hw->W_executeAt = hw->R_timer + 8;
//reset watchdog
hw->W_watchDog = 0xFF;
hw->synchronize();
}
int main(void)
{
#ifdef __unix__
AHardware *hw = new RealHardware("dummy", "/dev/ttyS0", B9600);
#else
AHardware *hw = new RealHardware("dummy", "COM7", 9600);
#endif
// AHardware *hw = new Logger("dummy_051115_0617.log");
// AHardware *hw = new Logger("dummy_04_23_09_05.log", Logger::CHECK_OUTPUT);
hw->W_servo[0] = 0; // init HWRead structure
hw->W_servo[1] = 0;
sync(hw);
// move servo0 from left to right and back, while servo1 reflects analog0
uint8_t i;
for(i = 30; i < 220; i++)
{
hw->W_servo[0] = i;
hw->W_servo[1] = hw->R_analog[0];
sync(hw);
}
for(i = 220; i > 30; i--)
{
hw->W_servo[0] = i;
hw->W_servo[1] = hw->R_analog[0];
sync(hw);
}
delete hw;
return 0;
}