summaryrefslogtreecommitdiffhomepage
path: root/digital/beacon
diff options
context:
space:
mode:
authorFlorent Duchon2012-05-16 17:31:53 +0200
committerFlorent Duchon2012-05-16 17:43:11 +0200
commitb4d8344ae068467679c733998ef9e0a2cbb6956c (patch)
treedb22c99ddbc4ba5913295d51223cf05577b445dd /digital/beacon
parent61738d34f10046b667846d474724294ff159a320 (diff)
digital/beacon: sending angle management
Diffstat (limited to 'digital/beacon')
-rw-r--r--digital/beacon/src/codewheel.c3
-rw-r--r--digital/beacon/src/laser.c24
-rw-r--r--digital/beacon/src/laser.h5
3 files changed, 30 insertions, 2 deletions
diff --git a/digital/beacon/src/codewheel.c b/digital/beacon/src/codewheel.c
index 205c2e2b..b28f756c 100644
--- a/digital/beacon/src/codewheel.c
+++ b/digital/beacon/src/codewheel.c
@@ -28,6 +28,8 @@
#include <math.h>
#include "debug_avr.h"
#include "codewheel.h"
+#include "laser.h"
+#include "network.h"
codewheel_s codewheel;
@@ -111,4 +113,5 @@ ISR(TIMER3_COMPA_vect)
{
OCR3A = CODEWHEEL_CPR;
}
+ laser_reset_angle_id();
}
diff --git a/digital/beacon/src/laser.c b/digital/beacon/src/laser.c
index 888589ad..bf77cdd9 100644
--- a/digital/beacon/src/laser.c
+++ b/digital/beacon/src/laser.c
@@ -28,7 +28,9 @@
#include "debug_avr.h"
#include "laser.h"
#include "servo.h"
+#include "network.h"
#include "codewheel.h"
+#include "calibration.h"
laser_s laser;
@@ -37,6 +39,7 @@ void laser_init(void)
{
/* Init laser structiure */
laser_set_angle(0);
+ laser_reset_angle_id();
/* Configure Input compare interrupts for Laser Interrupt*/
TCCR3B |= (1<<ICNC3)|(1<<ICES3);
@@ -112,10 +115,20 @@ void laser_set_angle(uint16_t angle)
laser.angle = angle;
}
+/* This function resets the angle id variable */
+void laser_reset_angle_id(void)
+{
+ laser.angle_id = 1;
+}
/* Zigbee sending IRQ vector */
ISR(TIMER3_COMPB_vect)
{
+ uint16_t angle_to_send;
+
+ /* For debug */
+ uprintf("angle[degree] = %f --- angle[raw] = %d\r\n",laser_get_angle_degree(),laser_get_angle_raw());
+
if(calibration_get_state() != SCANNING_STATE_CALIBRATED)
{
if(codewheel_get_state() == CODEWHEEL_INIT)
@@ -139,7 +152,16 @@ ISR(TIMER3_COMPB_vect)
}
else
{
- // TODO: Send angle
+ angle_to_send = laser_get_angle_raw() + (laser.angle_id << 9);
+#ifdef LOL_NUMBER_2
+ angle_to_send = (CODEWHEEL_CPR/4 - laser_get_angle_raw()) + (laser.angle_id << 9);
+#endif
+ network_send_data(NETWORK_ANGLE_RAW,angle_to_send);
+ if((laser_get_angle_degree() > 30) && (laser_get_angle_degree() < 70))
+ {
+ uprintf("angle[%d] = %f\r\n",laser.angle_id,laser_get_angle_degree());
+ laser.angle_id++;
+ }
}
/* Disable the interrupt */
diff --git a/digital/beacon/src/laser.h b/digital/beacon/src/laser.h
index f50c5b07..f0d32d93 100644
--- a/digital/beacon/src/laser.h
+++ b/digital/beacon/src/laser.h
@@ -64,6 +64,9 @@ uint16_t laser_get_angle_raw(void);
float laser_get_angle_degrees(void);
/* This function sets the angle value in raw format */
-void laser_set_angle_raw(uint16_t angle);
+void laser_set_angle(uint16_t angle);
+
+/* This function resets the angle id variable */
+void laser_reset_angle_id(void);
#endif