changeset 173:ac37f2690f0b main

Change this message to use uint8_t instead of uint16_t. The values are approximately inches.
author Bob Cook <bob@bobcookdev.com>
date Wed, 06 Feb 2013 21:45:48 -0800
parents cb2333758fb8
children 7bfb98e62138
files main/packages/common/can/can_messages.h main/robots/odr-sonar-front/canmsgs.cpp main/robots/odr-sonar-front/func.h main/robots/odr-sonar-front/sonar.cpp
diffstat 4 files changed, 18 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/main/packages/common/can/can_messages.h	Sat Jan 12 15:21:52 2013 -0800
+++ b/main/packages/common/can/can_messages.h	Wed Feb 06 21:45:48 2013 -0800
@@ -165,10 +165,10 @@
 
 typedef struct
 {
-    uint16_t left;
-    uint16_t center_left;
-    uint16_t center_right;
-    uint16_t right;
+    uint8_t left;
+    uint8_t center_left;
+    uint8_t center_right;
+    uint8_t right;
 
 } can_data_sonar_front;
 
--- a/main/robots/odr-sonar-front/canmsgs.cpp	Sat Jan 12 15:21:52 2013 -0800
+++ b/main/robots/odr-sonar-front/canmsgs.cpp	Wed Feb 06 21:45:48 2013 -0800
@@ -72,10 +72,10 @@
 
 bool canmsg_send_sonar_front
 (
-    uint16_t left,
-    uint16_t center_left,
-    uint16_t center_right,
-    uint16_t right
+    uint8_t left,
+    uint8_t center_left,
+    uint8_t center_right,
+    uint8_t right
 )
 {
     uint32_t msgid = can_build_message_id( can_node_odr_sonar_front,
--- a/main/robots/odr-sonar-front/func.h	Sat Jan 12 15:21:52 2013 -0800
+++ b/main/robots/odr-sonar-front/func.h	Wed Feb 06 21:45:48 2013 -0800
@@ -44,7 +44,7 @@
 
 bool canmsg_init();
 bool canmsg_send_status( bool enabled );
-bool canmsg_send_sonar_front( uint16_t l, uint16_t cl, uint16_t rl, uint16_t r );
+bool canmsg_send_sonar_front( uint8_t l, uint8_t cl, uint8_t rl, uint8_t r );
 bool canmsg_process_pending();
 
 // ----------------------------------------------------------------------------------------
--- a/main/robots/odr-sonar-front/sonar.cpp	Sat Jan 12 15:21:52 2013 -0800
+++ b/main/robots/odr-sonar-front/sonar.cpp	Wed Feb 06 21:45:48 2013 -0800
@@ -1,6 +1,6 @@
 // ----------------------------------------------------------------------------------------
 //
-//  Copyright (C) 2011 Bob Cook
+//  Copyright (C) 2011-2013 Bob Cook
 //    
 //  Bob Cook Development, Robotics Library
 //  http://www.bobcookdev.com/rl/
@@ -53,10 +53,10 @@
 
 volatile uint8_t   g_curr_sensor_index;
 
-volatile uint16_t  g_sensor_left;               // pin PD6
-volatile uint16_t  g_sensor_center_left;        // pin PD5
-volatile uint16_t  g_sensor_center_right;       // pin PB6
-volatile uint16_t  g_sensor_right;              // pin PB7
+volatile uint8_t  g_sensor_left;               // pin PD6
+volatile uint8_t  g_sensor_center_left;        // pin PD5
+volatile uint8_t  g_sensor_center_right;       // pin PB6
+volatile uint8_t  g_sensor_right;              // pin PB7
 
 // ----------------------------------------------------------------------------------------
 
@@ -179,7 +179,7 @@
             // falling edge => end of sample
             uint16_t sample = TCNT1L;
             sample |= static_cast< uint16_t >( TCNT1H ) << 8;
-            g_sensor_center_right = sample;
+            g_sensor_center_right = static_cast< uint8_t >( sample / 291 );
             // disable pin-change interrupt
             PCMSK0 &= ~( 1 << PCINT6 );
         }
@@ -196,7 +196,7 @@
             // falling edge => end of sample
             uint16_t sample = TCNT1L;
             sample |= static_cast< uint16_t >( TCNT1H ) << 8;
-            g_sensor_right = sample;
+            g_sensor_right = static_cast< uint8_t >( sample / 300 );
             // disable pin-change interrupt
             PCMSK0 &= ~( 1 << PCINT7 );
         }
@@ -221,7 +221,7 @@
             // falling edge => end of sample
             uint16_t sample = TCNT1L;
             sample |= static_cast< uint16_t >( TCNT1H ) << 8;
-            g_sensor_left = sample;
+            g_sensor_left = static_cast< uint8_t >( sample / 291 );
             // disable pin-change interrupt
             PCMSK2 &= ~( 1 << PCINT22 );
         }
@@ -238,7 +238,7 @@
             // falling edge => end of sample
             uint16_t sample = TCNT1L;
             sample |= static_cast< uint16_t >( TCNT1H ) << 8;
-            g_sensor_center_left = sample;
+            g_sensor_center_left = static_cast< uint8_t >( sample / 291 );
             // disable pin-change interrupt
             PCMSK2 &= ~( 1 << PCINT21 );
         }