summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorFlorent Duchon2012-04-22 22:45:10 +0200
committerFlorent Duchon2012-05-04 00:06:27 +0200
commit173d287c98800d26c05e19a15c83354ce6b19825 (patch)
treeafba7e7570f6f9073b4e6f96c13be5c60df527dd /digital
parent769f66910b6651199014d20e48b2c533684b73d8 (diff)
digital/beacon: rename angle variable into virtual_angle in laser IRQ
Diffstat (limited to 'digital')
-rw-r--r--digital/beacon/src/laser.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/digital/beacon/src/laser.c b/digital/beacon/src/laser.c
index 859852b7..bc6458b1 100644
--- a/digital/beacon/src/laser.c
+++ b/digital/beacon/src/laser.c
@@ -96,7 +96,7 @@ ISR(TIMER3_COMPB_vect)
/* Laser IRQ vector */
ISR(TIMER3_CAPT_vect)
{
- static uint16_t angle = 0;
+ static uint16_t virtual_angle = 0;
TLaser_edge_type current_edge;
current_edge = laser_get_edge_type();
@@ -104,15 +104,21 @@ ISR(TIMER3_CAPT_vect)
switch(current_edge)
{
case LASER_FIRST_RISING_EDGE:
- angle = ICR3;
+ virtual_angle = ICR3;
break;
case LASER_RISING_EDGE:
- angle = (angle + ICR3) / 2;
/* Could be a bounce so inhibit the latest angle confirmation */
laser_inhibit_angle_confirmation();
+ /* Recompute the angle value */
+ virtual_angle = (virtual_angle + ICR3) / 2;
break;
case LASER_FALLING_EDGE:
- angle = (angle + ICR3) / 2;
+ /* Recompute the angle value */
+ virtual_angle = (virtual_angle + ICR3) / 2;
+
+ /* It's a falling edge so potentially current_angle could be a real one */
+ laser_set_angle(virtual_angle);
+
/* Start virtual angle confirmation */
laser_engage_angle_confirmation(ICR3);
break;