commonappservices/alarmserver/ConsoleAlarmAlertServer/Source/ConsoleAlarmAlertLEDFlasher.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "ConsoleAlarmAlertLEDFlasher.h"
       
    17 #include <hal.h>
       
    18 #include <asaltdefs.h>
       
    19 
       
    20 const TInt KFlasherPeriodicity = 500000;
       
    21 
       
    22 CConsoleAlarmAlertLEDFlasher::CConsoleAlarmAlertLEDFlasher()
       
    23 :	CTimer(CActive::EPriorityIdle)
       
    24 	{
       
    25 	CActiveScheduler::Add(this);
       
    26 	}
       
    27 
       
    28 CConsoleAlarmAlertLEDFlasher* CConsoleAlarmAlertLEDFlasher::NewL()
       
    29 	{
       
    30 	CConsoleAlarmAlertLEDFlasher* self = new(ELeave) CConsoleAlarmAlertLEDFlasher();
       
    31 	CleanupStack::PushL(self);
       
    32 	self->ConstructL();
       
    33 	CleanupStack::Pop(self);
       
    34 	return self;
       
    35 	}
       
    36 
       
    37 /**
       
    38  * Start the flasher, if not busy
       
    39  */
       
    40 TInt CConsoleAlarmAlertLEDFlasher::Start()
       
    41 	{
       
    42 	Stop();
       
    43 	After(KFlasherPeriodicity);
       
    44 	return(SetRedLedOn(ETrue));
       
    45 	}
       
    46 
       
    47 
       
    48 //*************************************************************************************
       
    49 /**
       
    50  * Stop the LED flashing
       
    51  */
       
    52 void CConsoleAlarmAlertLEDFlasher::Stop()
       
    53 	{
       
    54 	Cancel();
       
    55 	SetRedLedOn(EFalse);
       
    56 	}
       
    57 
       
    58 
       
    59 //
       
    60 //
       
    61 //
       
    62 
       
    63 
       
    64 //*************************************************************************************
       
    65 /**
       
    66  * @see CActive
       
    67  */
       
    68 void CConsoleAlarmAlertLEDFlasher::RunL()
       
    69 	{
       
    70 	if (iStatus!=KErrNone)
       
    71 		{
       
    72 		SetRedLedOn(EFalse);
       
    73 		return;
       
    74 		}
       
    75 	SetRedLedOn(!iLedOn);
       
    76 	After(KFlasherPeriodicity);
       
    77 	}
       
    78 
       
    79 
       
    80 //
       
    81 //
       
    82 //
       
    83 
       
    84 
       
    85 //*************************************************************************************
       
    86 /**
       
    87  * Turn the LED on or off
       
    88  */
       
    89 TInt CConsoleAlarmAlertLEDFlasher::SetRedLedOn(TBool aOn)
       
    90 	{
       
    91 	const TInt KClearAllLeds = 0;
       
    92 	const TInt KLedMaskRed1 = 1;
       
    93 
       
    94 	iLedOn = aOn;
       
    95 	if (iLedOn)
       
    96 		{
       
    97 		return HAL::Set(HAL::ELEDmask, KLedMaskRed1);
       
    98 		}
       
    99 	else
       
   100 		{
       
   101 		return HAL::Set(HAL::ELEDmask, KClearAllLeds);
       
   102 		}
       
   103 	}
       
   104