📄 mmicharging.c
字号:
/*******************************************************************************
CONDAT (UK)
********************************************************************************
This software product is the property of Condat (UK) Ltd and may not be
disclosed to any third party without the express permission of the owner.
********************************************************************************
$Project name: Basic MMI
$Project code: BMI (6349)
$Module: Charging
$File: Mmicharging.c
$Revision: 1.0
$Author: huangxl
$Date: 26/08/02
********************************************************************************
Description:
********************************************************************************
$History: MmiSounds.c
data: modifier
26/08/02 hxl add for charger
27/08/02 hxl changed for charger
$End
*******************************************************************************/
/*******************************************************************************
Include Files
*******************************************************************************/
#define ENTITY_MFW
/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif
#include "mfw_sys.h"
#include "p_sim.h"
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_edt.h"
#include "mfw_lng.h"
#include "mfw_tim.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_phb.h"
#include "mfw_cm.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
#include "mfw_sat.h"
#include "mfw_phb.h"
#include "ksd.h"
#include "psa.h"
#include "mfw_sms.h"
#include "mfw_cphs.h"
#include "mfw_sat.h"
#include "dspl.h"
#include "MmiMmi.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiLists.h"
#include "MmiIdle.h"
#include "MmiSoftkeys.h"
#include "MmiIcons.h"
#include "MmiSounds.h"
#include "MmiMenu.h"
#include "MmiMain.h"
#include "MmiStart.h"
#include "MmiPins.h"
#include "MmiSettings.h"
#include "MmiVoiceMemo.h"
#include "mfw_ffs.h"
#include "MmiTimers.h"
#include "Mmibookutils.h"
#include "Mmibookshared.h"
#include "Rtc_api.h"
#include "cus_aci.h"
#include "p_sim.h"
#include "pwr.h"
#include "Audio.h"
#include "Mmicharging.h"
#include "mmiouteridle.h"
#include "mmiiconresource.h"
//#define TDTRACE 1
#include "mmiutilapi.h"
extern int g_switchon;
extern UINT32 driverFlag;
UINT8 currenticon=0;
UINT8 oldChargeIcon = 0;
extern int NotCharingMode; /* 2004/07/05 sunsj modify */
#define CLEAR_BOTTOM_ZONE dspl_Clear( KEY_AREA );
#define TIMER_CHARGING 2000 //Polling timer for charging window
T_MFW_HND lowVoltageWin = NULL;
typedef struct
{
/* administrative data */
T_MMI_CONTROL mmi_control;
T_MFW_HND win;
T_MFW_HND parent_win;
T_MFW_HND kbd;
T_MFW_HND tim;
} t_ChargeWin;
typedef enum
{
ChargeWin_INIT,
ChargeWin_DESTROY
} tChargeWinEvents;
T_MFW_HND g_ChargingWin = NULL;
extern pwr_Status_Type pwr_Status;
extern UBYTE BlinkBatPicnum;
extern UBYTE CurrentBatPicNum;
extern UBYTE OlderCurrentBatPicNum;
extern int AutoPowerOn();
UBYTE ChargeOffset=0;
bat_voltage bat_voltage_info;
static UBYTE IsBlinktimerRun=0;
static UBYTE lcdindex=0;
static T_MFW_HND ChargeWinCreate( T_MFW_HND parent_window );
static void ChargeWinDialog( T_MFW_HND win, USHORT event, SHORT value, void *parameter );
static void ChargeWinDestroy( MfwHnd window );
static int ChargeWinWindowCB( MfwEvt e, MfwWin *w );
void SwitchOnFromChargingWin(void);
void DisplayChargingWordInfo(int i);
static int ChargeWinKbdCB( MfwEvt e, MfwKbd *k );
//void ChargeWinUpdate(void);
static int ChargeWin_tim_cb( MfwEvt e, MfwTim *tc );
void SetChargingIcon( U8 BatteryCount);
static CARKITSTATE GetCarkitState(void);
static void chargerbatEvent(void);
extern void GetBatPicnum(void);
void SetOffChargingIcon( U8 BatteryCount);
//void dialog_drawPopIcon_sub(POP_TYPE type);//2004-04-01 Sunny add
/*2003/12/23,talcon add*/
extern U8 isLcdOff();
extern void outeridleExec (int reason,void* para);
//#define TDTRACE 1
#include "mmiutilapi.h"
extern MfwHnd idle_get_edt_window (void);//2004-04-12 Sunny add
void ChargeWin(void )
{
T_MFW_HND win; /* our window */
T_MFW_HND parentwin = mfwParent(mfwHeader());
//LCD_OFF();
lcdindex=0;
BlinkBatPicnum=CurrentBatPicNum; //zym added 2002,10,10 for charging display problem
win = ChargeWinCreate(parentwin) ;
if( win NEQ NULL )
{
g_ChargingWin = win;
SEND_EVENT( win, ChargeWin_INIT, 0, 0 );
}
}
static T_MFW_HND ChargeWinCreate( T_MFW_HND parent_window )
{
T_MFW_WIN *win_data;
t_ChargeWin *data;
driverFlag |= 0x02 ;
/* allocate memory for our control block
*/
if( ( data = (t_ChargeWin *) ALLOC_MEMORY( sizeof( t_ChargeWin ) ) ) == NULL )
return NULL;
/* Create the window if we can
*/
if( ( data->win = win_create( parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB) ChargeWinWindowCB ) ) == NULL )
{
FREE_MEMORY( (void *)data, sizeof( t_ChargeWin ) );
return NULL;
}
/* Okay, we have created the control block and the window, so
we now need to configure the dialog and data pointers
*/
data->mmi_control.dialog = (T_DIALOG_FUNC) ChargeWinDialog;
data->mmi_control.data = data;
win_data = ((T_MFW_HDR *)data->win)->data;
win_data->user = (void *) data;
data->parent_win = parent_window;
/* create keyboards and menus for our window
*/
data->kbd = kbdCreate( data->win, KEY_ALL , (MfwCb) ChargeWinKbdCB );
data->tim = timCreate(data->win, TIMER_CHARGING, (MfwCb) ChargeWin_tim_cb);
// 开机亮LCD
LedLightnessAdjust(200); // MI18800000446 WYJ
timStart(gtVibator);
//Start the timer for charging
timStart(data->tim);
IsBlinktimerRun=1;
/* And return the handle of the newly created window
*/
return data->win;
}
static void ChargeWinDialog( T_MFW_HND win, USHORT event, SHORT value, void *parameter )
{
T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
t_ChargeWin *data = (t_ChargeWin *) win_data->user;
/* Handle the input event, ew only deal with initialise and
destroy of the window in here
*/
switch( event )
{
case ChargeWin_INIT:
{
/* Initialise the input window
*/
/* show the window
*/
winShow( data->win );
}
break;
case ChargeWin_DESTROY:
{
/* destroy the input window
*/
ChargeWinDestroy( win );
}
break;
}
}
static void ChargeWinDestroy( MfwHnd window )
{
T_MFW_WIN *win = ((T_MFW_HDR *) window)->data;
t_ChargeWin *data = (t_ChargeWin *) win->user;
driverFlag &= 0xFFFFFFD;
if( data )
{
timDelete(data->tim);/*2003/12/16, wangyan modify*/
winDelete ( data->win );
FREE_MEMORY( (void *)data, sizeof( t_ChargeWin ) );
}
}
static int ChargeWinWindowCB( MfwEvt e, MfwWin *w )
{
t_ChargeWin *data = (t_ChargeWin*) w->user;
/* Handle the visible event, otherwise return MFW_EVENT_PASSED
*/
switch( e )
{
case MfwWinVisible:
dspl_ClearAll();
break;
default:
return MFW_EVENT_REJECTED;
}
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: ChargeWin_tim_cb
$Description: The time out has occured
$Returns: MFW_EVENT_CONSUMED always
$Arguments: e, event, tc timer context
*******************************************************************************/
static int ChargeWin_tim_cb( MfwEvt e, MfwTim *tc )
{
T_MFW_HND win = mfw_parent(mfw_header());
T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
t_ChargeWin *data = (t_ChargeWin *) win_data->user;
T_MFW_HND parentwin=data->parent_win;
UBYTE currenticon=0;
static UBYTE readidx=0;
T_RTC_DATE_TIME rtcTime;//gdy add
RTC_GetDateTime(&rtcTime);
if( ((rtcTime.year+2000)==FFS_flashData.latest_alarm.year)&&(rtcTime.month==FFS_flashData.latest_alarm.month)
&&(rtcTime.day==FFS_flashData.latest_alarm.day)&&(rtcTime.hour==FFS_flashData.latest_alarm.hour)&&
(rtcTime.minute==FFS_flashData.latest_alarm.minute-1) )
{
//AniandSerachon();//gdy add
LCD_ON();
SwitchOnFromChargingWin();
}
if( lcdindex==5 )
{
//LCD_OFF(); MI18800000446 WYJ remove
lcdindex++;
}
else if( lcdindex<5 )
lcdindex++;
if( pwr_Status.charger_plugged==1 )
{//charger in still
if( pwr_Status.charging_state == 0 )
{
//PROMPT(28, 48 ,0,TxtChargComplete);
DisplayChargingWordInfo(TxtChargComplete);
SetOffChargingIcon( 4 );
/* 2004/07/05 sunsj remove */
//DisplayOuterIdleCharge(4);
//glowing,2004-06-16, modify
#ifdef _M188_
pwr_send_charge_stop_event();
#endif
timStart(data->tim);
}
else
{// if((pwr_Status.charging_state == 1)||(pwr_Status.charging_state == 2)||(pwr_Status.charging_state == 100)){ ///need modify 10/23
currenticon=BlinkBatPicnum;
//PROMPT(28,48,0,TxtCharging);
DisplayChargingWordInfo(TxtCharging);
// if(currenticon>0)
if( currenticon==4 )
currenticon-=1;
currenticon = 0;//2004-03-21 Sunny add.
OlderCurrentBatPicNum = currenticon +ChargeOffset;//2004-03-21 Sunny add.
SetOffChargingIcon( OlderCurrentBatPicNum );
/* 2004/07/05 sunsj remove */
//DisplayOuterIdleCharge(OlderCurrentBatPicNum);
//if(((currenticon +ChargeOffset)==4)&&(bat_voltage_info.batchanged))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -