Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

Call Controlled Switch

led.png

Call Controlled LED

This example uses ACTION_EVENT_MT_CALL to toggle state of some connected switch. The first incoming call sets switch on, the second call off. And the cycle repeates.

Note:
It is attractive to the user because this control does not cost a penny. The call connection is not established.
Possible modifications:

/*
 * Copyright (C) 2003 BLADOX, s.r.o.  All rights reserved.
 * 
 * This file is part of an example program for Turbo. This example
 * program may be used, distributed and modified without limitation.
 *
 */

#include <config.h>
#include <turbo/turbo.h>

//------------------------------------------------------------------------
//  OUTPUT pin of LED application (AD0 = PA0)
//------------------------------------------------------------------------
#define LED_DDR DDRA
#define LED_DDR_PIN DD0
#define LED_PORT PORTA
#define LED_PORT_PIN PORT0
#define LED_PIN PINA
#define LED_PIN_PIN PIN0

u8 state;

void set_pin (u8 s)
{
  if (s != 0)
    sbi (LED_PORT, LED_PORT_PIN);       //set LED pin output register bit to log.1
  else
    cbi (LED_PORT, LED_PORT_PIN);       //set LED pin output register bit to log.0
}

void turbo_handler (u8 action, void *data)
{
  switch (action)
  {
    case ACTION_APP_INIT:
      reg_action (ACTION_EVENT_MT_CALL);
      state = 0;
      sbi (LED_DDR, LED_DDR_PIN);       //LED pin is OUTPUT
      set_pin (state);
      break;
    case ACTION_EVENT_MT_CALL:
      state = !state;
      set_pin (state);
      break;
    default:
      break;
  }
}


Copyright © 2004-2006 BLADOX
Turbo version 1.2