]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
eb_vidle: Use robot_switches message
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 29 Apr 2010 21:51:23 +0000 (23:51 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 29 Apr 2010 21:51:23 +0000 (23:51 +0200)
src/common/can_ids.h
src/eb_vidle/main.c

index fdcf1b7cdc828a7d9acf2d4d462f51af1d156e55..0b4440d376df4e723301e3ab19b26e14c5b5f5dd 100644 (file)
@@ -37,7 +37,8 @@
 
 
 
-#define CAN_BUMPER             to_boa(0x30)
+#define CAN_ROBOT_SWITCHES     to_boa(0x30)
+
 // ids of can-peripherials
 #define CAN_CHELAE to_per(0x32)          /**< BOA->PER @copydetails set_chelae() front view  1st B  left,  2nd B right */ 
 #define CAN_ADC_1 to_boa(0x33)          /* PER->BOA */
@@ -67,7 +68,6 @@
 //#define CAN_ERROR            to_boa(0x48)    // FIXME: (F.J.) rename me, ...
 
 
-#define CAN_ROBOT_SWITCHES     to_boa(0x47)
 #define CAN_VIDLE_STATUS       to_boa(0x48)
 #define CAN_VIDLE_CMD          to_per(0x49)
 
index 8e44b271f42a4772fdbbbe1a5722f2475a2de1f9..7226d5f2d3323e68c7db7209c77b3a64d178a471 100644 (file)
@@ -258,6 +258,7 @@ void blink_led()
 void handle_bumper()
 {
        static uint32_t bumper_time = 0;
+       char sw = 0;
 
        if (timer_msec >= bumper_time + 100)    
        {
@@ -265,22 +266,26 @@ void handle_bumper()
 
                bumper_time = timer_msec;
                
-               tx_msg.id = CAN_BUMPER;
-               tx_msg.dlc = 1;
-               tx_msg.flags = 0;       
                        
                        
                if (IO0PIN & (1<<BUMPER_PIN))
                {    
-                       tx_msg.data[0] = 0;
+                       sw &= ~CAN_SWITCH_BUMPER;
                        deb_led_off(LEDR);
                }
                else
                {
-                       tx_msg.data[0] = 1;
+                       sw |= CAN_SWITCH_BUMPER;
                        deb_led_on(LEDR);
                }
+
+               /* TODO: Put color to the second bit */
                        
+               tx_msg.id = CAN_ROBOT_SWITCHES;
+               tx_msg.dlc = 1;
+               tx_msg.flags = 0;
+               tx_msg.data[0] = sw;
+               
                can_tx_msg(&tx_msg);
        }
 }