From: Yunhee Seo Date: Wed, 25 Sep 2024 04:29:12 +0000 (+0900) Subject: battery: Enhance API description X-Git-Tag: accepted/tizen/unified/20241006.053304~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ae5ac032414a37647b7215c61db11a7ab39d7d6c;p=platform%2Fcore%2Fapi%2Fdevice.git battery: Enhance API description To improve readability and facilitate comprehension, more detailed API descriptions are added. Change-Id: I3a8acde35dc9b8f98aa99750310baef6976642de Signed-off-by: Yunhee Seo --- diff --git a/include/battery-internal.h b/include/battery-internal.h index 2ce0e56..bb36a4d 100644 --- a/include/battery-internal.h +++ b/include/battery-internal.h @@ -49,17 +49,28 @@ struct device_battery_info { }; /** - * @brief Gets the battery status.. + * @brief Gets the current device's battery status from HAL battery module. + * @details Retrieves detailed information about the battery status, including capacity, voltage averages and etc. * @since_tizen 6.0 + * @remarks Ensure that the provided @a info pointer is valid and has enough memory allocated. * @param[out] info battery status information.\n * The current_average is INT_MAX if battery hw does not provide current average.\n * The voltage_average is INT_MAX if battery hw does not provide voltage average. - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device + * @code + * #include + * ... + * struct device_battery_info info; + * int ret = 0; + * ... + * ret = device_battery_get_info(&info); + * ... + * @endcode + * @see device_battery_info */ int device_battery_get_info_direct(struct device_battery_info *info); diff --git a/include/battery.h b/include/battery.h index ca96ac9..c8c03f0 100644 --- a/include/battery.h +++ b/include/battery.h @@ -101,32 +101,51 @@ typedef enum { /** - * @brief Gets the battery charge percentage. + * @brief Gets the current device's battery charge percentage as an interger value. * @details It returns an integer value from @c 0 to @c 100 that indicates remaining battery charge * as a percentage of the maximum level. * @since_tizen 2.3 + * @remarks Ensure that the provided @a percent pointer is valid and has enough memory allocated. * @param[out] percent The remaining battery charge percentage (@c 0 ~ @c 100) - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device + * @code + * #include + * ... + * int percent = 0; + * int ret = 0; + * ... + * ret = device_battery_get_info(&percent); + * ... + * @endcode */ int device_battery_get_percent(int *percent); /** - * @brief Gets the charging state. + * @brief Gets the current device's charging state which the battery is charging. + * @details Checks whether the battery is currently being charged or not. * @since_tizen 2.3 + * @remarks Ensure that the provided @a charging pointer is valid and has enough memory allocated. * @param[out] charging The battery charging state - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device + * @code + * #include + * ... + * bool is_charging = false; + * int ret = 0; + * ... + * ret = device_battery_is_charging(&is_charging); + * ... + * @endcode * @see device_add_callback * @see device_remove_callback * @see #DEVICE_CALLBACK_BATTERY_CHARGING @@ -135,15 +154,25 @@ int device_battery_is_charging(bool *charging); /** - * @brief Gets the battery level status. + * @brief Gets the current device's battery level status as a @a device_battery_level_e. + * @details Retrieves the current battery level status based on remaining battery capacity. * @since_tizen 2.3 + * @remarks Ensure that the provided @a status pointer is valid and has enough memory allocated. * @param[out] status The battery level status - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device + * @code + * #include + * ... + * device_battery_level_e batt_lev_status = DEVICE_BATTERY_LEVEL_EMPTY; + * int ret = 0; + * ... + * ret = device_battery_get_level_status(&batt_lev_status); + * ... + * @endcode * @see device_battery_level_e * @see device_add_callback * @see device_remove_callback @@ -153,58 +182,102 @@ int device_battery_get_level_status(device_battery_level_e *status); /** - * @brief Gets the battery health information. + * @brief Gets the current device's battery health information as a @a device_battery_health_e. + * @details Retrieves the current battery health status information (e.g., good, overheat, dead, etc). * @since_tizen 3.0 + * @remarks Ensure that the provided @a health pointer is valid and has enough memory allocated. * @param[out] health The battery health information - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device + * @code + * #include + * ... + * device_battery_health_e batt_health = DEVICE_BATTERY_HEALTH_GOOD; + * int ret = 0; + * ... + * ret = device_battery_get_health(&batt_health); + * ... + * @endcode + * @see device_battery_health_e */ int device_battery_get_health(device_battery_health_e *health); /** - * @brief Gets the battery power source information. + * @brief Gets the current device's power source information from the battery. + * @details Retrieves the current battery power source information (e.g., ac, usb, etc). * @since_tizen 3.0 + * @remarks Ensure that the provided @a source pointer is valid and has enough memory allocated. * @param[out] source The battery power source information - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device + * @code + * #include + * ... + * device_battery_power_source_e batt_power_src = DEVICE_BATTERY_POWER_SOURCE_NONE; + * int ret = 0; + * ... + * ret = device_battery_get_power_source(&batt_power_src); + * ... + * @endcode + * @see device_battery_power_source_e */ int device_battery_get_power_source(device_battery_power_source_e *source); /** - * @brief Gets the battery properties. + * @brief Gets the current device's specified battery property as an interger value. + * @details Retrieves the current battery property information (e.g., capacity, current_average, temperature, etc). * @since_tizen 3.0 + * @remarks Ensure that the provided @a value pointer is valid and has enough memory allocated. * @param[in] property The property type * @param[out] value The battery information for the property given - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device + * @code + * #include + * ... + * int value = 0; + * int ret = 0; + * ... + * ret = device_battery_get_property(DEVICE_BATTERY_PROPERTY_CAPACITY, &value); + * ... + * @endcode + * @see device_battery_property_e */ int device_battery_get_property(device_battery_property_e property, int *value); /** - * @brief Gets the battery status information. + * @brief Gets the current device's battery status according to the degree of charge. + * @details Retrieves the current battery status information (e.g., charging, discharging, full, etc). * @since_tizen 3.0 + * @remarks Ensure that the provided @a status pointer is valid and has enough memory allocated. * @param[out] status The battery status information - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #DEVICE_ERROR_NONE Successful * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device + * @code + * #include + * ... + * device_battery_status_e batt_status = DEVICE_BATTERY_STATUS_CHARGING; + * int ret = 0; + * ... + * ret = device_battery_get_property(&batt_status); + * ... + * @endcode + * @see device_battery_status_e */ int device_battery_get_status(device_battery_status_e *status);