[tuxdroid-svn] r870 - in daemon/trunk: . libs
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2008-01-23 18:17:18
|
Author: Paul_R Date: 2008-01-23 19:17:10 +0100 (Wed, 23 Jan 2008) New Revision: 870 Modified: daemon/trunk/libs/USBDaemon_status_table.c daemon/trunk/status.h Log: * Added a new function to control the LEDs status. With the fading functions, the port isn't a good indication. Now, the LEDs are on if the intensity is greater than 0x20. Else, they're off. Modified: daemon/trunk/libs/USBDaemon_status_table.c =================================================================== --- daemon/trunk/libs/USBDaemon_status_table.c 2008-01-23 15:28:39 UTC (rev 869) +++ daemon/trunk/libs/USBDaemon_status_table.c 2008-01-23 18:17:10 UTC (rev 870) @@ -275,6 +275,50 @@ tcp_server_send_raw(tcp_frame); } +static void leds_status_changed(uint8_t left_led, uint8_t right_led) +{ + //XXX find a better way to send the LEDs status + tcp_frame_t tcp_frame; + + tcp_frame_zero(&tcp_frame); + + tcp_frame[0] = SOURCE_TUX; + tcp_frame[1] = SS_DEFAULT; + tcp_frame[2] = DATA_TP_RSP; + tcp_frame[3] = SUBDATA_TP_STATUS; + + if ((left_led < 0x20) && (tux_status.led.left.on) + && tux_status.led.mask == false) + { + tux_status.led.left.on = false; + tcp_frame[4] = DATA_STATUS_LED_LEFT_INTENSITY; + tcp_frame[5] = tux_status.led.left.on; + tcp_server_send_raw(tcp_frame); + } + else if (tux_status.led.left.on == false) + { + tux_status.led.left.on = true; + tcp_frame[4] = DATA_STATUS_LED_LEFT_INTENSITY; + tcp_frame[5] = tux_status.led.left.on; + tcp_server_send_raw(tcp_frame); + } + + if ((right_led < 0x20) && (tux_status.led.right.on) + && tux_status.led.mask == false) + { + tux_status.led.right.on = false; + tcp_frame[4] = DATA_STATUS_LED_RIGHT_INTENSITY; + tcp_frame[5] = tux_status.led.right.on; + tcp_server_send_raw(tcp_frame); + } + else if (tux_status.led.right.on == false) + { + tux_status.led.right.on = true; + tcp_frame[4] = DATA_STATUS_LED_RIGHT_INTENSITY; + tcp_frame[5] = tux_status.led.right.on; + tcp_server_send_raw(tcp_frame); + } +} /* TODO Add functions to get the average battery voltage and status */ static void battery_changed(unsigned int const level, unsigned int const loaded) @@ -716,6 +760,7 @@ case STATUS_LED_CMD: update_leds(&new_status[1]); + leds_status_changed(new_status[1], new_status[2]); break; case PONG_CMD: Modified: daemon/trunk/status.h =================================================================== --- daemon/trunk/status.h 2008-01-23 15:28:39 UTC (rev 869) +++ daemon/trunk/status.h 2008-01-23 18:17:10 UTC (rev 870) @@ -185,6 +185,7 @@ int intensity; /**< Intensity of the led, from 0 (off) to 255 (on). */ bool fading; /**< Set when a fading effect is ongoing. */ bool pulsing; /**< Set when a pulsing effect is ongoing. */ + bool on; } left, right; /**< Indvidual LED status. */ bool mask; /**< When masked, the LEDs are not lit even though the intensity is non zero. The mask is used to turn off |