-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
executable file
·68 lines (49 loc) · 1.09 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
#include "WProgram.h"
#include <avr/interrupt.h>
extern "C"{
#include "motorcontrol.h"
#include "pwm.h"
#include <avr/io.h>
}
#include "Servo.h"
#include "IRRangers.h"
#include <avr/delay.h>
extern "C" void __cxa_pure_virtual()
{
cli();
for (;;);
}
int main(void)
{
init();
Serial.begin(57600);
IRRangers scanner;
scanner.setServoAngle(10);
//scanner.ContinousScan();
//scanner.ContinousScan();
scanner.setMaxScanAngle(120);
Serial.flush();
while(1==1){
if (Serial.available()){ // get new byte, parse if neccesaryp
char c = Serial.read();
if (c ==10){
//Printout data
int i;\
Serial.write(c); //Send command back
Serial.write(scanner.scanIndex+1); // send scan
for ( i=0; i<= scanner.scanIndex; i++){
Serial.write(scanner.data[i].angle);
Serial.writeInt(scanner.data[i].leftEncoderCount);
Serial.writeInt(scanner.data[i].rightEncocerCount);
Serial.write(scanner.data[i].angle);
for (int j=0; j<4; j++){
Serial.writeInt(scanner.data[i].irData[j]);
}
}
scanner.scanIndex =0;
}
}
scanner.scan2();
_delay_ms(1);
}
}