[tuxdroid-svn] r996 - software_suite_v2/middleware/tuxdriver/trunk/src
Status: Beta
Brought to you by:
ks156
From: eFfeM <c2m...@c2...> - 2008-04-20 19:12:42
|
Author: eFfeM Date: 2008-04-20 21:12:47 +0200 (Sun, 20 Apr 2008) New Revision: 996 Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_user_inputs.c Log: curlies Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_user_inputs.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_user_inputs.c 2008-04-20 19:08:48 UTC (rev 995) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_user_inputs.c 2008-04-20 19:12:47 UTC (rev 996) @@ -21,11 +21,11 @@ #include <stdio.h> #include <string.h> +#include "tux_hw_cmd.h" #include "tux_hw_status.h" #include "tux_sw_status.h" -#include "tux_hw_cmd.h" +#include "tux_usb.h" #include "tux_user_inputs.h" -#include "tux_usb.h" static bool ir_received = false; static bool ir_has_not_yet_been_used = true; @@ -58,8 +58,10 @@ old_state = *(unsigned char *)tux_sw_status_get_value(SW_ID_LEFT_WING_BUTTON); if (new_state != old_state) + { tux_sw_status_set_value(SW_ID_LEFT_WING_BUTTON, (void *)&new_state, true); + } } /** @@ -74,8 +76,10 @@ old_state = *(unsigned char *)tux_sw_status_get_value(SW_ID_RIGHT_WING_BUTTON); if (new_state != old_state) + { tux_sw_status_set_value(SW_ID_RIGHT_WING_BUTTON, (void *)&new_state, true); + } } /** @@ -90,7 +94,9 @@ old_state = *(unsigned char *)tux_sw_status_get_value(SW_ID_HEAD_BUTTON); if (new_state != old_state) + { tux_sw_status_set_value(SW_ID_HEAD_BUTTON, (void *)&new_state, true); + } } /** @@ -203,10 +209,13 @@ { char *code_str = ""; - if (rc5_on_receiving) { - if (!ir_received) { + if (rc5_on_receiving) + { + if (!ir_received) + { rc5_timeout_counter++; - if (rc5_timeout_counter >= RC5_TIMEOUT) { + if (rc5_timeout_counter >= RC5_TIMEOUT) + { /* remote button is released */ code_str = RC5_code_to_str(K_DUMMY_RELEASE); tux_sw_status_set_value(SW_ID_REMOTE_BUTTON, @@ -215,24 +224,34 @@ rc5_timeout_counter = 0; rc5_on_receiving = false; } - } else + } + else + { rc5_timeout_counter = 0; + } - if (rc5_last_toggle != hw_status_table.ir.rc5_code.bits.toggle) { + if (rc5_last_toggle != hw_status_table.ir.rc5_code.bits.toggle) + { /* remote button is released */ code_str = RC5_code_to_str(K_DUMMY_RELEASE); tux_sw_status_set_value(SW_ID_REMOTE_BUTTON, (void *)code_str, true); /* remote button is pressed */ - if (hw_status_table.ir.rc5_code.bits.command <= LAST_VALID_K) { + if (hw_status_table.ir.rc5_code.bits.command <= LAST_VALID_K) + { code_str = RC5_code_to_str(hw_status_table.ir.rc5_code.bits.command); tux_sw_status_set_value(SW_ID_REMOTE_BUTTON, (void *)code_str, true); - } else + } + else + { rc5_on_receiving = 0; + } } - } else { /* not in receiving */ + } + else + { /* not in receiving */ if ((ir_received) && ((rc5_last_toggle != hw_status_table.ir.rc5_code.bits.toggle) || ir_has_not_yet_been_used)) @@ -242,12 +261,16 @@ rc5_on_receiving = true; /* remote button is pressed */ - if (hw_status_table.ir.rc5_code.bits.command <= LAST_VALID_K) { + if (hw_status_table.ir.rc5_code.bits.command <= LAST_VALID_K) + { code_str = RC5_code_to_str(hw_status_table.ir.rc5_code.bits.command); tux_sw_status_set_value(SW_ID_REMOTE_BUTTON, (void *)code_str, true); - } else + } + else + { rc5_on_receiving = false; + } } } @@ -276,22 +299,40 @@ old_state = (char *)tux_sw_status_get_value(SW_ID_CHARGER_STATE); - if (!hw_status_table.sensors1.sensors.bits.power_plug_insertion_switch) { + if (!hw_status_table.sensors1.sensors.bits.power_plug_insertion_switch) + { new_state = STRING_VALUE_UNPLUGGED; - } else if (hw_status_table.sensors1.sensors.bits.charger_led_status) { - new_state = STRING_VALUE_CHARGING; - } else { - if (hw_status_table.ports.portb.bits.charger_inhibit_signal) { - new_state = STRING_VALUE_INHIBITED; - } else - if (strcmp(STRING_VALUE_UNPLUGGED, old_state)) - new_state = STRING_VALUE_TRICKLE; - else - new_state = STRING_VALUE_UNPLUGGED; } + else + { + if (hw_status_table.sensors1.sensors.bits.charger_led_status) + { + new_state = STRING_VALUE_CHARGING; + } + else + { + if (hw_status_table.ports.portb.bits.charger_inhibit_signal) + { + new_state = STRING_VALUE_INHIBITED; + } + else + { + if (strcmp(STRING_VALUE_UNPLUGGED, old_state)) + { + new_state = STRING_VALUE_TRICKLE; + } + else + { + new_state = STRING_VALUE_UNPLUGGED; + } + } + } + } if (strcmp(new_state, old_state)) + { tux_sw_status_set_value(SW_ID_CHARGER_STATE, (void *)new_state, true); + } } /** @@ -331,7 +372,9 @@ ret &= str_to_uint8(command, &cmd); if (!ret) + { return false; + } frame[1] = add; frame[2] = cmd; |