[tuxdroid-svn] r990 - software_suite_v2/middleware/tuxdriver/trunk/src
Status: Beta
Brought to you by:
ks156
From: eFfeM <c2m...@c2...> - 2008-04-20 12:19:08
|
Author: eFfeM Date: 2008-04-20 14:19:11 +0200 (Sun, 20 Apr 2008) New Revision: 990 Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_pong.c Log: cleanup, removed unneeded includes Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_pong.c =================================================================== --- software_suite_v2/middleware/tuxdriver/trunk/src/tux_pong.c 2008-04-20 12:16:51 UTC (rev 989) +++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_pong.c 2008-04-20 12:19:11 UTC (rev 990) @@ -19,14 +19,12 @@ */ #include <math.h> -#include <stdio.h> -#include <string.h> #include "tux_hw_status.h" #include "tux_hw_cmd.h" +#include "tux_pong.h" #include "tux_sw_status.h" #include "tux_usb.h" -#include "tux_pong.h" static unsigned char received_pong = 0; static float average_stack[10]; @@ -41,13 +39,17 @@ stack_insert(float value) { if (value > 100.0) + { value = 100.0; + } average_stack[stack_idx] = value; stack_idx++; if (stack_fill_count < 10) + { stack_fill_count++; + } stack_idx %= 10; } @@ -62,7 +64,9 @@ float average = 0.0; for (i = 0; i < stack_fill_count; i++) + { average += average_stack[i]; + } return (average / (stack_fill_count * 1.0)); } @@ -81,20 +85,23 @@ received_pong++; new_pending = hw_status_table.pong.pongs_pending_number; - if (new_pending <= 190) { + if (new_pending <= 190) + { local_average = received_pong * 10.0; - if (local_average > 10.0) { + if (local_average > 10.0) + { stack_insert(local_average); average = stack_average(); last_average = *(float *)tux_sw_status_get_value(SW_ID_CONNECTION_QUALITY); if (fabs(last_average - average) >= 1.0) + { tux_sw_status_set_value(SW_ID_CONNECTION_QUALITY, - (void *)&average, true); + (void *)&average, true); + } } received_pong = 0; } - } /** @@ -103,13 +110,13 @@ LIBLOCAL void tux_pong_get(void) { - unsigned char frame[TUX_SEND_LENGTH - 1] = {TUX_PONG_PING_CMD, - 200, - 0, 0}; + unsigned char frame[TUX_SEND_LENGTH - 1] = { TUX_PONG_PING_CMD, + 200, 0, 0}; get_count++; - if (get_count >= 40) { + if (get_count >= 40) + { get_count = 0; tux_usb_send_to_tux(frame); } |