changeset 69:77321341946c

first-pass implementation of UI to FCHG connection
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 23 Oct 2020 03:39:22 +0000
parents e9a4b683f697
children 032a561fab2b
files src/ui/bmi/mmiIcons.c src/ui/bmi/mmiIdle.c src/ui/bmi/mmiMain.c src/ui/bmi/mmiMain.h src/ui/mfw/mfw_mme.c src/ui/mfw/mfw_mme.h
diffstat 6 files changed, 77 insertions(+), 87 deletions(-) [+]
line wrap: on
line diff
--- a/src/ui/bmi/mmiIcons.c	Fri Oct 23 01:59:58 2020 +0000
+++ b/src/ui/bmi/mmiIcons.c	Fri Oct 23 03:39:22 2020 +0000
@@ -2391,8 +2391,7 @@
     if (batterystatus >= iconBattMax)
         return 0;
 
-  if( (globalMobileMode & (GlobalMobileOn|GlobalCharging)) AND
-       (globalBatteryMode NEQ GlobalBatteryFull) )
+  if (globalBatteryMode == BATT_STATE_CHARGING)
   {
     if ( idleIsFocussed() AND battery_charging_animate)
     {
@@ -2434,8 +2433,7 @@
 int BattChargeEventTim( MfwEvt e, MfwTim *tc )
 {
   int i;
-  if( (globalMobileMode & (GlobalMobileOn|GlobalCharging)) AND
-       (globalBatteryMode NEQ GlobalBatteryFull) )
+  if (globalBatteryMode == BATT_STATE_CHARGING)
   {
     if (idleIsFocussed() AND battery_charging_animate)
     {
--- a/src/ui/bmi/mmiIdle.c	Fri Oct 23 01:59:58 2020 +0000
+++ b/src/ui/bmi/mmiIdle.c	Fri Oct 23 03:39:22 2020 +0000
@@ -1955,25 +1955,17 @@
         switch (idle_data.nm_status)
         {
             case NETWORK_FULL_SERVICE :
-                if (globalMobileMode == (GlobalMobileOn|GlobalCharging))
+                if (globalBatteryMode == BATT_STATE_CHARGING_COMPLETE)
+                {
+                    idle_displayData(IDLE_CHARGING_MODE,TxtChargComplete,NULL);
+                }
+                else if (globalBatteryMode == BATT_STATE_CHARGING)
                 {
-                    if(globalBatteryMode == GlobalBatteryFull)
-                    {
-                        idle_displayData(IDLE_CHARGING_MODE,TxtChargComplete,NULL);
-
-                    }
-                    else
-                    {
-                        idle_displayData(IDLE_CHARGING_MODE,TxtCharging,NULL);
-                    }
-                    break;
+                    idle_displayData(IDLE_CHARGING_MODE,TxtCharging,NULL);
                 }
-                else
+                else if (DivertStatus == MFW_CFLAG_SET)
                 {
-                    if (DivertStatus == MFW_CFLAG_SET)
-                    {
-                        idle_displayData(IDLE_CHARGING_MODE,TxtCallDivert,NULL);
-                    }
+                    idle_displayData(IDLE_CHARGING_MODE,TxtCallDivert,NULL);
                 }
                 /*NM p032
                 set the flag when the TEST SIM is inserted*/
--- a/src/ui/bmi/mmiMain.c	Fri Oct 23 01:59:58 2020 +0000
+++ b/src/ui/bmi/mmiMain.c	Fri Oct 23 03:39:22 2020 +0000
@@ -288,7 +288,9 @@
     Solution     : As part of the implementation, type of GlobalIconStatus is changed from U16 to U32 as number of
     bits in the variable is not sufficient to store details about all the icons*/
 U32 GlobalIconStatus;
+#if 0	/* removed in FreeCalypso */
 UBYTE globalMobileMode;
+#endif
 int MmiModule;
 
 // ADDED BY RAVI - 28-11-2005
@@ -313,8 +315,6 @@
 #endif
 
 
-void globalFlashBattery (void);
-
 UBYTE globalBatteryPicNumber;
 UBYTE globalSignalPicNumber;
 
@@ -1172,48 +1172,23 @@
 	TRACE_EVENT_P1("MfwMmeBaState:mc->value: %d", mc->value);
 	switch(value)
 	{
-//x0pleela 10 Apr, 2006 ER: OMAPS00075178
-	case PWR_CHG_PLUG:
+	case BATT_EVENT_CHARGER_PLUG:
 		TRACE_EVENT("Mme Event:PWR_CHG_PLUG");
 		charging_start_info();
 		break;
-	/* External Power Plugged Off */
-    //case 0: //x0pleela 10 Apr, 2006 
-	case PWR_CHG_UNPLUG://x0pleela 10 Apr, 2006 ER: OMAPS00075178
-      		TRACE_EVENT("Mme Event:Discharging");
-	    	globalMobileMode = globalMobileMode & (~GlobalCharging);
-	    	globalMobileMode = globalMobileMode & (~GlobalBatteryPower);
-		globalBatteryMode = GlobalBatteryGreater5; //x0pleela 10 Apr, 2006
-		timStop(battery_charging_animate ); //x0pleela 11 Apr, 2006
-		idleEvent(IdleUpdate); //x0pleela 10 Apr, 2006
+	case BATT_STATE_NO_CHARGING:
+	case BATT_STATE_CHARGING:
+	case BATT_STATE_CHARGING_COMPLETE:
+		TRACE_EVENT_P1("MfwMmeBaState change to %d", value);
+		globalBatteryMode = value;
+		if (value != BATT_STATE_CHARGING)
+			timStop(battery_charging_animate);
+		idleEvent(IdleUpdate);
+		break;
+	default:
+		break;
+	}
 	break;
-
-	/* Mme Event: External Power Connected or End of Charge */
- //      case 1: //x0pleela 10 Apr, 2006 
-	case PWR_CHG_STOP: //x0pleela 10 Apr, 2006 ER: OMAPS00075178
-      		TRACE_EVENT("Mme Event:GlobalBatteryPower");
-//		globalMobileMode = globalMobileMode & (~GlobalCharging);
-	    	globalMobileMode = (globalMobileMode | GlobalBatteryPower);
-	    /* indicate that the battery is full*/
-	  	globalBatteryMode = GlobalBatteryFull;
-		timStop(battery_charging_animate ); //x0pleela 11 Apr, 2006
-		idleEvent(IdleUpdate); //x0pleela 10 Apr, 2006
-	 	 TRACE_EVENT("globalBatteryPicNumber = GlobalBatteryFull");
-	break;
-	/* Mme Event: Start of Charge */
-//	case 2: //x0pleela 10 Apr, 2006
-	case PWR_CHG_BEGIN: //x0pleela 10 Apr, 2006 ER: OMAPS00075178
-	    TRACE_EVENT("Mme Event:Charging");	   
-	    globalMobileMode = globalMobileMode & (~GlobalBatteryPower);
-	    globalMobileMode = (globalMobileMode | GlobalCharging);
-		globalBatteryMode = GlobalBatteryGreater5; //x0pleela 10 Apr, 2006
-		idleEvent(IdleUpdate); //x0pleela 10 Apr, 2006
-		//globalFlashBattery (); //x0pleela 10 Apr, 2006 : included to show animation of battery charging
-	break;
-	default:
-	    break;
-    }
-    break;
 //      xpradipg - LOCOSTO-ENH-31895 : 23 June 2005
 #ifdef FF_MMI_AUDIO_PROFILE
 //indicates the events related to the headset
@@ -1599,7 +1574,9 @@
    //---------------start: Mobile OFF-------------------
     TRACE_EVENT("            Mobile OFF");
     /* delete the state of mobile on   */
+#if 0	/* removed in FreeCalypso */
     globalMobileMode = globalMobileMode & (~GlobalMobileOn);
+#endif
 
     deregis = FALSE;
 
@@ -1632,16 +1609,12 @@
 int globalBatteryUpdate (U8 value)
 {
 
-    MmiModuleDel (ModuleBattLow);  /* delete the state */
-
-    globalBatteryMode = GlobalBatteryGreater5;
-
+  MmiModuleDel (ModuleBattLow);  /* delete the state */
 
   switch (value)
   {
     case 0:       /* battery low */
       globalBatteryPicNumber = 0;
-      globalBatteryMode = GlobalBatteryLesser5;
 
       /* is just a global status */
       MmiModuleSet (ModuleBattLow);  /* set the state */
@@ -1668,9 +1641,9 @@
       break;
   }
 
-    idleEvent(IdleUpdate);
-
-    return 0;
+  idleEvent(IdleUpdate);
+
+  return 0;
 }
 
 
@@ -1699,6 +1672,7 @@
 
 
 
+#if 0	/* removed in FreeCalypso */
 /*******************************************************************************
 
  $Function:  globalFlashBattery
@@ -1722,6 +1696,7 @@
     idleEvent(IdleUpdate);
     TRACE_EVENT(" start the timer for Blink ");
 }
+#endif
 
 /* SPR#1428 - SH - New Editor: this is all obsolete with new editor.  Equivalent
  * functionality can be found in AUITextEntry.c */
--- a/src/ui/bmi/mmiMain.h	Fri Oct 23 01:59:58 2020 +0000
+++ b/src/ui/bmi/mmiMain.h	Fri Oct 23 03:39:22 2020 +0000
@@ -223,9 +223,11 @@
 #define SettingsCBDisable         0x80    /* SPR 2470 0x80- disable CB display 0-display CB */
 //extern USHORT settingsStatus;
 
+#if 0	/* removed in FreeCalypso */
 #define GlobalBatteryLesser5     1
 #define GlobalBatteryGreater5    2
 #define GlobalBatteryFull        3
+#endif
 
 extern UBYTE globalBatteryMode; /*  */
 
--- a/src/ui/mfw/mfw_mme.c	Fri Oct 23 01:59:58 2020 +0000
+++ b/src/ui/mfw/mfw_mme.c	Fri Oct 23 03:39:22 2020 +0000
@@ -146,6 +146,7 @@
 #ifdef FF_MMI_USBMS
 #include "usb/usb_api.h"
 #endif
+#include "fchg/fchg_api.h"
 
 //x0pleela 01 Apr, 2007 ER: OMAPS00122561
 #ifdef FF_PHONE_LOCK
@@ -184,7 +185,7 @@
 static int mmeCommand (U32 cmd, void *h);
 
                                         /* driver callbacks         */
-static void pwrCb (drv_SignalID_Type *signal_params);
+static void pwrCb (enum fchg_event);
 static void rxCb (drv_SignalID_Type *signal_params);
 static void rtcCb (drv_SignalID_Type *signal_params);
 
@@ -426,9 +427,9 @@
     hdsPresence = 0;
 
 
-    pwr_Init(pwrCb); //power driver
-    rx_Init(rxCb);   //fieldstrength driver
-    light_Init();    //light emitting driver
+    fchg_register_event_handler(pwrCb);	/* battery driver */
+    rx_Init(rxCb);	//fieldstrength driver
+    light_Init();	//light emitting driver
 //      xpradipg - LOCOSTO-ENH-31895 : 23 June 2005
 #ifdef FF_MMI_AUDIO_PROFILE
     audio_Init(audio_device_config);
@@ -436,8 +437,6 @@
     audio_Init(hdsCb); //audio driver
 #endif
 
-    mmeBattInfo ( 10, 0);
-
     mmeRxInfo(5,0);
 
     /* install prim handler     */
@@ -778,6 +777,7 @@
 
 */
 
+#if 0	/* removed in FreeCalypso */
 void mmeBattInfo ( U8 intervalls, U16 level)
 {
     pwr_DCB_Type pwr_DCB;
@@ -789,6 +789,7 @@
     pwr_DCB.Steps = intervalls;         /* n Steps                  */
     pwr_SetConfig(&pwr_DCB);
 }
+#endif
 
 
 /*
@@ -1042,12 +1043,17 @@
         case MMI_BATTERY_IND:
             level = ((T_MMI_BATTERY_IND *) data)->volt;
             state = ((T_MMI_BATTERY_IND *) data)->temp;
-            if (battLevel != level)
+            if (level != FCHG_BATT_BARS_CHARGING && battLevel != level)
             {
                 battLevel = level;
                 mmeSignal(MfwMmeBattery,level);
             }
-            if (battState != state)
+            /* is it a new state or an event? */
+            if (state >= BATT_EVENT_CHARGER_PLUG)
+            {
+                mmeSignal(MfwMmeBaState,state);
+            }
+            else if (battState != state)
             {
                 battState = state;
                 mmeSignal(MfwMmeBaState,state);
@@ -1187,14 +1193,28 @@
 
 */
 
-static void pwrCb (drv_SignalID_Type *signal_params)
+static void pwrCb (enum fchg_event fchg_event)
 {
-    pwr_Status_Type *para;
+    struct fchg_user_state fchg_data;
     PALLOC(battery_ind, MMI_BATTERY_IND);
 
-    para = (pwr_Status_Type *) signal_params->UserData;
-    battery_ind->volt = para->BatteryLevel;
-    battery_ind->temp = para->Status;
+    fchg_get_current_state(&fchg_data);
+    battery_ind->volt = fchg_data.batt_bars;
+    if (fchg_event == FCHG_EVENT_CHARGER_PLUG) {
+	battery_ind->temp = BATT_EVENT_CHARGER_PLUG;
+    } else {
+	switch (fchg_data.chg_state) {
+	case FCHG_STATE_CI_CHARGING:
+	case FCHG_STATE_CV_CHARGING:
+	    battery_ind->temp = BATT_STATE_CHARGING;
+	    break;
+	case FCHG_STATE_READY_TO_RECHARGE:
+	    battery_ind->temp = BATT_STATE_CHARGING_COMPLETE;
+	    break;
+	default:
+	    battery_ind->temp = BATT_STATE_NO_CHARGING;
+	}
+    }
 
     PSENDX(ACI,battery_ind);
 }
--- a/src/ui/mfw/mfw_mme.h	Fri Oct 23 01:59:58 2020 +0000
+++ b/src/ui/mfw/mfw_mme.h	Fri Oct 23 03:39:22 2020 +0000
@@ -164,13 +164,16 @@
 #define MFW_AUD_CARKIT          4
 #endif
 
-//x0pleela 10 Apr, 2006
-//Events for battery charger status
+/*
+ * FreeCalypso change: battery states and events
+ * communicated via MfwMmeBaState signal.
+ */
 enum {
-    PWR_CHG_BEGIN  = 2,  // charger begin
-    PWR_CHG_STOP   = 3,  // charger end
-    PWR_CHG_PLUG   = 4,  // charger plug
-    PWR_CHG_UNPLUG = 5   // charger unplug
+    BATT_STATE_NO_CHARGING = 0,
+    BATT_STATE_CHARGING,
+    BATT_STATE_CHARGING_COMPLETE,
+    /* last state, events follow */
+    BATT_EVENT_CHARGER_PLUG
 };
                                         /* PROTOTYPES               */
 MfwRes mmeInit (void);