[tuxdroid-svn] r586 - daemon/trunk/libs
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-10-08 14:53:59
|
Author: jaguarondi Date: 2007-10-08 16:53:59 +0200 (Mon, 08 Oct 2007) New Revision: 586 Modified: daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_status_table.c daemon/trunk/libs/USBDaemon_status_table.h Log: * Added battery level status. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-10-08 13:47:19 UTC (rev 585) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-10-08 14:53:59 UTC (rev 586) @@ -611,6 +611,11 @@ result[1] = sensors2.light_level / 256; result[2] = sensors2.light_level % 256; break; + case DATA_STATUS_BATTERY: + result[1] = battery.level / 256; + result[2] = battery.level % 256; + result[3] = battery.status; + break; case DATA_STATUS_EYES_POSITION_COUNTER: result[1] = position1.eyes_position.Byte; break; Modified: daemon/trunk/libs/USBDaemon_status_table.c =================================================================== --- daemon/trunk/libs/USBDaemon_status_table.c 2007-10-08 13:47:19 UTC (rev 585) +++ daemon/trunk/libs/USBDaemon_status_table.c 2007-10-08 14:53:59 UTC (rev 586) @@ -225,12 +225,34 @@ tcp_frame[4] = DATA_STATUS_LIGHT_LEVEL; sensors2.light_level = light_level; - + tcp_frame[5] = light_level / 256; tcp_frame[6] = light_level % 256; tcp_server_send_raw(tcp_frame); } +static void battery_changed(int level, int 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; + + tcp_frame[4] = DATA_STATUS_BATTERY; + + battery.level = level; + battery.status = status; + + tcp_frame[5] = level / 256; + tcp_frame[6] = level % 256; + tcp_frame[7] = status; + tcp_server_send_raw(tcp_frame); +} + static void pong_event(unsigned char pong_number, unsigned char pong_received) { tcp_frame_t tcp_frame; @@ -532,7 +554,7 @@ /* The answer from the usb_tux_connection command has been received */ connection_status.usb_request_f = false; connection_status.tux_id = (new_status[1] << 8) + new_status[2]; - log_debug("id retunred by tux: %i (0x%.2x%.2x)", + log_debug("id returned by tux: %i (0x%.2x%.2x)", connection_status.tux_id, new_status[1], new_status[2]); break; case STATUS_PORTS_CMD: @@ -563,6 +585,16 @@ } break; + case STATUS_BATTERY_CMD: + { + int level; + int status; + level = (new_status[1] << 8) + new_status[2]; + status = new_status[3]; + battery_changed(level, status); + } + break; + case STATUS_POSITION1_CMD: if (position1.eyes_position.Byte != new_status[1] || position1.mouth_position.Byte != new_status[2] Modified: daemon/trunk/libs/USBDaemon_status_table.h =================================================================== --- daemon/trunk/libs/USBDaemon_status_table.h 2007-10-08 13:47:19 UTC (rev 585) +++ daemon/trunk/libs/USBDaemon_status_table.h 2007-10-08 14:53:59 UTC (rev 586) @@ -175,6 +175,7 @@ #define DATA_STATUS_IR_CODE 0x22 #define DATA_STATUS_SOUND_COUNT 0x23 #define DATA_STATUS_PONG 0x24 +#define DATA_STATUS_BATTERY 0x25 /* tux connection commands available on the usb dongle */ typedef enum @@ -242,6 +243,13 @@ } sensors2; struct { + _PORT_BYTE_ level_high; + _PORT_BYTE_ level_low; + int status; + int level; +} battery; +struct +{ _PORT_BYTE_ eyes_position; _PORT_BYTE_ mouth_position; _PORT_BYTE_ wings_position; |