Author: remi
Date: 2008-12-01 09:19:01 +0100 (Mon, 01 Dec 2008)
New Revision: 2947
Modified:
software_suite_v2/tuxware/tuxdriver/trunk/src/log.c
software_suite_v2/tuxware/tuxdriver/trunk/src/log.h
software_suite_v2/tuxware/tuxdriver/trunk/src/tux_audio.c
software_suite_v2/tuxware/tuxdriver/trunk/src/tux_audio.h
software_suite_v2/tuxware/tuxdriver/trunk/src/tux_battery.c
software_suite_v2/tuxware/tuxdriver/trunk/src/tux_battery.h
Log:
* added comments and doxygen.
Modified: software_suite_v2/tuxware/tuxdriver/trunk/src/log.c
===================================================================
--- software_suite_v2/tuxware/tuxdriver/trunk/src/log.c 2008-12-01 08:07:28 UTC
(rev 2946)
+++ software_suite_v2/tuxware/tuxdriver/trunk/src/log.c 2008-12-01 08:19:01 UTC
(rev 2947)
@@ -18,6 +18,12 @@
* 02111-1307, USA.
*/
+/**
+ * \file log.c
+ * \brief Logger functions.
+ * \ingroup logger
+ */
+
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
@@ -58,11 +64,9 @@
static bool log_opened;
/**
- * Open the log.
- *
- * /param[in] target Logging target
- *
- * /return true if successfull, false otherwise
+ * \brief Open the log.
+ * \param target Logging target.
+ * \return true if successfull, false otherwise.
*/
bool
log_open(log_target_t target)
@@ -95,7 +99,7 @@
}
/**
- * Close the log.
+ * \brief Close the log.
*/
void
log_close(void)
@@ -118,7 +122,8 @@
}
/**
- *
+ * \brief Write text in the log.
+ * \param text Text to write.
*/
static void
write_log_text(char *text)
@@ -134,9 +139,8 @@
}
/**
- * Set the logging level.
- *
- * /param[in] new_level New logging level
+ * \brief Set the logging level.
+ * \param new_level New logging level.
*/
void
log_set_level(log_level_t new_level)
@@ -146,9 +150,8 @@
}
/**
- * Get the logging level.
- *
- * /return current logging level
+ * \brief Get the logging level.
+ * \return The current logging level
*/
log_level_t
log_get_level(void)
@@ -157,16 +160,16 @@
}
/**
- * Log formatted message at the specified level.
+ * \brief Log formatted message at the specified level.
*
- * /param[in] at_level Level to log the message at
- * /param[in] fmt Message format
- * /param[in] ... Optional message data
+ * \param at_level Level to log the message at.
+ * \param fmt Message format.
+ * \param ... Optional message data.
*
* If the priority of the specifed level is lower than the priority
* of the current logging level, the message is silently dropped.
*
- * /return true if successful, false otherwise
+ * \return true if successful, false otherwise.
*/
bool
log_text(log_level_t at_level, const char *fmt, ...)
Modified: software_suite_v2/tuxware/tuxdriver/trunk/src/log.h
===================================================================
--- software_suite_v2/tuxware/tuxdriver/trunk/src/log.h 2008-12-01 08:07:28 UTC
(rev 2946)
+++ software_suite_v2/tuxware/tuxdriver/trunk/src/log.h 2008-12-01 08:19:01 UTC
(rev 2947)
@@ -1,3 +1,29 @@
+/*
+ * Tux Droid - Log
+ * Copyright (C) 2007 C2ME S.A. <[EMAIL PROTECTED]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+/**
+ * \file log.h
+ * \brief Logger header.
+ * \ingroup logger
+ */
+
#ifndef __LOG_H__
#define __LOG_H__
@@ -3,22 +29,22 @@
#include <stdbool.h>
-/** Logging target */
+/** \brief Logging target. */
typedef enum log_target
{
- LOG_TARGET_TUX,
- LOG_TARGET_SHELL
+ LOG_TARGET_TUX, /**< Target file */
+ LOG_TARGET_SHELL /**< Target shell */
} log_target_t;
extern bool log_open(log_target_t target);
extern void log_close(void);
-/** Logging levels, in increasing priorities */
+/** \brief Logging levels, in increasing priorities */
typedef enum log_level
{
- LOG_LEVEL_DEBUG,
- LOG_LEVEL_INFO,
- LOG_LEVEL_WARNING,
- LOG_LEVEL_ERROR,
- LOG_LEVEL_NONE
+ LOG_LEVEL_DEBUG, /**< Level Debug */
+ LOG_LEVEL_INFO, /**< Level Info */
+ LOG_LEVEL_WARNING, /**< Level Warning */
+ LOG_LEVEL_ERROR, /**< Level Error */
+ LOG_LEVEL_NONE /**< Level None */
} log_level_t;
Modified: software_suite_v2/tuxware/tuxdriver/trunk/src/tux_audio.c
===================================================================
--- software_suite_v2/tuxware/tuxdriver/trunk/src/tux_audio.c 2008-12-01
08:07:28 UTC (rev 2946)
+++ software_suite_v2/tuxware/tuxdriver/trunk/src/tux_audio.c 2008-12-01
08:19:01 UTC (rev 2947)
@@ -18,13 +18,21 @@
* 02111-1307, USA.
*/
+/**
+ * \file tux_audio.c
+ * \brief Audio speaker functions.
+ * \author [EMAIL PROTECTED]
+ * \ingroup audio
+ */
+
#include "tux_audio.h"
#include "tux_hw_cmd.h"
#include "tux_types.h"
#include "tux_usb.h"
/**
- *
+ * \brief Send a command to switch the audio stream to Tuxdroid-Audio channel.
+ * \return The sending success.
*/
LIBLOCAL bool
tux_audio_cmd_channel_general(void)
@@ -34,7 +42,8 @@
}
/**
- *
+ * \brief Send a command to switch the audio stream to Tuxdroid-TTS channel.
+ * \return The sending success.
*/
LIBLOCAL bool
tux_audio_cmd_channel_tts(void)
@@ -44,7 +53,9 @@
}
/**
- *
+ * \brief Send a command to mute/unmute the speaker.
+ * \param value Mute value.
+ * \return The sending success.
*/
LIBLOCAL bool
tux_audio_cmd_mute(bool value)
Modified: software_suite_v2/tuxware/tuxdriver/trunk/src/tux_audio.h
===================================================================
--- software_suite_v2/tuxware/tuxdriver/trunk/src/tux_audio.h 2008-12-01
08:07:28 UTC (rev 2946)
+++ software_suite_v2/tuxware/tuxdriver/trunk/src/tux_audio.h 2008-12-01
08:19:01 UTC (rev 2947)
@@ -18,6 +18,13 @@
* 02111-1307, USA.
*/
+/**
+ * \file tux_audio.h
+ * \brief Audio speaker header.
+ * \author [EMAIL PROTECTED]
+ * \ingroup audio
+ */
+
#ifndef _TUX_AUDIO_H_
#define _TUX_AUDIO_H_
Modified: software_suite_v2/tuxware/tuxdriver/trunk/src/tux_battery.c
===================================================================
--- software_suite_v2/tuxware/tuxdriver/trunk/src/tux_battery.c 2008-12-01
08:07:28 UTC (rev 2946)
+++ software_suite_v2/tuxware/tuxdriver/trunk/src/tux_battery.c 2008-12-01
08:19:01 UTC (rev 2947)
@@ -18,6 +18,13 @@
* 02111-1307, USA.
*/
+/**
+ * \file tux_battery.c
+ * \brief Battery level functions.
+ * \author [EMAIL PROTECTED]
+ * \ingroup power
+ */
+
#include <string.h>
#include "tux_battery.h"
@@ -25,26 +32,29 @@
#include "tux_hw_status.h"
#include "tux_sw_status.h"
+/** \brief Battery states */
typedef enum
{
- FULL,
- HIGH,
- LOW,
- EMPTY
+ FULL, /**< Battery level full */
+ HIGH, /**< Battery level high */
+ LOW, /**< Battery level low */
+ EMPTY /**< Battery level empty */
} battery_state_t;
-/*
- REPORTING_DELTA is the treshold value for changes;
- changes smaller than this value are not reported
- might become a controllable parameter in the future
-*/
+/**
+ * REPORTING_DELTA is the treshold value for changes;
+ * changes smaller than this value are not reported
+ * might become a controllable parameter in the future
+ */
#define REPORTING_DELTA 100
+/** Current battery state */
static battery_state_t battery_state = EMPTY;
+/** Current battery state for event */
static int last_level_for_event = 0;
/**
- * Update the status of the battery voltage.
+ * \brief Update the status of the battery voltage.
*/
LIBLOCAL void
tux_battery_update_level(void)
@@ -54,22 +64,28 @@
char *new_state_str = "";
int delta;
+ /* Get the current battery level from adc and convert it to mV */
adc_value = (hw_status_table.battery.high_level << 8);
adc_value += hw_status_table.battery.low_level;
new_level = adc_value * 7.467;
/* 7.467 = 0.00322 * 2.319 * 1000 no idea where the first two are from
- 1000 is to go to mV
- */
+ * 1000 is to go to mV */
+ /* Get the difference between last and new level */
delta = new_level - last_level_for_event;
+
+ /* If the delta threshold is reached */
if ((delta > REPORTING_DELTA) || (delta < -REPORTING_DELTA))
{
last_level_for_event = new_level;
+
+ /* Update directly the SW_ID_BATTERY_LEVEL status if motors off */
if (!hw_status_table.battery.motors_state)
{
tux_sw_status_set_intvalue(SW_ID_BATTERY_LEVEL, new_level, true);
}
+ /* Battery level full */
if (new_level >= TUX_BATTERY_FULL_VALUE)
{
new_state_str = STRING_VALUE_FULL;
@@ -77,6 +93,7 @@
}
else
{
+ /* Battery level high */
if ((new_level < TUX_BATTERY_FULL_VALUE) &&
(new_level >= TUX_BATTERY_HIGH_VALUE))
{
@@ -85,6 +102,7 @@
}
else
{
+ /* Battery level low */
if ((new_level < TUX_BATTERY_HIGH_VALUE) &&
(new_level >= TUX_BATTERY_LOW_VALUE))
{
@@ -93,16 +111,18 @@
}
else
{
+ /* Battery level empty */
new_state_str = STRING_VALUE_EMPTY;
battery_state = EMPTY;
}
}
}
-
+ /* Update the SW_ID_BATTERY_STATE status */
tux_sw_status_set_strvalue(SW_ID_BATTERY_STATE, new_state_str, true);
}
else
{
+ /* Update the SW_ID_BATTERY_LEVEL status */
tux_sw_status_set_intvalue(SW_ID_BATTERY_LEVEL, new_level, false);
}
}
Modified: software_suite_v2/tuxware/tuxdriver/trunk/src/tux_battery.h
===================================================================
--- software_suite_v2/tuxware/tuxdriver/trunk/src/tux_battery.h 2008-12-01
08:07:28 UTC (rev 2946)
+++ software_suite_v2/tuxware/tuxdriver/trunk/src/tux_battery.h 2008-12-01
08:19:01 UTC (rev 2947)
@@ -18,14 +18,29 @@
* 02111-1307, USA.
*/
+/**
+ * \file tux_battery.c
+ * \brief Battery level header.
+ * \author [EMAIL PROTECTED]
+ * \ingroup power
+ */
+
#ifndef _TUX_BATTERY_H_
#define _TUX_BATTERY_H_
-/* values are in mV */
+/**
+ * \name Battery level thresholds in mV.
+ * @{
+ */
+/** Battery level threshold FULL */
#define TUX_BATTERY_FULL_VALUE 6000
+/** Battery level threshold HIGH */
#define TUX_BATTERY_HIGH_VALUE 5400
+/** Battery level threshold LOW */
#define TUX_BATTERY_LOW_VALUE 4500
+/** Battery level threshold EMPTY */
#define TUX_BATTERY_EMPTY_VALUE 0000
+/** @} */
extern void tux_battery_update_level(void);
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn