buildverification/autosmoketest/Timew/ConsoleAlarmAlertServer/Source/ConsoleAlarmAlertLEDFlasher.cpp
branchRCL_3
changeset 11 493058e57c8c
parent 0 9736f095102e
equal deleted inserted replaced
10:4ca382093dae 11:493058e57c8c
       
     1 // Copyright (c) 1997-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 
       
    18 // System includes
       
    19 #include <hal.h>
       
    20 
       
    21 // User includes
       
    22 #include "asaltdefs.h"
       
    23 
       
    24 // Type definitions
       
    25 
       
    26 // Constants
       
    27 const TInt KFlasherPeriodicity = 500000;
       
    28 
       
    29 // Enumerations
       
    30 
       
    31 // Classes referenced
       
    32 
       
    33 
       
    34 //
       
    35 // ----> CConsoleAlarmAlertLEDFlasher (source)
       
    36 //
       
    37 
       
    38 //*************************************************************************************
       
    39 CConsoleAlarmAlertLEDFlasher::CConsoleAlarmAlertLEDFlasher()
       
    40 :	CTimer(CActive::EPriorityIdle)
       
    41 	{
       
    42 	CActiveScheduler::Add(this);
       
    43 	}
       
    44 
       
    45 
       
    46 //*************************************************************************************
       
    47 CConsoleAlarmAlertLEDFlasher* CConsoleAlarmAlertLEDFlasher::NewL()
       
    48 	{
       
    49 	CConsoleAlarmAlertLEDFlasher* self = new(ELeave) CConsoleAlarmAlertLEDFlasher();
       
    50 	CleanupStack::PushL(self);
       
    51 	self->ConstructL();
       
    52 	CleanupStack::Pop(self);
       
    53 	return self;
       
    54 	}
       
    55 
       
    56 
       
    57 //
       
    58 //
       
    59 //
       
    60 
       
    61 
       
    62 //*************************************************************************************
       
    63 /**
       
    64  * Start the flasher, if not busy
       
    65  */
       
    66 TInt CConsoleAlarmAlertLEDFlasher::Start()
       
    67 	{
       
    68 	Stop();
       
    69 	After(KFlasherPeriodicity);
       
    70 	return(SetRedLedOn(ETrue));
       
    71 	}
       
    72 
       
    73 
       
    74 //*************************************************************************************
       
    75 /**
       
    76  * Stop the LED flashing
       
    77  */
       
    78 void CConsoleAlarmAlertLEDFlasher::Stop()
       
    79 	{
       
    80 	Cancel();
       
    81 	SetRedLedOn(EFalse);
       
    82 	}
       
    83 
       
    84 
       
    85 //
       
    86 //
       
    87 //
       
    88 
       
    89 
       
    90 //*************************************************************************************
       
    91 /**
       
    92  * @see CActive
       
    93  */
       
    94 void CConsoleAlarmAlertLEDFlasher::RunL()
       
    95 	{
       
    96 	if (iStatus!=KErrNone)
       
    97 		{
       
    98 		SetRedLedOn(EFalse);
       
    99 		return;
       
   100 		}
       
   101 	SetRedLedOn(!iLedOn);
       
   102 	After(KFlasherPeriodicity);
       
   103 	}
       
   104 
       
   105 
       
   106 //
       
   107 //
       
   108 //
       
   109 
       
   110 
       
   111 //*************************************************************************************
       
   112 /**
       
   113  * Turn the LED on or off
       
   114  */
       
   115 TInt CConsoleAlarmAlertLEDFlasher::SetRedLedOn(TBool aOn)
       
   116 	{
       
   117 	const TInt KClearAllLeds = 0;
       
   118 	const TInt KLedMaskRed1 = 1;
       
   119 
       
   120 	iLedOn = aOn;
       
   121 	if (iLedOn)
       
   122 		{
       
   123 		return HAL::Set(HAL::ELEDmask, KLedMaskRed1);
       
   124 		}
       
   125 	else
       
   126 		{
       
   127 		return HAL::Set(HAL::ELEDmask, KClearAllLeds);
       
   128 		}
       
   129 	}
       
   130