📄 battdrvrutility.cpp
字号:
//------------------------------------------------------------------------------
//
// Copyright (C) 2005, Motorola Inc. All Rights Reserved
//
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
// File: battdrvrUtility.cpp
//
// Provides the utility function for battdrvr
//
//------------------------------------------------------------------------------
#include <windows.h>
#include <stdlib.h>
#include "battdrvrUtility.h"
//-----------------------------------------------------------------------------
// External Functions
//-----------------------------------------------------------------------------
// External Variables
//-----------------------------------------------------------------------------
// Defines
#define C_S_TO_MS 1000 // convert factor from sec to milli sec
#define C_A_TO_MA 1000 // convert factor from A to mA
#define C_BASE 100 // base factor to convert peukert number and charge efficiency
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------
// Local Variables
//-----------------------------------------------------------------------------
// Local Functions
//------------------------------------------------------------------------------
//
// Function: CalChargingCapacityChange
//
// This function returns the change of the batt capacity during charging based on battery charging
// equation: delta_capacity = current * e * t;
//
// Parameters:
// current
// [in] current flow inside the battery
// e
// [in] charge efficiency for the battery
// t
// [in] duration of the charging
//
// Returns:
// DWORD
//
//------------------------------------------------------------------------------
DWORD CalChargingCapacityChange(DWORD current, DWORD e, DWORD t)
{
return (DWORD)(current *e/C_BASE* t/C_S_TO_MS);
}
//------------------------------------------------------------------------------
//
// Function: CalDischargingCapacityChange
//
// This function returns the change of the batt capacity during discharging based on peukert's
// equation: delta_capacity = (current ^p) * t
//
// Parameters:
// current
// [in] current flow inside the battery
// p
// [in] peukert number for the battery
// t
// [in] duration of the charging
//
// Returns:
// DWORD
//
//------------------------------------------------------------------------------
DWORD CalDischargingCapacityChange(DWORD current, DWORD p, DWORD t)
{
return (DWORD)(pow((double)current/C_A_TO_MA, (double)p/C_BASE)*C_A_TO_MA*t/C_S_TO_MS);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -