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

timer.c

Example of timer handling.
/*
 * 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>

u8 PROGMEM t_Foo_en[] = "Timer";

u8 PROGMEM t_Started_en[] = "Timer started, countdown ... 20 sec";
u8 PROGMEM t_Bum_en[] = "Time expired, bum!";
u8 PROGMEM t_No_Timer_en[] = "No Timer Available";

void timer_expired (void *data)
{
  display_text_raw (t_Bum_en,
                    Q_DISPLAY_TEXT_HIGH_PRIORITY |
                    Q_DISPLAY_TEXT_DELAY_CLEAR);
}

void action_menu (void *data)
{
  u8 t = timer_start (0, 0, 20);

  if (t != 0)
    display_text_raw (t_Started_en,
                      Q_DISPLAY_TEXT_HIGH_PRIORITY |
                      Q_DISPLAY_TEXT_DELAY_CLEAR);
  else
    display_text_raw (t_No_Timer_en,
                      Q_DISPLAY_TEXT_HIGH_PRIORITY |
                      Q_DISPLAY_TEXT_DELAY_CLEAR);
}

void turbo_handler (u8 action, void *data)
{
  switch (action)
  {
    case ACTION_INSERT_MENU:
      insert_menu (t_Foo_en);
      break;
    case ACTION_MENU_SELECTION:
      stk_thread (action_menu, data);
      break;
    case ACTION_TIMER_EXPIRATION:
      stk_thread (timer_expired, data);
    default:
      break;
  }
}


Copyright © 2004-2006 BLADOX
Turbo version 1.2