FreeCalypso > hg > fc-tourmaline
comparison src/ui/mfw/mfw_mme.c @ 84:7160f0d005d2
first stage of actual FreeCalypso backlight rework
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Oct 2020 23:46:55 +0000 |
parents | 77321341946c |
children | b7421cdea22b |
comparison
equal
deleted
inserted
replaced
83:718ede6f6f1f | 84:7160f0d005d2 |
---|---|
127 | 127 |
128 #endif | 128 #endif |
129 | 129 |
130 #include "mfw_mfw.h" | 130 #include "mfw_mfw.h" |
131 #include "mfw_sys.h" | 131 #include "mfw_sys.h" |
132 #include "mfw_tim.h" | |
132 #include "prim.h" | 133 #include "prim.h" |
133 #include "message.h" | 134 #include "message.h" |
134 #include "prim.h" | 135 #include "prim.h" |
135 #include "aci_cmh.h" | 136 #include "aci_cmh.h" |
136 #include "gdi.h" | 137 #include "gdi.h" |
179 | 180 |
180 static U8 battLevel = 0; /* battery level */ | 181 static U8 battLevel = 0; /* battery level */ |
181 static U8 battState = 0; /* state of power supply */ | 182 static U8 battState = 0; /* state of power supply */ |
182 static U16 hdsPresence = 0; /* headset presence */ | 183 static U16 hdsPresence = 0; /* headset presence */ |
183 | 184 |
185 /* backlight control internals */ | |
186 #define LIGHT_LEVEL_OFF 0 | |
187 #define LIGHT_LEVEL_LOW 50 | |
188 #define LIGHT_LEVEL_MAX 255 | |
189 | |
190 UBYTE mme_backlight_incall; | |
191 static U8 current_backlight_level; | |
192 | |
193 static MfwHdr bltimIdleH; /* backlight timer for idle state */ | |
194 static MfwTim bltimIdle; | |
195 static MfwHdr bltimCallH; /* backlight timer for in-call state */ | |
196 static MfwTim bltimCall; | |
197 static int bl_timeout_idle (U32 t, void *h); | |
198 static int bl_timeout_call (U32 t, void *h); | |
184 | 199 |
185 static int mmeCommand (U32 cmd, void *h); | 200 static int mmeCommand (U32 cmd, void *h); |
186 | 201 |
187 /* driver callbacks */ | 202 /* driver callbacks */ |
188 static void pwrCb (enum fchg_event); | 203 static void pwrCb (enum fchg_event); |
424 | 439 |
425 battLevel = 0; | 440 battLevel = 0; |
426 battState = 0; | 441 battState = 0; |
427 hdsPresence = 0; | 442 hdsPresence = 0; |
428 | 443 |
444 /* init FreeCalypso backlight control infrastructure */ | |
445 bltimIdle.handler = bl_timeout_idle; | |
446 bltimIdle.time = 30000; | |
447 bltimIdleH.data = &bltimIdle; | |
448 bltimIdleH.type = MfwTypTim; | |
449 bltimCall.handler = bl_timeout_call; | |
450 bltimCall.time = 10000; | |
451 bltimCallH.data = &bltimCall; | |
452 bltimCallH.type = MfwTypTim; | |
429 | 453 |
430 fchg_register_event_handler(pwrCb); /* battery driver */ | 454 fchg_register_event_handler(pwrCb); /* battery driver */ |
431 rx_Init(rxCb); //fieldstrength driver | 455 rx_Init(rxCb); //fieldstrength driver |
432 light_Init(); //light emitting driver | 456 light_Init(); //light emitting driver |
433 // xpradipg - LOCOSTO-ENH-31895 : 23 June 2005 | 457 // xpradipg - LOCOSTO-ENH-31895 : 23 June 2005 |
628 | 652 |
629 return MfwResOk; // RAVI /*a0393213 compiler warnings removal - 0 changed to MfwResOk*/ | 653 return MfwResOk; // RAVI /*a0393213 compiler warnings removal - 0 changed to MfwResOk*/ |
630 } | 654 } |
631 | 655 |
632 | 656 |
633 static int mme_backlightStatus[BL_LAST_OPTION]; | |
634 /* | |
635 +--------------------------------------------------------------------+ | |
636 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
637 | STATE : code ROUTINE : mme_setBacklightIdle | | |
638 +--------------------------------------------------------------------+ | |
639 | |
640 PURPOSE : called when an event may change the backlight level/status | |
641 | |
642 */ | |
643 void mme_backlightEvent(int event) | |
644 { | |
645 int light; | |
646 if ((event >=BL_INIT) && (event <BL_LAST_OPTION)) | |
647 { | |
648 light = mme_backlightStatus[event]; | |
649 if (light == BL_SET_IDLE) | |
650 { | |
651 light_setBacklightIdle(); | |
652 } | |
653 else if (light == BL_NO_CHANGE) | |
654 { | |
655 //No change | |
656 } | |
657 else if ((light >=BL_NO_LIGHT) && (light <=BL_MAX_LIGHT)) | |
658 { | |
659 mmeBackLight ((U8)light); | |
660 } | |
661 | |
662 } | |
663 } | |
664 | |
665 /* | |
666 +--------------------------------------------------------------------+ | |
667 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
668 | STATE : code ROUTINE : mme_setBacklightIdle | | |
669 +--------------------------------------------------------------------+ | |
670 | |
671 PURPOSE : called to initialise backlight events | |
672 | |
673 */ | |
674 void mme_setBacklightEvent(int event, int lightLevel) | |
675 { | |
676 if ((event >=BL_INIT) && (event <BL_LAST_OPTION)) | |
677 { | |
678 mme_backlightStatus[event] = lightLevel; | |
679 } | |
680 } | |
681 | |
682 | |
683 /* | 657 /* |
684 +--------------------------------------------------------------------+ | 658 +--------------------------------------------------------------------+ |
685 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | 659 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | |
686 | STATE : code ROUTINE : mmeBackLight | | 660 | STATE : code ROUTINE : mmeBackLight | |
687 +--------------------------------------------------------------------+ | 661 +--------------------------------------------------------------------+ |
688 | 662 |
689 PURPOSE : set display backlight | 663 PURPOSE : set display backlight |
690 | 664 |
691 */ | 665 */ |
692 void mmeBackLight (U8 level) | 666 static void mmeBackLight (U8 level) |
693 { | 667 { |
694 light_SetStatus(LIGHT_DEVICE_BACKLIGHT,level); | 668 if (level != current_backlight_level) { |
669 light_SetStatus(LIGHT_DEVICE_BACKLIGHT, level); | |
670 current_backlight_level = level; | |
671 } | |
672 } | |
673 | |
674 /* new FreeCalypso backlight control functions */ | |
675 | |
676 void mme_backlightOnEvent (void) | |
677 { | |
678 timStop(&bltimIdleH); | |
679 timStop(&bltimCallH); | |
680 mmeBackLight(LIGHT_LEVEL_MAX); | |
681 if (mme_backlight_incall) | |
682 timStart(&bltimCallH); | |
683 else | |
684 timStart(&bltimIdleH); | |
685 } | |
686 | |
687 int mme_backlightKeyPress (void) | |
688 { | |
689 int ret; | |
690 | |
691 ret = (current_backlight_level == LIGHT_LEVEL_OFF); | |
692 timStop(&bltimIdleH); | |
693 timStop(&bltimCallH); | |
694 mmeBackLight(LIGHT_LEVEL_MAX); | |
695 return ret; | |
696 } | |
697 | |
698 static int bl_timeout_idle (U32 t, void *h) | |
699 { | |
700 mmeBackLight(LIGHT_LEVEL_OFF); | |
701 } | |
702 | |
703 static int bl_timeout_call (U32 t, void *h) | |
704 { | |
705 mmeBackLight(LIGHT_LEVEL_LOW); | |
695 } | 706 } |
696 | 707 |
697 | 708 |
698 /* | 709 /* |
699 +--------------------------------------------------------------------+ | 710 +--------------------------------------------------------------------+ |